Fossil SCM

Merge recent addtional features (integrate, reports, timeline, et al.) from trunk.

andybradford 2013-08-05 17:39 ssh-shared-account merge
Commit a5df66f3aa7a5fe07c715395c4d4be4dca0a8471
+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
+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
+44 -1
--- src/checkin.c
+++ src/checkin.c
@@ -108,10 +108,14 @@
108108
}else if( isChnged ){
109109
if( isChnged==2 ){
110110
blob_appendf(report, "UPDATED_BY_MERGE %s\n", zDisplayName);
111111
}else if( isChnged==3 ){
112112
blob_appendf(report, "ADDED_BY_MERGE %s\n", zDisplayName);
113
+ }else if( isChnged==4 ){
114
+ blob_appendf(report, "UPDATED_BY_INTEGRATE %s\n", zDisplayName);
115
+ }else if( isChnged==5 ){
116
+ blob_appendf(report, "ADDED_BY_INTEGRATE %s\n", zDisplayName);
113117
}else if( file_contains_merge_marker(zFullName) ){
114118
blob_appendf(report, "CONFLICT %s\n", zDisplayName);
115119
}else{
116120
blob_appendf(report, "EDITED %s\n", zDisplayName);
117121
}
@@ -129,10 +133,11 @@
129133
while( db_step(&q)==SQLITE_ROW ){
130134
const char *zLabel = "MERGED_WITH";
131135
switch( db_column_int(&q, 1) ){
132136
case -1: zLabel = "CHERRYPICK "; break;
133137
case -2: zLabel = "BACKOUT "; break;
138
+ case -4: zLabel = "INTEGRATE "; break;
134139
}
135140
blob_append(report, zPrefix, nPrefix);
136141
blob_appendf(report, "%s %s\n", zLabel, db_column_text(&q, 0));
137142
}
138143
db_finalize(&q);
@@ -332,10 +337,14 @@
332337
}else if( chnged ){
333338
if( chnged==2 ){
334339
type = "UPDATED_BY_MERGE ";
335340
}else if( chnged==3 ){
336341
type = "ADDED_BY_MERGE ";
342
+ }else if( chnged==4 ){
343
+ type = "UPDATED_BY_INTEGRATE ";
344
+ }else if( chnged==5 ){
345
+ type = "ADDED_BY_INTEGRATE ";
337346
}else if( file_contains_merge_marker(zFullName) ){
338347
type = "CONFLICT ";
339348
}else{
340349
type = "EDITED ";
341350
}
@@ -1678,24 +1687,58 @@
16781687
** and rollback the transaction.
16791688
*/
16801689
if( dryRunFlag ){
16811690
blob_write_to_file(&manifest, "");
16821691
}
1683
-
16841692
if( outputManifest ){
16851693
zManifestFile = mprintf("%smanifest", g.zLocalRoot);
16861694
blob_write_to_file(&manifest, zManifestFile);
16871695
blob_reset(&manifest);
16881696
blob_read_from_file(&manifest, zManifestFile);
16891697
free(zManifestFile);
16901698
}
1699
+
16911700
nvid = content_put(&manifest);
16921701
if( nvid==0 ){
16931702
fossil_panic("trouble committing manifest: %s", g.zErrMsg);
16941703
}
16951704
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid);
16961705
manifest_crosslink(nvid, &manifest);
1706
+
1707
+ db_prepare(&q, "SELECT uuid,merge FROM vmerge JOIN blob ON merge=rid"
1708
+ " WHERE id=-4");
1709
+ while( db_step(&q)==SQLITE_ROW ){
1710
+ const char *zIntegrateUuid = db_column_text(&q, 0);
1711
+ int rid = db_column_int(&q, 1);
1712
+ if( !is_a_leaf(rid) ){
1713
+ fossil_print("Not_Closed: %s (not a leaf any more)\n", zIntegrateUuid);
1714
+ }else{
1715
+ if (!db_exists("SELECT 1 FROM tagxref "
1716
+ " WHERE tagid=%d AND rid=%d AND tagtype>0",
1717
+ TAG_CLOSED, rid)
1718
+ ){
1719
+ Blob ctrl;
1720
+ Blob cksum;
1721
+ char *zDate;
1722
+ int nrid;
1723
+
1724
+ blob_zero(&ctrl);
1725
+ zDate = date_in_standard_format(sCiInfo.zDateOvrd ? sCiInfo.zDateOvrd : "now");
1726
+ blob_appendf(&ctrl, "D %s\n", zDate);
1727
+ blob_appendf(&ctrl, "T +closed %s\n", zIntegrateUuid);
1728
+ blob_appendf(&ctrl, "U %F\n", sCiInfo.zUserOvrd ? sCiInfo.zUserOvrd : g.zLogin);
1729
+ md5sum_blob(&ctrl, &cksum);
1730
+ blob_appendf(&ctrl, "Z %b\n", &cksum);
1731
+ nrid = content_put(&ctrl);
1732
+ manifest_crosslink(nrid, &ctrl);
1733
+ assert( blob_is_reset(&ctrl) );
1734
+ }
1735
+ fossil_print("Closed: %s\n", zIntegrateUuid);
1736
+ }
1737
+ }
1738
+ db_finalize(&q);
1739
+
16971740
assert( blob_is_reset(&manifest) );
16981741
content_deltify(vid, nvid, 0);
16991742
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", nvid);
17001743
fossil_print("New_Version: %s\n", zUuid);
17011744
if( outputManifest ){
17021745
--- src/checkin.c
+++ src/checkin.c
@@ -108,10 +108,14 @@
108 }else if( isChnged ){
109 if( isChnged==2 ){
110 blob_appendf(report, "UPDATED_BY_MERGE %s\n", zDisplayName);
111 }else if( isChnged==3 ){
112 blob_appendf(report, "ADDED_BY_MERGE %s\n", zDisplayName);
 
 
 
 
113 }else if( file_contains_merge_marker(zFullName) ){
114 blob_appendf(report, "CONFLICT %s\n", zDisplayName);
115 }else{
116 blob_appendf(report, "EDITED %s\n", zDisplayName);
117 }
@@ -129,10 +133,11 @@
129 while( db_step(&q)==SQLITE_ROW ){
130 const char *zLabel = "MERGED_WITH";
131 switch( db_column_int(&q, 1) ){
132 case -1: zLabel = "CHERRYPICK "; break;
133 case -2: zLabel = "BACKOUT "; break;
 
134 }
135 blob_append(report, zPrefix, nPrefix);
136 blob_appendf(report, "%s %s\n", zLabel, db_column_text(&q, 0));
137 }
138 db_finalize(&q);
@@ -332,10 +337,14 @@
332 }else if( chnged ){
333 if( chnged==2 ){
334 type = "UPDATED_BY_MERGE ";
335 }else if( chnged==3 ){
336 type = "ADDED_BY_MERGE ";
 
 
 
 
337 }else if( file_contains_merge_marker(zFullName) ){
338 type = "CONFLICT ";
339 }else{
340 type = "EDITED ";
341 }
@@ -1678,24 +1687,58 @@
1678 ** and rollback the transaction.
1679 */
1680 if( dryRunFlag ){
1681 blob_write_to_file(&manifest, "");
1682 }
1683
1684 if( outputManifest ){
1685 zManifestFile = mprintf("%smanifest", g.zLocalRoot);
1686 blob_write_to_file(&manifest, zManifestFile);
1687 blob_reset(&manifest);
1688 blob_read_from_file(&manifest, zManifestFile);
1689 free(zManifestFile);
1690 }
 
1691 nvid = content_put(&manifest);
1692 if( nvid==0 ){
1693 fossil_panic("trouble committing manifest: %s", g.zErrMsg);
1694 }
1695 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid);
1696 manifest_crosslink(nvid, &manifest);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1697 assert( blob_is_reset(&manifest) );
1698 content_deltify(vid, nvid, 0);
1699 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", nvid);
1700 fossil_print("New_Version: %s\n", zUuid);
1701 if( outputManifest ){
1702
--- src/checkin.c
+++ src/checkin.c
@@ -108,10 +108,14 @@
108 }else if( isChnged ){
109 if( isChnged==2 ){
110 blob_appendf(report, "UPDATED_BY_MERGE %s\n", zDisplayName);
111 }else if( isChnged==3 ){
112 blob_appendf(report, "ADDED_BY_MERGE %s\n", zDisplayName);
113 }else if( isChnged==4 ){
114 blob_appendf(report, "UPDATED_BY_INTEGRATE %s\n", zDisplayName);
115 }else if( isChnged==5 ){
116 blob_appendf(report, "ADDED_BY_INTEGRATE %s\n", zDisplayName);
117 }else if( file_contains_merge_marker(zFullName) ){
118 blob_appendf(report, "CONFLICT %s\n", zDisplayName);
119 }else{
120 blob_appendf(report, "EDITED %s\n", zDisplayName);
121 }
@@ -129,10 +133,11 @@
133 while( db_step(&q)==SQLITE_ROW ){
134 const char *zLabel = "MERGED_WITH";
135 switch( db_column_int(&q, 1) ){
136 case -1: zLabel = "CHERRYPICK "; break;
137 case -2: zLabel = "BACKOUT "; break;
138 case -4: zLabel = "INTEGRATE "; break;
139 }
140 blob_append(report, zPrefix, nPrefix);
141 blob_appendf(report, "%s %s\n", zLabel, db_column_text(&q, 0));
142 }
143 db_finalize(&q);
@@ -332,10 +337,14 @@
337 }else if( chnged ){
338 if( chnged==2 ){
339 type = "UPDATED_BY_MERGE ";
340 }else if( chnged==3 ){
341 type = "ADDED_BY_MERGE ";
342 }else if( chnged==4 ){
343 type = "UPDATED_BY_INTEGRATE ";
344 }else if( chnged==5 ){
345 type = "ADDED_BY_INTEGRATE ";
346 }else if( file_contains_merge_marker(zFullName) ){
347 type = "CONFLICT ";
348 }else{
349 type = "EDITED ";
350 }
@@ -1678,24 +1687,58 @@
1687 ** and rollback the transaction.
1688 */
1689 if( dryRunFlag ){
1690 blob_write_to_file(&manifest, "");
1691 }
 
1692 if( outputManifest ){
1693 zManifestFile = mprintf("%smanifest", g.zLocalRoot);
1694 blob_write_to_file(&manifest, zManifestFile);
1695 blob_reset(&manifest);
1696 blob_read_from_file(&manifest, zManifestFile);
1697 free(zManifestFile);
1698 }
1699
1700 nvid = content_put(&manifest);
1701 if( nvid==0 ){
1702 fossil_panic("trouble committing manifest: %s", g.zErrMsg);
1703 }
1704 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid);
1705 manifest_crosslink(nvid, &manifest);
1706
1707 db_prepare(&q, "SELECT uuid,merge FROM vmerge JOIN blob ON merge=rid"
1708 " WHERE id=-4");
1709 while( db_step(&q)==SQLITE_ROW ){
1710 const char *zIntegrateUuid = db_column_text(&q, 0);
1711 int rid = db_column_int(&q, 1);
1712 if( !is_a_leaf(rid) ){
1713 fossil_print("Not_Closed: %s (not a leaf any more)\n", zIntegrateUuid);
1714 }else{
1715 if (!db_exists("SELECT 1 FROM tagxref "
1716 " WHERE tagid=%d AND rid=%d AND tagtype>0",
1717 TAG_CLOSED, rid)
1718 ){
1719 Blob ctrl;
1720 Blob cksum;
1721 char *zDate;
1722 int nrid;
1723
1724 blob_zero(&ctrl);
1725 zDate = date_in_standard_format(sCiInfo.zDateOvrd ? sCiInfo.zDateOvrd : "now");
1726 blob_appendf(&ctrl, "D %s\n", zDate);
1727 blob_appendf(&ctrl, "T +closed %s\n", zIntegrateUuid);
1728 blob_appendf(&ctrl, "U %F\n", sCiInfo.zUserOvrd ? sCiInfo.zUserOvrd : g.zLogin);
1729 md5sum_blob(&ctrl, &cksum);
1730 blob_appendf(&ctrl, "Z %b\n", &cksum);
1731 nrid = content_put(&ctrl);
1732 manifest_crosslink(nrid, &ctrl);
1733 assert( blob_is_reset(&ctrl) );
1734 }
1735 fossil_print("Closed: %s\n", zIntegrateUuid);
1736 }
1737 }
1738 db_finalize(&q);
1739
1740 assert( blob_is_reset(&manifest) );
1741 content_deltify(vid, nvid, 0);
1742 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", nvid);
1743 fossil_print("New_Version: %s\n", zUuid);
1744 if( outputManifest ){
1745
+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/json_status.c
+++ src/json_status.c
@@ -157,10 +157,11 @@
157157
while( db_step(&q)==SQLITE_ROW ){
158158
const char *zLabel = "MERGED_WITH";
159159
switch( db_column_int(&q, 1) ){
160160
case -1: zLabel = "CHERRYPICK "; break;
161161
case -2: zLabel = "BACKOUT "; break;
162
+ case -4: zLabel = "INTEGRATE "; break;
162163
}
163164
blob_append(report, zPrefix, nPrefix);
164165
blob_appendf(report, "%s %s\n", zLabel, db_column_text(&q, 0));
165166
}
166167
db_finalize(&q);
167168
--- src/json_status.c
+++ src/json_status.c
@@ -157,10 +157,11 @@
157 while( db_step(&q)==SQLITE_ROW ){
158 const char *zLabel = "MERGED_WITH";
159 switch( db_column_int(&q, 1) ){
160 case -1: zLabel = "CHERRYPICK "; break;
161 case -2: zLabel = "BACKOUT "; break;
 
162 }
163 blob_append(report, zPrefix, nPrefix);
164 blob_appendf(report, "%s %s\n", zLabel, db_column_text(&q, 0));
165 }
166 db_finalize(&q);
167
--- src/json_status.c
+++ src/json_status.c
@@ -157,10 +157,11 @@
157 while( db_step(&q)==SQLITE_ROW ){
158 const char *zLabel = "MERGED_WITH";
159 switch( db_column_int(&q, 1) ){
160 case -1: zLabel = "CHERRYPICK "; break;
161 case -2: zLabel = "BACKOUT "; break;
162 case -4: zLabel = "INTEGRATE "; break;
163 }
164 blob_append(report, zPrefix, nPrefix);
165 blob_appendf(report, "%s %s\n", zLabel, db_column_text(&q, 0));
166 }
167 db_finalize(&q);
168
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -98,11 +98,11 @@
9898
@ SELECT
9999
@ NULL,
100100
@ blob.rid,
101101
@ uuid,
102102
@ CAST(strftime('%%s',event.mtime) AS INTEGER),
103
- @ datetime(event.mtime,'utc'),
103
+ @ datetime(event.mtime),
104104
@ coalesce(ecomment, comment),
105105
@ coalesce(euser, user),
106106
@ blob.rid IN leaf,
107107
@ bgcolor,
108108
@ event.type,
109109
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -98,11 +98,11 @@
98 @ SELECT
99 @ NULL,
100 @ blob.rid,
101 @ uuid,
102 @ CAST(strftime('%%s',event.mtime) AS INTEGER),
103 @ datetime(event.mtime,'utc'),
104 @ coalesce(ecomment, comment),
105 @ coalesce(euser, user),
106 @ blob.rid IN leaf,
107 @ bgcolor,
108 @ event.type,
109
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -98,11 +98,11 @@
98 @ SELECT
99 @ NULL,
100 @ blob.rid,
101 @ uuid,
102 @ CAST(strftime('%%s',event.mtime) AS INTEGER),
103 @ datetime(event.mtime),
104 @ coalesce(ecomment, comment),
105 @ coalesce(euser, user),
106 @ blob.rid IN leaf,
107 @ bgcolor,
108 @ event.type,
109
+2
--- src/main.c
+++ src/main.c
@@ -162,10 +162,11 @@
162162
int markPrivate; /* All new artifacts are private if true */
163163
int clockSkewSeen; /* True if clocks on client and server out of sync */
164164
int wikiFlags; /* Wiki conversion flags applied to %w and %W */
165165
char isHTTP; /* True if server/CGI modes, else assume CLI. */
166166
char javascriptHyperlink; /* If true, set href= using script, not HTML */
167
+ Blob httpHeader; /* Complete text of the HTTP request header */
167168
168169
int urlIsFile; /* True if a "file:" url */
169170
int urlIsHttps; /* True if a "https:" url */
170171
int urlIsSsh; /* True if an "ssh:" url */
171172
char *urlName; /* Hostname for http: or filename for file: */
@@ -530,10 +531,11 @@
530531
int idx;
531532
int rc;
532533
sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
533534
memset(&g, 0, sizeof(g));
534535
g.now = time(0);
536
+ g.httpHeader = empty_blob;
535537
#ifdef FOSSIL_ENABLE_JSON
536538
#if defined(NDEBUG)
537539
g.json.errorDetailParanoia = 2 /* FIXME: make configurable
538540
One problem we have here is that this
539541
code is needed before the db is opened,
540542
--- src/main.c
+++ src/main.c
@@ -162,10 +162,11 @@
162 int markPrivate; /* All new artifacts are private if true */
163 int clockSkewSeen; /* True if clocks on client and server out of sync */
164 int wikiFlags; /* Wiki conversion flags applied to %w and %W */
165 char isHTTP; /* True if server/CGI modes, else assume CLI. */
166 char javascriptHyperlink; /* If true, set href= using script, not HTML */
 
167
168 int urlIsFile; /* True if a "file:" url */
169 int urlIsHttps; /* True if a "https:" url */
170 int urlIsSsh; /* True if an "ssh:" url */
171 char *urlName; /* Hostname for http: or filename for file: */
@@ -530,10 +531,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 #ifdef FOSSIL_ENABLE_JSON
536 #if defined(NDEBUG)
537 g.json.errorDetailParanoia = 2 /* FIXME: make configurable
538 One problem we have here is that this
539 code is needed before the db is opened,
540
--- src/main.c
+++ src/main.c
@@ -162,10 +162,11 @@
162 int markPrivate; /* All new artifacts are private if true */
163 int clockSkewSeen; /* True if clocks on client and server out of sync */
164 int wikiFlags; /* Wiki conversion flags applied to %w and %W */
165 char isHTTP; /* True if server/CGI modes, else assume CLI. */
166 char javascriptHyperlink; /* If true, set href= using script, not HTML */
167 Blob httpHeader; /* Complete text of the HTTP request header */
168
169 int urlIsFile; /* True if a "file:" url */
170 int urlIsHttps; /* True if a "https:" url */
171 int urlIsSsh; /* True if an "ssh:" url */
172 char *urlName; /* Hostname for http: or filename for file: */
@@ -530,10 +531,11 @@
531 int idx;
532 int rc;
533 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
534 memset(&g, 0, sizeof(g));
535 g.now = time(0);
536 g.httpHeader = empty_blob;
537 #ifdef FOSSIL_ENABLE_JSON
538 #if defined(NDEBUG)
539 g.json.errorDetailParanoia = 2 /* FIXME: make configurable
540 One problem we have here is that this
541 code is needed before the db is opened,
542
+2
--- src/main.c
+++ src/main.c
@@ -162,10 +162,11 @@
162162
int markPrivate; /* All new artifacts are private if true */
163163
int clockSkewSeen; /* True if clocks on client and server out of sync */
164164
int wikiFlags; /* Wiki conversion flags applied to %w and %W */
165165
char isHTTP; /* True if server/CGI modes, else assume CLI. */
166166
char javascriptHyperlink; /* If true, set href= using script, not HTML */
167
+ Blob httpHeader; /* Complete text of the HTTP request header */
167168
168169
int urlIsFile; /* True if a "file:" url */
169170
int urlIsHttps; /* True if a "https:" url */
170171
int urlIsSsh; /* True if an "ssh:" url */
171172
char *urlName; /* Hostname for http: or filename for file: */
@@ -530,10 +531,11 @@
530531
int idx;
531532
int rc;
532533
sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
533534
memset(&g, 0, sizeof(g));
534535
g.now = time(0);
536
+ g.httpHeader = empty_blob;
535537
#ifdef FOSSIL_ENABLE_JSON
536538
#if defined(NDEBUG)
537539
g.json.errorDetailParanoia = 2 /* FIXME: make configurable
538540
One problem we have here is that this
539541
code is needed before the db is opened,
540542
--- src/main.c
+++ src/main.c
@@ -162,10 +162,11 @@
162 int markPrivate; /* All new artifacts are private if true */
163 int clockSkewSeen; /* True if clocks on client and server out of sync */
164 int wikiFlags; /* Wiki conversion flags applied to %w and %W */
165 char isHTTP; /* True if server/CGI modes, else assume CLI. */
166 char javascriptHyperlink; /* If true, set href= using script, not HTML */
 
167
168 int urlIsFile; /* True if a "file:" url */
169 int urlIsHttps; /* True if a "https:" url */
170 int urlIsSsh; /* True if an "ssh:" url */
171 char *urlName; /* Hostname for http: or filename for file: */
@@ -530,10 +531,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 #ifdef FOSSIL_ENABLE_JSON
536 #if defined(NDEBUG)
537 g.json.errorDetailParanoia = 2 /* FIXME: make configurable
538 One problem we have here is that this
539 code is needed before the db is opened,
540
--- src/main.c
+++ src/main.c
@@ -162,10 +162,11 @@
162 int markPrivate; /* All new artifacts are private if true */
163 int clockSkewSeen; /* True if clocks on client and server out of sync */
164 int wikiFlags; /* Wiki conversion flags applied to %w and %W */
165 char isHTTP; /* True if server/CGI modes, else assume CLI. */
166 char javascriptHyperlink; /* If true, set href= using script, not HTML */
167 Blob httpHeader; /* Complete text of the HTTP request header */
168
169 int urlIsFile; /* True if a "file:" url */
170 int urlIsHttps; /* True if a "https:" url */
171 int urlIsSsh; /* True if an "ssh:" url */
172 char *urlName; /* Hostname for http: or filename for file: */
@@ -530,10 +531,11 @@
531 int idx;
532 int rc;
533 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
534 memset(&g, 0, sizeof(g));
535 g.now = time(0);
536 g.httpHeader = empty_blob;
537 #ifdef FOSSIL_ENABLE_JSON
538 #if defined(NDEBUG)
539 g.json.errorDetailParanoia = 2 /* FIXME: make configurable
540 One problem we have here is that this
541 code is needed before the db is opened,
542
+20 -7
--- src/merge.c
+++ src/merge.c
@@ -91,19 +91,22 @@
9191
** files whose names differ only in case are taken
9292
** to be the same file.
9393
**
9494
** -f|--force Force the merge even if it would be a no-op.
9595
**
96
+** --integrate Merged branch will be closed when committing.
97
+**
9698
** -n|--dry-run If given, display instead of run actions
9799
**
98100
** -v|--verbose Show additional details of the merge
99101
*/
100102
void merge_cmd(void){
101103
int vid; /* Current version "V" */
102104
int mid; /* Version we are merging from "M" */
103105
int pid; /* The pivot version - most recent common ancestor P */
104106
int verboseFlag; /* True if the -v|--verbose option is present */
107
+ int integrateFlag; /* True if the --integrate option is present */
105108
int pickFlag; /* True if the --cherrypick option is present */
106109
int backoutFlag; /* True if the --backout option is present */
107110
int dryRunFlag; /* True if the --dry-run or -n option is present */
108111
int forceFlag; /* True if the --force or -f option is present */
109112
const char *zBinGlob; /* The value of --binary */
@@ -128,10 +131,11 @@
128131
verboseFlag = find_option("verbose","v",0)!=0;
129132
if( !verboseFlag ){
130133
verboseFlag = find_option("detail",0,0)!=0; /* deprecated */
131134
}
132135
pickFlag = find_option("cherrypick",0,0)!=0;
136
+ integrateFlag = find_option("integrate",0,0)!=0;
133137
backoutFlag = find_option("backout",0,0)!=0;
134138
debugFlag = find_option("debug",0,0)!=0;
135139
zBinGlob = find_option("binary",0,1);
136140
dryRunFlag = find_option("dry-run","n",0)!=0;
137141
if( !dryRunFlag ){
@@ -162,12 +166,12 @@
162166
** has not already been merged into the current checkout and (3)
163167
** the leaf is not closed and (4) the leaf is in the same branch
164168
** as the current checkout.
165169
*/
166170
Stmt q;
167
- if( pickFlag || backoutFlag ){
168
- fossil_fatal("cannot use --cherrypick or --backout with a fork merge");
171
+ if( pickFlag || backoutFlag || integrateFlag){
172
+ fossil_fatal("cannot use --backout, --cherrypick or --integrate with a fork merge");
169173
}
170174
mid = db_int(0,
171175
"SELECT leaf.rid"
172176
" FROM leaf, event"
173177
" WHERE leaf.rid=event.objid"
@@ -220,10 +224,13 @@
220224
}
221225
if( pickFlag ){
222226
fossil_fatal("incompatible options: --cherrypick & --baseline");
223227
}
224228
}else if( pickFlag || backoutFlag ){
229
+ if( integrateFlag ){
230
+ fossil_fatal("incompatible options: --integrate & --cherrypick or --backout");
231
+ }
225232
pid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", mid);
226233
if( pid<=0 ){
227234
fossil_fatal("cannot find an ancestor for %s", g.argv[2]);
228235
}
229236
}else{
@@ -251,12 +258,16 @@
251258
if( !forceFlag && mid==pid ){
252259
fossil_print("Merge skipped because it is a no-op. "
253260
" Use --force to override.\n");
254261
return;
255262
}
263
+ if( integrateFlag && !is_a_leaf(mid) ){
264
+ fossil_warning("ignoring --integrate: %s is not a leaf", g.argv[2]);
265
+ integrateFlag = 0;
266
+ }
256267
if( verboseFlag ){
257
- print_checkin_description(mid, 12, "merge-from:");
268
+ print_checkin_description(mid, 12, integrateFlag?"integrate:":"merge-from:");
258269
print_checkin_description(pid, 12, "baseline:");
259270
}
260271
vfile_check_signature(vid, CKSIG_ENOTFILE);
261272
db_begin_transaction();
262273
if( !dryRunFlag ) undo_begin();
@@ -434,12 +445,12 @@
434445
int idv;
435446
const char *zName;
436447
char *zFullName;
437448
db_multi_exec(
438449
"INSERT INTO vfile(vid,chnged,deleted,rid,mrid,isexe,islink,pathname)"
439
- " SELECT %d,3,0,rid,mrid,isexe,islink,pathname FROM vfile WHERE id=%d",
440
- vid, idm
450
+ " SELECT %d,%d,0,rid,mrid,isexe,islink,pathname FROM vfile WHERE id=%d",
451
+ vid, integrateFlag?5:3, idm
441452
);
442453
idv = db_last_insert_rowid();
443454
db_multi_exec("UPDATE fv SET idv=%d WHERE rowid=%d", idv, rowid);
444455
zName = db_column_text(&q, 2);
445456
zFullName = mprintf("%s%s", g.zLocalRoot, zName);
@@ -474,12 +485,12 @@
474485
/* Copy content from idm over into idv. Overwrite idv. */
475486
fossil_print("UPDATE %s\n", zName);
476487
if( !dryRunFlag ){
477488
undo_save(zName);
478489
db_multi_exec(
479
- "UPDATE vfile SET mtime=0, mrid=%d, chnged=2, islink=%d "
480
- " WHERE id=%d", ridm, islinkm, idv
490
+ "UPDATE vfile SET mtime=0, mrid=%d, chnged=%d, islink=%d "
491
+ " WHERE id=%d", ridm, integrateFlag?4:2, islinkm, idv
481492
);
482493
vfile_to_disk(0, idv, 0, 0);
483494
}
484495
}
485496
db_finalize(&q);
@@ -644,11 +655,13 @@
644655
" WHERE type='ci' AND objid=%d",
645656
mid
646657
);
647658
}else if( backoutFlag ){
648659
db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(-2,%d)",pid);
660
+ }else if( integrateFlag ){
661
+ db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(-4,%d)",mid);
649662
}else{
650663
db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(0,%d)", mid);
651664
}
652665
undo_finish();
653666
db_end_transaction(dryRunFlag);
654667
}
655668
--- src/merge.c
+++ src/merge.c
@@ -91,19 +91,22 @@
91 ** files whose names differ only in case are taken
92 ** to be the same file.
93 **
94 ** -f|--force Force the merge even if it would be a no-op.
95 **
 
 
96 ** -n|--dry-run If given, display instead of run actions
97 **
98 ** -v|--verbose Show additional details of the merge
99 */
100 void merge_cmd(void){
101 int vid; /* Current version "V" */
102 int mid; /* Version we are merging from "M" */
103 int pid; /* The pivot version - most recent common ancestor P */
104 int verboseFlag; /* True if the -v|--verbose option is present */
 
105 int pickFlag; /* True if the --cherrypick option is present */
106 int backoutFlag; /* True if the --backout option is present */
107 int dryRunFlag; /* True if the --dry-run or -n option is present */
108 int forceFlag; /* True if the --force or -f option is present */
109 const char *zBinGlob; /* The value of --binary */
@@ -128,10 +131,11 @@
128 verboseFlag = find_option("verbose","v",0)!=0;
129 if( !verboseFlag ){
130 verboseFlag = find_option("detail",0,0)!=0; /* deprecated */
131 }
132 pickFlag = find_option("cherrypick",0,0)!=0;
 
133 backoutFlag = find_option("backout",0,0)!=0;
134 debugFlag = find_option("debug",0,0)!=0;
135 zBinGlob = find_option("binary",0,1);
136 dryRunFlag = find_option("dry-run","n",0)!=0;
137 if( !dryRunFlag ){
@@ -162,12 +166,12 @@
162 ** has not already been merged into the current checkout and (3)
163 ** the leaf is not closed and (4) the leaf is in the same branch
164 ** as the current checkout.
165 */
166 Stmt q;
167 if( pickFlag || backoutFlag ){
168 fossil_fatal("cannot use --cherrypick or --backout with a fork merge");
169 }
170 mid = db_int(0,
171 "SELECT leaf.rid"
172 " FROM leaf, event"
173 " WHERE leaf.rid=event.objid"
@@ -220,10 +224,13 @@
220 }
221 if( pickFlag ){
222 fossil_fatal("incompatible options: --cherrypick & --baseline");
223 }
224 }else if( pickFlag || backoutFlag ){
 
 
 
225 pid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", mid);
226 if( pid<=0 ){
227 fossil_fatal("cannot find an ancestor for %s", g.argv[2]);
228 }
229 }else{
@@ -251,12 +258,16 @@
251 if( !forceFlag && mid==pid ){
252 fossil_print("Merge skipped because it is a no-op. "
253 " Use --force to override.\n");
254 return;
255 }
 
 
 
 
256 if( verboseFlag ){
257 print_checkin_description(mid, 12, "merge-from:");
258 print_checkin_description(pid, 12, "baseline:");
259 }
260 vfile_check_signature(vid, CKSIG_ENOTFILE);
261 db_begin_transaction();
262 if( !dryRunFlag ) undo_begin();
@@ -434,12 +445,12 @@
434 int idv;
435 const char *zName;
436 char *zFullName;
437 db_multi_exec(
438 "INSERT INTO vfile(vid,chnged,deleted,rid,mrid,isexe,islink,pathname)"
439 " SELECT %d,3,0,rid,mrid,isexe,islink,pathname FROM vfile WHERE id=%d",
440 vid, idm
441 );
442 idv = db_last_insert_rowid();
443 db_multi_exec("UPDATE fv SET idv=%d WHERE rowid=%d", idv, rowid);
444 zName = db_column_text(&q, 2);
445 zFullName = mprintf("%s%s", g.zLocalRoot, zName);
@@ -474,12 +485,12 @@
474 /* Copy content from idm over into idv. Overwrite idv. */
475 fossil_print("UPDATE %s\n", zName);
476 if( !dryRunFlag ){
477 undo_save(zName);
478 db_multi_exec(
479 "UPDATE vfile SET mtime=0, mrid=%d, chnged=2, islink=%d "
480 " WHERE id=%d", ridm, islinkm, idv
481 );
482 vfile_to_disk(0, idv, 0, 0);
483 }
484 }
485 db_finalize(&q);
@@ -644,11 +655,13 @@
644 " WHERE type='ci' AND objid=%d",
645 mid
646 );
647 }else if( backoutFlag ){
648 db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(-2,%d)",pid);
 
 
649 }else{
650 db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(0,%d)", mid);
651 }
652 undo_finish();
653 db_end_transaction(dryRunFlag);
654 }
655
--- src/merge.c
+++ src/merge.c
@@ -91,19 +91,22 @@
91 ** files whose names differ only in case are taken
92 ** to be the same file.
93 **
94 ** -f|--force Force the merge even if it would be a no-op.
95 **
96 ** --integrate Merged branch will be closed when committing.
97 **
98 ** -n|--dry-run If given, display instead of run actions
99 **
100 ** -v|--verbose Show additional details of the merge
101 */
102 void merge_cmd(void){
103 int vid; /* Current version "V" */
104 int mid; /* Version we are merging from "M" */
105 int pid; /* The pivot version - most recent common ancestor P */
106 int verboseFlag; /* True if the -v|--verbose option is present */
107 int integrateFlag; /* True if the --integrate option is present */
108 int pickFlag; /* True if the --cherrypick option is present */
109 int backoutFlag; /* True if the --backout option is present */
110 int dryRunFlag; /* True if the --dry-run or -n option is present */
111 int forceFlag; /* True if the --force or -f option is present */
112 const char *zBinGlob; /* The value of --binary */
@@ -128,10 +131,11 @@
131 verboseFlag = find_option("verbose","v",0)!=0;
132 if( !verboseFlag ){
133 verboseFlag = find_option("detail",0,0)!=0; /* deprecated */
134 }
135 pickFlag = find_option("cherrypick",0,0)!=0;
136 integrateFlag = find_option("integrate",0,0)!=0;
137 backoutFlag = find_option("backout",0,0)!=0;
138 debugFlag = find_option("debug",0,0)!=0;
139 zBinGlob = find_option("binary",0,1);
140 dryRunFlag = find_option("dry-run","n",0)!=0;
141 if( !dryRunFlag ){
@@ -162,12 +166,12 @@
166 ** has not already been merged into the current checkout and (3)
167 ** the leaf is not closed and (4) the leaf is in the same branch
168 ** as the current checkout.
169 */
170 Stmt q;
171 if( pickFlag || backoutFlag || integrateFlag){
172 fossil_fatal("cannot use --backout, --cherrypick or --integrate with a fork merge");
173 }
174 mid = db_int(0,
175 "SELECT leaf.rid"
176 " FROM leaf, event"
177 " WHERE leaf.rid=event.objid"
@@ -220,10 +224,13 @@
224 }
225 if( pickFlag ){
226 fossil_fatal("incompatible options: --cherrypick & --baseline");
227 }
228 }else if( pickFlag || backoutFlag ){
229 if( integrateFlag ){
230 fossil_fatal("incompatible options: --integrate & --cherrypick or --backout");
231 }
232 pid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", mid);
233 if( pid<=0 ){
234 fossil_fatal("cannot find an ancestor for %s", g.argv[2]);
235 }
236 }else{
@@ -251,12 +258,16 @@
258 if( !forceFlag && mid==pid ){
259 fossil_print("Merge skipped because it is a no-op. "
260 " Use --force to override.\n");
261 return;
262 }
263 if( integrateFlag && !is_a_leaf(mid) ){
264 fossil_warning("ignoring --integrate: %s is not a leaf", g.argv[2]);
265 integrateFlag = 0;
266 }
267 if( verboseFlag ){
268 print_checkin_description(mid, 12, integrateFlag?"integrate:":"merge-from:");
269 print_checkin_description(pid, 12, "baseline:");
270 }
271 vfile_check_signature(vid, CKSIG_ENOTFILE);
272 db_begin_transaction();
273 if( !dryRunFlag ) undo_begin();
@@ -434,12 +445,12 @@
445 int idv;
446 const char *zName;
447 char *zFullName;
448 db_multi_exec(
449 "INSERT INTO vfile(vid,chnged,deleted,rid,mrid,isexe,islink,pathname)"
450 " SELECT %d,%d,0,rid,mrid,isexe,islink,pathname FROM vfile WHERE id=%d",
451 vid, integrateFlag?5:3, idm
452 );
453 idv = db_last_insert_rowid();
454 db_multi_exec("UPDATE fv SET idv=%d WHERE rowid=%d", idv, rowid);
455 zName = db_column_text(&q, 2);
456 zFullName = mprintf("%s%s", g.zLocalRoot, zName);
@@ -474,12 +485,12 @@
485 /* Copy content from idm over into idv. Overwrite idv. */
486 fossil_print("UPDATE %s\n", zName);
487 if( !dryRunFlag ){
488 undo_save(zName);
489 db_multi_exec(
490 "UPDATE vfile SET mtime=0, mrid=%d, chnged=%d, islink=%d "
491 " WHERE id=%d", ridm, integrateFlag?4:2, islinkm, idv
492 );
493 vfile_to_disk(0, idv, 0, 0);
494 }
495 }
496 db_finalize(&q);
@@ -644,11 +655,13 @@
655 " WHERE type='ci' AND objid=%d",
656 mid
657 );
658 }else if( backoutFlag ){
659 db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(-2,%d)",pid);
660 }else if( integrateFlag ){
661 db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(-4,%d)",mid);
662 }else{
663 db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(0,%d)", mid);
664 }
665 undo_finish();
666 db_end_transaction(dryRunFlag);
667 }
668
+11 -10
--- src/schema.c
+++ src/schema.c
@@ -475,25 +475,25 @@
475475
@ --
476476
@ -- The file.rid field is 0 for files or folders that have been
477477
@ -- added but not yet committed.
478478
@ --
479479
@ -- Vfile.chnged is 0 for unmodified files, 1 for files that have
480
-@ -- been edited or which have been subjected to a 3-way merge.
480
+@ -- been edited or which have been subjected to a 3-way merge.
481481
@ -- Vfile.chnged is 2 if the file has been replaced from a different
482482
@ -- version by the merge and 3 if the file has been added by a merge.
483
-@ -- The difference between vfile.chnged==2 and a regular add is that
484
-@ -- with vfile.chnged==2 we know that the current version of the file
485
-@ -- is already in the repository.
486
-@ --
483
+@ -- Vfile.chnged is 4|5 is the same as 2|3, but the operation has been
484
+@ -- done by an --integrate merge. The difference between vfile.chnged==2|4
485
+@ -- and a regular add is that with vfile.chnged==2|4 we know that the
486
+@ -- current version of the file is already in the repository.
487487
@ --
488488
@ CREATE TABLE vfile(
489489
@ id INTEGER PRIMARY KEY, -- ID of the checked out file
490490
@ vid INTEGER REFERENCES blob, -- The baseline this file is part of.
491
-@ chnged INT DEFAULT 0, -- 0:unchnged 1:edited 2:m-chng 3:m-add
492
-@ deleted BOOLEAN DEFAULT 0, -- True if deleted
491
+@ chnged INT DEFAULT 0, -- 0:unchnged 1:edited 2:m-chng 3:m-add 4:i-chng 5:i-add
492
+@ deleted BOOLEAN DEFAULT 0, -- True if deleted
493493
@ isexe BOOLEAN, -- True if file should be executable
494
-@ islink BOOLEAN, -- True if file should be symlink
494
+@ islink BOOLEAN, -- True if file should be symlink
495495
@ rid INTEGER, -- Originally from this repository record
496496
@ mrid INTEGER, -- Based on this record due to a merge
497497
@ mtime INTEGER, -- Mtime of file on disk. sec since 1970
498498
@ pathname TEXT, -- Full pathname relative to root
499499
@ origname TEXT, -- Original pathname. NULL if unchanged
@@ -502,12 +502,13 @@
502502
@
503503
@ -- This table holds a record of uncommitted merges in the local
504504
@ -- file tree. If a VFILE entry with id has merged with another
505505
@ -- record, there is an entry in this table with (id,merge) where
506506
@ -- merge is the RECORD table entry that the file merged against.
507
-@ -- An id of 0 here means the version record itself. When id==(-1)
508
-@ -- that is a cherrypick merge and id==(-2) is a backout merge.
507
+@ -- An id of 0 or <-3 here means the version record itself. When
508
+@ -- id==(-1) that is a cherrypick merge, id==(-2) that is a
509
+@ -- backout merge and id==(-4) is a integrate merge.
509510
@
510511
@ CREATE TABLE vmerge(
511512
@ id INTEGER REFERENCES vfile, -- VFILE entry that has been merged
512513
@ merge INTEGER, -- Merged with this record
513514
@ UNIQUE(id, merge)
514515
--- src/schema.c
+++ src/schema.c
@@ -475,25 +475,25 @@
475 @ --
476 @ -- The file.rid field is 0 for files or folders that have been
477 @ -- added but not yet committed.
478 @ --
479 @ -- Vfile.chnged is 0 for unmodified files, 1 for files that have
480 @ -- been edited or which have been subjected to a 3-way merge.
481 @ -- Vfile.chnged is 2 if the file has been replaced from a different
482 @ -- version by the merge and 3 if the file has been added by a merge.
483 @ -- The difference between vfile.chnged==2 and a regular add is that
484 @ -- with vfile.chnged==2 we know that the current version of the file
485 @ -- is already in the repository.
486 @ --
487 @ --
488 @ CREATE TABLE vfile(
489 @ id INTEGER PRIMARY KEY, -- ID of the checked out file
490 @ vid INTEGER REFERENCES blob, -- The baseline this file is part of.
491 @ chnged INT DEFAULT 0, -- 0:unchnged 1:edited 2:m-chng 3:m-add
492 @ deleted BOOLEAN DEFAULT 0, -- True if deleted
493 @ isexe BOOLEAN, -- True if file should be executable
494 @ islink BOOLEAN, -- True if file should be symlink
495 @ rid INTEGER, -- Originally from this repository record
496 @ mrid INTEGER, -- Based on this record due to a merge
497 @ mtime INTEGER, -- Mtime of file on disk. sec since 1970
498 @ pathname TEXT, -- Full pathname relative to root
499 @ origname TEXT, -- Original pathname. NULL if unchanged
@@ -502,12 +502,13 @@
502 @
503 @ -- This table holds a record of uncommitted merges in the local
504 @ -- file tree. If a VFILE entry with id has merged with another
505 @ -- record, there is an entry in this table with (id,merge) where
506 @ -- merge is the RECORD table entry that the file merged against.
507 @ -- An id of 0 here means the version record itself. When id==(-1)
508 @ -- that is a cherrypick merge and id==(-2) is a backout merge.
 
509 @
510 @ CREATE TABLE vmerge(
511 @ id INTEGER REFERENCES vfile, -- VFILE entry that has been merged
512 @ merge INTEGER, -- Merged with this record
513 @ UNIQUE(id, merge)
514
--- src/schema.c
+++ src/schema.c
@@ -475,25 +475,25 @@
475 @ --
476 @ -- The file.rid field is 0 for files or folders that have been
477 @ -- added but not yet committed.
478 @ --
479 @ -- Vfile.chnged is 0 for unmodified files, 1 for files that have
480 @ -- been edited or which have been subjected to a 3-way merge.
481 @ -- Vfile.chnged is 2 if the file has been replaced from a different
482 @ -- version by the merge and 3 if the file has been added by a merge.
483 @ -- Vfile.chnged is 4|5 is the same as 2|3, but the operation has been
484 @ -- done by an --integrate merge. The difference between vfile.chnged==2|4
485 @ -- and a regular add is that with vfile.chnged==2|4 we know that the
486 @ -- current version of the file is already in the repository.
487 @ --
488 @ CREATE TABLE vfile(
489 @ id INTEGER PRIMARY KEY, -- ID of the checked out file
490 @ vid INTEGER REFERENCES blob, -- The baseline this file is part of.
491 @ chnged INT DEFAULT 0, -- 0:unchnged 1:edited 2:m-chng 3:m-add 4:i-chng 5:i-add
492 @ deleted BOOLEAN DEFAULT 0, -- True if deleted
493 @ isexe BOOLEAN, -- True if file should be executable
494 @ islink BOOLEAN, -- True if file should be symlink
495 @ rid INTEGER, -- Originally from this repository record
496 @ mrid INTEGER, -- Based on this record due to a merge
497 @ mtime INTEGER, -- Mtime of file on disk. sec since 1970
498 @ pathname TEXT, -- Full pathname relative to root
499 @ origname TEXT, -- Original pathname. NULL if unchanged
@@ -502,12 +502,13 @@
502 @
503 @ -- This table holds a record of uncommitted merges in the local
504 @ -- file tree. If a VFILE entry with id has merged with another
505 @ -- record, there is an entry in this table with (id,merge) where
506 @ -- merge is the RECORD table entry that the file merged against.
507 @ -- An id of 0 or <-3 here means the version record itself. When
508 @ -- id==(-1) that is a cherrypick merge, id==(-2) that is a
509 @ -- backout merge and id==(-4) is a integrate merge.
510 @
511 @ CREATE TABLE vmerge(
512 @ id INTEGER REFERENCES vfile, -- VFILE entry that has been merged
513 @ merge INTEGER, -- Merged with this record
514 @ UNIQUE(id, merge)
515
+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
+2 -2
--- src/shun.c
+++ src/shun.c
@@ -66,11 +66,10 @@
6666
zUuid = zCanonical;
6767
}
6868
}
6969
style_header("Shunned Artifacts");
7070
if( zUuid && P("sub") ){
71
- login_verify_csrf_secret();
7271
db_multi_exec("DELETE FROM shun WHERE uuid='%s'", zUuid);
7372
if( db_exists("SELECT 1 FROM blob WHERE uuid='%s'", zUuid) ){
7473
@ <p class="noMoreShun">Artifact
7574
@ <a href="%s(g.zTop)/artifact/%s(zUuid)">%s(zUuid)</a> is no
7675
@ longer being shunned.</p>
@@ -133,20 +132,21 @@
133132
@ <input type="text" name="uuid" value="%h(PD("shun",""))" size="50" />
134133
@ <input type="submit" name="add" value="Shun" />
135134
@ </div></form>
136135
@ </blockquote>
137136
@
137
+ @ <a name="delshun"></a>
138138
@ <p>Enter the UUID of a previous shunned artifact to cause it to be
139139
@ accepted again in the repository. The artifact content is not
140140
@ restored because the content is unknown. The only change is that
141141
@ the formerly shunned artifact will be accepted on subsequent sync
142142
@ operations.</p>
143143
@
144144
@ <blockquote>
145145
@ <form method="post" action="%s(g.zTop)/%s(g.zPath)"><div>
146146
login_insert_csrf_secret();
147
- @ <input type="text" name="uuid" size="50" />
147
+ @ <input type="text" name="uuid" value="%h(PD("accept", ""))" size="50" />
148148
@ <input type="submit" name="sub" value="Accept" />
149149
@ </div></form>
150150
@ </blockquote>
151151
@
152152
@ <p>Press the Rebuild button below to rebuild the repository. The
153153
--- src/shun.c
+++ src/shun.c
@@ -66,11 +66,10 @@
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>
@@ -133,20 +132,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 @ <p>Enter the UUID of a previous shunned artifact to cause it to be
139 @ accepted again in the repository. The artifact content is not
140 @ restored because the content is unknown. The only change is that
141 @ the formerly shunned artifact will be accepted on subsequent sync
142 @ operations.</p>
143 @
144 @ <blockquote>
145 @ <form method="post" action="%s(g.zTop)/%s(g.zPath)"><div>
146 login_insert_csrf_secret();
147 @ <input type="text" name="uuid" size="50" />
148 @ <input type="submit" name="sub" value="Accept" />
149 @ </div></form>
150 @ </blockquote>
151 @
152 @ <p>Press the Rebuild button below to rebuild the repository. The
153
--- src/shun.c
+++ src/shun.c
@@ -66,11 +66,10 @@
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>
@@ -133,20 +132,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 @ <a name="delshun"></a>
138 @ <p>Enter the UUID of a previous shunned artifact to cause it to be
139 @ accepted again in the repository. The artifact content is not
140 @ restored because the content is unknown. The only change is that
141 @ the formerly shunned artifact will be accepted on subsequent sync
142 @ operations.</p>
143 @
144 @ <blockquote>
145 @ <form method="post" action="%s(g.zTop)/%s(g.zPath)"><div>
146 login_insert_csrf_secret();
147 @ <input type="text" name="uuid" value="%h(PD("accept", ""))" size="50" />
148 @ <input type="submit" name="sub" value="Accept" />
149 @ </div></form>
150 @ </blockquote>
151 @
152 @ <p>Press the Rebuild button below to rebuild the repository. The
153
+822 -622
--- 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-05 12:31:41 4b8b426f10f8ae13bf553f7adf5ae09383fa0bd4"
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 */
@@ -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
@@ -10762,10 +10746,11 @@
1076210746
char *zColAff; /* String defining the affinity of each column */
1076310747
Index *pNext; /* The next index associated with the same table */
1076410748
Schema *pSchema; /* Schema containing this index */
1076510749
u8 *aSortOrder; /* for each column: True==DESC, False==ASC */
1076610750
char **azColl; /* Array of collation sequence names for index */
10751
+ Expr *pPartIdxWhere; /* WHERE clause for partial indices */
1076710752
int tnum; /* DB Page containing root of this index */
1076810753
u16 nColumn; /* Number of columns in table used by this index */
1076910754
u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
1077010755
unsigned autoIndex:2; /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */
1077110756
unsigned bUnordered:1; /* Use this index for == or IN queries only */
@@ -11242,10 +11227,11 @@
1124211227
#define NC_HasAgg 0x02 /* One or more aggregate functions seen */
1124311228
#define NC_IsCheck 0x04 /* True if resolving names in a CHECK constraint */
1124411229
#define NC_InAggFunc 0x08 /* True if analyzing arguments to an agg func */
1124511230
#define NC_AsMaybe 0x10 /* Resolve to AS terms of the result set only
1124611231
** if no other resolution is available */
11232
+#define NC_PartIdx 0x20 /* True if resolving a partial index WHERE */
1124711233
1124811234
/*
1124911235
** An instance of the following structure contains all information
1125011236
** needed to generate code for a single SELECT statement.
1125111237
**
@@ -11426,10 +11412,11 @@
1142611412
int nTab; /* Number of previously allocated VDBE cursors */
1142711413
int nMem; /* Number of memory cells used so far */
1142811414
int nSet; /* Number of sets used so far */
1142911415
int nOnce; /* Number of OP_Once instructions so far */
1143011416
int ckBase; /* Base register of data during check constraints */
11417
+ int iPartIdxTab; /* Table corresponding to a partial index */
1143111418
int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
1143211419
int iCacheCnt; /* Counter used to generate aColCache[].lru values */
1143311420
struct yColCache {
1143411421
int iTable; /* Table cursor number */
1143511422
int iColumn; /* Table column number */
@@ -12007,11 +11994,11 @@
1200711994
SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*);
1200811995
SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*);
1200911996
SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*);
1201011997
SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*);
1201111998
SQLITE_PRIVATE Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
12012
- Token*, int, int);
11999
+ Expr*, int, int);
1201312000
SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int);
1201412001
SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
1201512002
SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
1201612003
Expr*,ExprList*,u16,Expr*,Expr*);
1201712004
SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
@@ -12055,12 +12042,13 @@
1205512042
SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
1205612043
SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
1205712044
SQLITE_PRIVATE void sqlite3Vacuum(Parse*);
1205812045
SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*);
1205912046
SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);
12060
-SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*);
12061
-SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*);
12047
+SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*, int);
12048
+SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int);
12049
+SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr*, Expr*, int);
1206212050
SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
1206312051
SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
1206412052
SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
1206512053
SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);
1206612054
SQLITE_PRIVATE void sqlite3PrngSaveState(void);
@@ -12083,11 +12071,11 @@
1208312071
SQLITE_PRIVATE void sqlite3ExprCodeIsNullJump(Vdbe*, const Expr*, int, int);
1208412072
SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);
1208512073
SQLITE_PRIVATE int sqlite3IsRowid(const char*);
1208612074
SQLITE_PRIVATE void sqlite3GenerateRowDelete(Parse*, Table*, int, int, int, Trigger *, int);
1208712075
SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int*);
12088
-SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int);
12076
+SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*);
1208912077
SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int,
1209012078
int*,int,int,int,int,int*);
1209112079
SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int);
1209212080
SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, int);
1209312081
SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);
@@ -12286,10 +12274,11 @@
1228612274
SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *, Expr *, int, int);
1228712275
SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
1228812276
SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);
1228912277
SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*);
1229012278
SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
12279
+SQLITE_PRIVATE void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);
1229112280
SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
1229212281
SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
1229312282
SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);
1229412283
SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
1229512284
SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);
@@ -13257,10 +13246,13 @@
1325713246
typedef struct VdbeSorter VdbeSorter;
1325813247
1325913248
/* Opaque type used by the explainer */
1326013249
typedef struct Explain Explain;
1326113250
13251
+/* Elements of the linked list at Vdbe.pAuxData */
13252
+typedef struct AuxData AuxData;
13253
+
1326213254
/*
1326313255
** A cursor is a pointer into a single BTree within a database file.
1326413256
** The cursor can seek to a BTree entry with a particular key, or
1326513257
** loop over all entries of the Btree. You can also insert new BTree
1326613258
** entries or retrieve the key or data from the entry that the cursor
@@ -13443,27 +13435,23 @@
1344313435
*/
1344413436
#ifdef SQLITE_DEBUG
1344513437
#define memIsValid(M) ((M)->flags & MEM_Invalid)==0
1344613438
#endif
1344713439
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.
13440
+/*
13441
+** Each auxilliary data pointer stored by a user defined function
13442
+** implementation calling sqlite3_set_auxdata() is stored in an instance
13443
+** of this structure. All such structures associated with a single VM
13444
+** are stored in a linked list headed at Vdbe.pAuxData. All are destroyed
13445
+** when the VM is halted (if not before).
1345713446
*/
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 */
13447
+struct AuxData {
13448
+ int iOp; /* Instruction number of OP_Function opcode */
13449
+ int iArg; /* Index of function argument. */
13450
+ void *pAux; /* Aux data pointer */
13451
+ void (*xDelete)(void *); /* Destructor for the aux data */
13452
+ AuxData *pNext; /* Next element in list */
1346513453
};
1346613454
1346713455
/*
1346813456
** The "context" argument for a installable function. A pointer to an
1346913457
** instance of this structure is the first argument to the routines used
@@ -13477,16 +13465,17 @@
1347713465
** This structure is defined inside of vdbeInt.h because it uses substructures
1347813466
** (Mem) which are only defined there.
1347913467
*/
1348013468
struct sqlite3_context {
1348113469
FuncDef *pFunc; /* Pointer to function information. MUST BE FIRST */
13482
- VdbeFunc *pVdbeFunc; /* Auxilary data, if created. */
1348313470
Mem s; /* The return value is stored here */
1348413471
Mem *pMem; /* Memory cell used to store aggregate context */
1348513472
CollSeq *pColl; /* Collating sequence */
1348613473
int isError; /* Error code returned by the function. */
1348713474
int skipFlag; /* Skip skip accumulator loading if true */
13475
+ int iOp; /* Instruction number of OP_Function */
13476
+ Vdbe *pVdbe; /* The VM that owns this context */
1348813477
};
1348913478
1349013479
/*
1349113480
** An Explain object accumulates indented output which is helpful
1349213481
** in describing recursive data structures.
@@ -13581,10 +13570,11 @@
1358113570
int nFrame; /* Number of frames in pFrame list */
1358213571
u32 expmask; /* Binding to these vars invalidates VM */
1358313572
SubProgram *pProgram; /* Linked list of all sub-programs used by VM */
1358413573
int nOnceFlag; /* Size of array aOnceFlag[] */
1358513574
u8 *aOnceFlag; /* Flags for OP_Once */
13575
+ AuxData *pAuxData; /* Linked list of auxdata allocations */
1358613576
};
1358713577
1358813578
/*
1358913579
** The following are allowed values for Vdbe.magic
1359013580
*/
@@ -13604,11 +13594,11 @@
1360413594
#endif
1360513595
SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
1360613596
SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int);
1360713597
SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int);
1360813598
SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
13609
-SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc*, int);
13599
+SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe*, int, int);
1361013600
1361113601
int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
1361213602
SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int*);
1361313603
SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3*, BtCursor *, i64 *);
1361413604
SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
@@ -30499,10 +30489,11 @@
3049930489
*/
3050030490
#if SQLITE_OS_WIN /* This file is used for Windows only */
3050130491
3050230492
#ifdef __CYGWIN__
3050330493
# include <sys/cygwin.h>
30494
+/* # include <errno.h> */
3050430495
#endif
3050530496
3050630497
/*
3050730498
** Include code that is common to all os_*.c files
3050830499
*/
@@ -30919,10 +30910,11 @@
3091930910
* zero for the default behavior.
3092030911
*/
3092130912
#ifndef SQLITE_WIN32_HEAP_FLAGS
3092230913
# define SQLITE_WIN32_HEAP_FLAGS (0)
3092330914
#endif
30915
+
3092430916
3092530917
/*
3092630918
** The winMemData structure stores information required by the Win32-specific
3092730919
** sqlite3_mem_methods implementation.
3092830920
*/
@@ -34384,14 +34376,14 @@
3438434376
OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
3438534377
osGetCurrentProcessId(), pFd));
3438634378
return SQLITE_OK;
3438734379
}
3438834380
assert( (nMap % winSysInfo.dwPageSize)==0 );
34389
-#if SQLITE_OS_WINRT
34390
- pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, nMap);
34391
-#else
3439234381
assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
34382
+#if SQLITE_OS_WINRT
34383
+ pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, (SIZE_T)nMap);
34384
+#else
3439334385
pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
3439434386
#endif
3439534387
if( pNew==NULL ){
3439634388
osCloseHandle(pFd->hMap);
3439734389
pFd->hMap = NULL;
@@ -34556,10 +34548,19 @@
3455634548
#endif
3455734549
/* caller will handle out of memory */
3455834550
return zConverted;
3455934551
}
3456034552
34553
+/*
34554
+** Maximum pathname length (in bytes) for windows. The MAX_PATH macro is
34555
+** in characters, so we allocate 3 bytes per character assuming worst-case
34556
+** 3-bytes-per-character UTF8.
34557
+*/
34558
+#ifndef SQLITE_WIN32_MAX_PATH
34559
+# define SQLITE_WIN32_MAX_PATH (MAX_PATH*3)
34560
+#endif
34561
+
3456134562
/*
3456234563
** Create a temporary file name in zBuf. zBuf must be big enough to
3456334564
** hold at pVfs->mxPathname characters.
3456434565
*/
3456534566
static int getTempname(int nBuf, char *zBuf){
@@ -34567,53 +34568,74 @@
3456734568
"abcdefghijklmnopqrstuvwxyz"
3456834569
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
3456934570
"0123456789";
3457034571
size_t i, j;
3457134572
int nTempPath;
34572
- char zTempPath[MAX_PATH+2];
34573
+ char zTempPath[SQLITE_WIN32_MAX_PATH+2];
3457334574
3457434575
/* It's odd to simulate an io-error here, but really this is just
3457534576
** using the io-error infrastructure to test that SQLite handles this
3457634577
** function failing.
3457734578
*/
3457834579
SimulateIOError( return SQLITE_IOERR );
3457934580
34580
- memset(zTempPath, 0, MAX_PATH+2);
34581
-
3458234581
if( sqlite3_temp_directory ){
34583
- sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
34582
+ sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s",
34583
+ sqlite3_temp_directory);
3458434584
}
3458534585
#if !SQLITE_OS_WINRT
3458634586
else if( isNT() ){
3458734587
char *zMulti;
3458834588
WCHAR zWidePath[MAX_PATH];
34589
- osGetTempPathW(MAX_PATH-30, zWidePath);
34589
+ if( osGetTempPathW(MAX_PATH-30, zWidePath)==0 ){
34590
+ OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34591
+ return SQLITE_IOERR_GETTEMPPATH;
34592
+ }
3459034593
zMulti = unicodeToUtf8(zWidePath);
3459134594
if( zMulti ){
34592
- sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti);
34595
+ sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zMulti);
3459334596
sqlite3_free(zMulti);
3459434597
}else{
3459534598
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
3459634599
return SQLITE_IOERR_NOMEM;
3459734600
}
3459834601
}
3459934602
#ifdef SQLITE_WIN32_HAS_ANSI
3460034603
else{
3460134604
char *zUtf8;
34602
- char zMbcsPath[MAX_PATH];
34603
- osGetTempPathA(MAX_PATH-30, zMbcsPath);
34605
+ char zMbcsPath[SQLITE_WIN32_MAX_PATH];
34606
+ if( osGetTempPathA(SQLITE_WIN32_MAX_PATH-30, zMbcsPath)==0 ){
34607
+ OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34608
+ return SQLITE_IOERR_GETTEMPPATH;
34609
+ }
3460434610
zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
3460534611
if( zUtf8 ){
34606
- sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8);
34612
+ sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zUtf8);
3460734613
sqlite3_free(zUtf8);
3460834614
}else{
3460934615
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
3461034616
return SQLITE_IOERR_NOMEM;
3461134617
}
3461234618
}
34613
-#endif
34614
-#endif
34619
+#else
34620
+ else{
34621
+ /*
34622
+ ** Compiled without ANSI support and the current operating system
34623
+ ** is not Windows NT; therefore, just zero the temporary buffer.
34624
+ */
34625
+ memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34626
+ }
34627
+#endif /* SQLITE_WIN32_HAS_ANSI */
34628
+#else
34629
+ else{
34630
+ /*
34631
+ ** Compiled for WinRT and the sqlite3_temp_directory is not set;
34632
+ ** therefore, just zero the temporary buffer.
34633
+ */
34634
+ memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34635
+ }
34636
+#endif /* !SQLITE_OS_WINRT */
3461534637
3461634638
/* Check that the output buffer is large enough for the temporary file
3461734639
** name. If it is not, return SQLITE_ERROR.
3461834640
*/
3461934641
nTempPath = sqlite3Strlen30(zTempPath);
@@ -34695,11 +34717,11 @@
3469534717
int cnt = 0;
3469634718
3469734719
/* If argument zPath is a NULL pointer, this function is required to open
3469834720
** a temporary file. Use this buffer to store the file name in.
3469934721
*/
34700
- char zTmpname[MAX_PATH+2]; /* Buffer used to create temp filename */
34722
+ char zTmpname[SQLITE_WIN32_MAX_PATH+2]; /* Buffer used to create temp filename */
3470134723
3470234724
int rc = SQLITE_OK; /* Function Return Code */
3470334725
#if !defined(NDEBUG) || SQLITE_OS_WINCE
3470434726
int eType = flags&0xFFFFFF00; /* Type of file to open */
3470534727
#endif
@@ -34761,12 +34783,11 @@
3476134783
/* If the second argument to this function is NULL, generate a
3476234784
** temporary file name to use
3476334785
*/
3476434786
if( !zUtf8Name ){
3476534787
assert(isDelete && !isOpenJournal);
34766
- memset(zTmpname, 0, MAX_PATH+2);
34767
- rc = getTempname(MAX_PATH+2, zTmpname);
34788
+ rc = getTempname(SQLITE_WIN32_MAX_PATH+2, zTmpname);
3476834789
if( rc!=SQLITE_OK ){
3476934790
OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
3477034791
return rc;
3477134792
}
3477234793
zUtf8Name = zTmpname;
@@ -35193,27 +35214,34 @@
3519335214
){
3519435215
3519535216
#if defined(__CYGWIN__)
3519635217
SimulateIOError( return SQLITE_ERROR );
3519735218
UNUSED_PARAMETER(nFull);
35198
- assert( pVfs->mxPathname>=MAX_PATH );
35219
+ assert( pVfs->mxPathname>=SQLITE_WIN32_MAX_PATH );
3519935220
assert( nFull>=pVfs->mxPathname );
3520035221
if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
3520135222
/*
3520235223
** NOTE: We are dealing with a relative path name and the data
3520335224
** directory has been set. Therefore, use it as the basis
3520435225
** for converting the relative path name to an absolute
3520535226
** one by prepending the data directory and a slash.
3520635227
*/
35207
- char zOut[MAX_PATH+1];
35208
- memset(zOut, 0, MAX_PATH+1);
35209
- cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35210
- MAX_PATH+1);
35228
+ char zOut[SQLITE_WIN32_MAX_PATH+1];
35229
+ if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35230
+ SQLITE_WIN32_MAX_PATH+1)<0 ){
35231
+ winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35232
+ zRelative);
35233
+ return SQLITE_CANTOPEN_FULLPATH;
35234
+ }
3521135235
sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s",
3521235236
sqlite3_data_directory, zOut);
3521335237
}else{
35214
- cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull);
35238
+ if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){
35239
+ winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35240
+ zRelative);
35241
+ return SQLITE_CANTOPEN_FULLPATH;
35242
+ }
3521535243
}
3521635244
return SQLITE_OK;
3521735245
#endif
3521835246
3521935247
#if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
@@ -35551,11 +35579,11 @@
3555135579
*/
3555235580
SQLITE_API int sqlite3_os_init(void){
3555335581
static sqlite3_vfs winVfs = {
3555435582
3, /* iVersion */
3555535583
sizeof(winFile), /* szOsFile */
35556
- MAX_PATH, /* mxPathname */
35584
+ SQLITE_WIN32_MAX_PATH, /* mxPathname */
3555735585
0, /* pNext */
3555835586
"win32", /* zName */
3555935587
0, /* pAppData */
3556035588
winOpen, /* xOpen */
3556135589
winDelete, /* xDelete */
@@ -60176,12 +60204,12 @@
6017660204
** a prior call to sqlite3VdbeMakeLabel().
6017760205
*/
6017860206
SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *p, int x){
6017960207
int j = -1-x;
6018060208
assert( p->magic==VDBE_MAGIC_INIT );
60181
- assert( j>=0 && j<p->nLabel );
60182
- if( p->aLabel ){
60209
+ assert( j<p->nLabel );
60210
+ if( j>=0 && p->aLabel ){
6018360211
p->aLabel[j] = p->nOp;
6018460212
}
6018560213
}
6018660214
6018760215
/*
@@ -60501,12 +60529,11 @@
6050160529
/*
6050260530
** Change the P2 operand of instruction addr so that it points to
6050360531
** the address of the next instruction to be coded.
6050460532
*/
6050560533
SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe *p, int addr){
60506
- assert( addr>=0 || p->db->mallocFailed );
60507
- if( addr>=0 ) sqlite3VdbeChangeP2(p, addr, p->nOp);
60534
+ if( ALWAYS(addr>=0) ) sqlite3VdbeChangeP2(p, addr, p->nOp);
6050860535
}
6050960536
6051060537
6051160538
/*
6051260539
** If the input FuncDef structure is ephemeral, then free it. If
@@ -60538,17 +60565,10 @@
6053860565
}
6053960566
case P4_MPRINTF: {
6054060567
if( db->pnBytesFreed==0 ) sqlite3_free(p4);
6054160568
break;
6054260569
}
60543
- case P4_VDBEFUNC: {
60544
- VdbeFunc *pVdbeFunc = (VdbeFunc *)p4;
60545
- freeEphemeralFunction(db, pVdbeFunc->pFunc);
60546
- if( db->pnBytesFreed==0 ) sqlite3VdbeDeleteAuxData(pVdbeFunc, 0);
60547
- sqlite3DbFree(db, pVdbeFunc);
60548
- break;
60549
- }
6055060570
case P4_FUNCDEF: {
6055160571
freeEphemeralFunction(db, (FuncDef*)p4);
6055260572
break;
6055360573
}
6055460574
case P4_MEM: {
@@ -61574,10 +61594,14 @@
6157461594
while( p->pDelFrame ){
6157561595
VdbeFrame *pDel = p->pDelFrame;
6157661596
p->pDelFrame = pDel->pParent;
6157761597
sqlite3VdbeFrameDelete(pDel);
6157861598
}
61599
+
61600
+ /* Delete any auxdata allocations made by the VM */
61601
+ sqlite3VdbeDeleteAuxData(p, -1, 0);
61602
+ assert( p->pAuxData==0 );
6157961603
}
6158061604
6158161605
/*
6158261606
** Clean up the VM after execution.
6158361607
**
@@ -62372,24 +62396,39 @@
6237262396
sqlite3VdbeDelete(p);
6237362397
return rc;
6237462398
}
6237562399
6237662400
/*
62377
-** Call the destructor for each auxdata entry in pVdbeFunc for which
62378
-** the corresponding bit in mask is clear. Auxdata entries beyond 31
62379
-** are always destroyed. To destroy all auxdata entries, call this
62380
-** routine with mask==0.
62401
+** If parameter iOp is less than zero, then invoke the destructor for
62402
+** all auxiliary data pointers currently cached by the VM passed as
62403
+** the first argument.
62404
+**
62405
+** Or, if iOp is greater than or equal to zero, then the destructor is
62406
+** only invoked for those auxiliary data pointers created by the user
62407
+** function invoked by the OP_Function opcode at instruction iOp of
62408
+** VM pVdbe, and only then if:
62409
+**
62410
+** * the associated function parameter is the 32nd or later (counting
62411
+** from left to right), or
62412
+**
62413
+** * the corresponding bit in argument mask is clear (where the first
62414
+** function parameter corrsponds to bit 0 etc.).
6238162415
*/
62382
-SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc *pVdbeFunc, int mask){
62383
- int i;
62384
- for(i=0; i<pVdbeFunc->nAux; i++){
62385
- struct AuxData *pAux = &pVdbeFunc->apAux[i];
62386
- if( (i>31 || !(mask&(((u32)1)<<i))) && pAux->pAux ){
62416
+SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){
62417
+ AuxData **pp = &pVdbe->pAuxData;
62418
+ while( *pp ){
62419
+ AuxData *pAux = *pp;
62420
+ if( (iOp<0)
62421
+ || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & ((u32)1<<pAux->iArg))))
62422
+ ){
6238762423
if( pAux->xDelete ){
6238862424
pAux->xDelete(pAux->pAux);
6238962425
}
62390
- pAux->pAux = 0;
62426
+ *pp = pAux->pNext;
62427
+ sqlite3DbFree(pVdbe->db, pAux);
62428
+ }else{
62429
+ pp= &pAux->pNext;
6239162430
}
6239262431
}
6239362432
}
6239462433
6239562434
/*
@@ -62904,11 +62943,11 @@
6290462943
*/
6290562944
SQLITE_PRIVATE int sqlite3VdbeRecordCompare(
6290662945
int nKey1, const void *pKey1, /* Left key */
6290762946
UnpackedRecord *pPKey2 /* Right key */
6290862947
){
62909
- int d1; /* Offset into aKey[] of next data element */
62948
+ u32 d1; /* Offset into aKey[] of next data element */
6291062949
u32 idx1; /* Offset into aKey[] of next header element */
6291162950
u32 szHdr1; /* Number of bytes in header */
6291262951
int i = 0;
6291362952
int nField;
6291462953
int rc = 0;
@@ -62938,11 +62977,11 @@
6293862977
while( idx1<szHdr1 && i<pPKey2->nField ){
6293962978
u32 serial_type1;
6294062979
6294162980
/* Read the serial types for the next element in each key. */
6294262981
idx1 += getVarint32( aKey1+idx1, serial_type1 );
62943
- if( d1>=nKey1 && sqlite3VdbeSerialTypeLen(serial_type1)>0 ) break;
62982
+ if( d1+sqlite3VdbeSerialTypeLen(serial_type1)>(u32)nKey1 ) break;
6294462983
6294562984
/* Extract the values to be compared.
6294662985
*/
6294762986
d1 += sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1);
6294862987
@@ -63167,11 +63206,11 @@
6316763206
** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*
6316863207
** constants) to the value before returning it.
6316963208
**
6317063209
** The returned value must be freed by the caller using sqlite3ValueFree().
6317163210
*/
63172
-SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetValue(Vdbe *v, int iVar, u8 aff){
63211
+SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){
6317363212
assert( iVar>0 );
6317463213
if( v ){
6317563214
Mem *pMem = &v->aVar[iVar-1];
6317663215
if( 0==(pMem->flags & MEM_Null) ){
6317763216
sqlite3_value *pRet = sqlite3ValueNew(v->db);
@@ -63784,18 +63823,18 @@
6378463823
/*
6378563824
** Return the auxilary data pointer, if any, for the iArg'th argument to
6378663825
** the user-function defined by pCtx.
6378763826
*/
6378863827
SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
63789
- VdbeFunc *pVdbeFunc;
63828
+ AuxData *pAuxData;
6379063829
6379163830
assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63792
- pVdbeFunc = pCtx->pVdbeFunc;
63793
- if( !pVdbeFunc || iArg>=pVdbeFunc->nAux || iArg<0 ){
63794
- return 0;
63831
+ for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
63832
+ if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
6379563833
}
63796
- return pVdbeFunc->apAux[iArg].pAux;
63834
+
63835
+ return (pAuxData ? pAuxData->pAux : 0);
6379763836
}
6379863837
6379963838
/*
6380063839
** Set the auxilary data pointer and delete function, for the iArg'th
6380163840
** argument to the user-function defined by pCtx. Any previous value is
@@ -63805,33 +63844,30 @@
6380563844
sqlite3_context *pCtx,
6380663845
int iArg,
6380763846
void *pAux,
6380863847
void (*xDelete)(void*)
6380963848
){
63810
- struct AuxData *pAuxData;
63811
- VdbeFunc *pVdbeFunc;
63812
- if( iArg<0 ) goto failed;
63849
+ AuxData *pAuxData;
63850
+ Vdbe *pVdbe = pCtx->pVdbe;
6381363851
6381463852
assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63815
- pVdbeFunc = pCtx->pVdbeFunc;
63816
- if( !pVdbeFunc || pVdbeFunc->nAux<=iArg ){
63817
- int nAux = (pVdbeFunc ? pVdbeFunc->nAux : 0);
63818
- int nMalloc = sizeof(VdbeFunc) + sizeof(struct AuxData)*iArg;
63819
- pVdbeFunc = sqlite3DbRealloc(pCtx->s.db, pVdbeFunc, nMalloc);
63820
- if( !pVdbeFunc ){
63821
- goto failed;
63822
- }
63823
- pCtx->pVdbeFunc = pVdbeFunc;
63824
- memset(&pVdbeFunc->apAux[nAux], 0, sizeof(struct AuxData)*(iArg+1-nAux));
63825
- pVdbeFunc->nAux = iArg+1;
63826
- pVdbeFunc->pFunc = pCtx->pFunc;
63827
- }
63828
-
63829
- pAuxData = &pVdbeFunc->apAux[iArg];
63830
- if( pAuxData->pAux && pAuxData->xDelete ){
63853
+ if( iArg<0 ) goto failed;
63854
+
63855
+ for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
63856
+ if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
63857
+ }
63858
+ if( pAuxData==0 ){
63859
+ pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData));
63860
+ if( !pAuxData ) goto failed;
63861
+ pAuxData->iOp = pCtx->iOp;
63862
+ pAuxData->iArg = iArg;
63863
+ pAuxData->pNext = pVdbe->pAuxData;
63864
+ pVdbe->pAuxData = pAuxData;
63865
+ }else if( pAuxData->xDelete ){
6383163866
pAuxData->xDelete(pAuxData->pAux);
6383263867
}
63868
+
6383363869
pAuxData->pAux = pAux;
6383463870
pAuxData->xDelete = xDelete;
6383563871
return;
6383663872
6383763873
failed:
@@ -65439,11 +65475,11 @@
6543965475
u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
6544065476
u8 encoding = ENC(db); /* The database encoding */
6544165477
int iCompare = 0; /* Result of last OP_Compare operation */
6544265478
unsigned nVmStep = 0; /* Number of virtual machine steps */
6544365479
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65444
- unsigned nProgressOps = 0; /* nVmStep at last progress callback. */
65480
+ unsigned nProgressLimit; /* Invoke xProgress() when nVmStep reaches this */
6544565481
#endif
6544665482
Mem *aMem = p->aMem; /* Copy of p->aMem */
6544765483
Mem *pIn1 = 0; /* 1st input operand */
6544865484
Mem *pIn2 = 0; /* 2nd input operand */
6544965485
Mem *pIn3 = 0; /* 3rd input operand */
@@ -65898,10 +65934,21 @@
6589865934
assert( p->explain==0 );
6589965935
p->pResultSet = 0;
6590065936
db->busyHandler.nBusy = 0;
6590165937
CHECK_FOR_INTERRUPT;
6590265938
sqlite3VdbeIOTraceSql(p);
65939
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65940
+ if( db->xProgress ){
65941
+ assert( 0 < db->nProgressOps );
65942
+ nProgressLimit = (unsigned)p->aCounter[SQLITE_STMTSTATUS_VM_STEP-1];
65943
+ if( nProgressLimit==0 ){
65944
+ nProgressLimit = db->nProgressOps;
65945
+ }else{
65946
+ nProgressLimit %= (unsigned)db->nProgressOps;
65947
+ }
65948
+ }
65949
+#endif
6590365950
#ifdef SQLITE_DEBUG
6590465951
sqlite3BeginBenignMalloc();
6590565952
if( p->pc==0 && (p->db->flags & SQLITE_VdbeListing)!=0 ){
6590665953
int i;
6590765954
printf("VDBE Program Listing:\n");
@@ -66058,18 +66105,20 @@
6605866105
** of VDBE ops have been executed (either since this invocation of
6605966106
** sqlite3VdbeExec() or since last time the progress callback was called).
6606066107
** If the progress callback returns non-zero, exit the virtual machine with
6606166108
** a return code SQLITE_ABORT.
6606266109
*/
66063
- if( db->xProgress!=0 && (nVmStep - nProgressOps)>=db->nProgressOps ){
66110
+ if( db->xProgress!=0 && nVmStep>=nProgressLimit ){
6606466111
int prc;
6606566112
prc = db->xProgress(db->pProgressArg);
6606666113
if( prc!=0 ){
6606766114
rc = SQLITE_INTERRUPT;
6606866115
goto vdbe_error_halt;
6606966116
}
66070
- nProgressOps = nVmStep;
66117
+ if( db->xProgress!=0 ){
66118
+ nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps);
66119
+ }
6607166120
}
6607266121
#endif
6607366122
6607466123
break;
6607566124
}
@@ -66751,23 +66800,18 @@
6675166800
Deephemeralize(u.ai.pArg);
6675266801
sqlite3VdbeMemStoreType(u.ai.pArg);
6675366802
REGISTER_TRACE(pOp->p2+u.ai.i, u.ai.pArg);
6675466803
}
6675566804
66756
- assert( pOp->p4type==P4_FUNCDEF || pOp->p4type==P4_VDBEFUNC );
66757
- if( pOp->p4type==P4_FUNCDEF ){
66758
- u.ai.ctx.pFunc = pOp->p4.pFunc;
66759
- u.ai.ctx.pVdbeFunc = 0;
66760
- }else{
66761
- u.ai.ctx.pVdbeFunc = (VdbeFunc*)pOp->p4.pVdbeFunc;
66762
- u.ai.ctx.pFunc = u.ai.ctx.pVdbeFunc->pFunc;
66763
- }
66764
-
66805
+ assert( pOp->p4type==P4_FUNCDEF );
66806
+ u.ai.ctx.pFunc = pOp->p4.pFunc;
6676566807
u.ai.ctx.s.flags = MEM_Null;
6676666808
u.ai.ctx.s.db = db;
6676766809
u.ai.ctx.s.xDel = 0;
6676866810
u.ai.ctx.s.zMalloc = 0;
66811
+ u.ai.ctx.iOp = pc;
66812
+ u.ai.ctx.pVdbe = p;
6676966813
6677066814
/* The output cell may already have a buffer allocated. Move
6677166815
** the pointer to u.ai.ctx.s so in case the user-function can use
6677266816
** the already allocated buffer instead of allocating a new one.
6677366817
*/
@@ -66786,15 +66830,11 @@
6678666830
lastRowid = db->lastRowid;
6678766831
6678866832
/* If any auxiliary data functions have been called by this user function,
6678966833
** immediately call the destructor for any non-static values.
6679066834
*/
66791
- if( u.ai.ctx.pVdbeFunc ){
66792
- sqlite3VdbeDeleteAuxData(u.ai.ctx.pVdbeFunc, pOp->p1);
66793
- pOp->p4.pVdbeFunc = u.ai.ctx.pVdbeFunc;
66794
- pOp->p4type = P4_VDBEFUNC;
66795
- }
66835
+ sqlite3VdbeDeleteAuxData(p, pc, pOp->p1);
6679666836
6679766837
if( db->mallocFailed ){
6679866838
/* Even though a malloc() has failed, the implementation of the
6679966839
** user function may have called an sqlite3_result_XXX() function
6680066840
** to return a value. The following call releases any resources
@@ -74157,15 +74197,24 @@
7415774197
/* Translate the schema name in zDb into a pointer to the corresponding
7415874198
** schema. If not found, pSchema will remain NULL and nothing will match
7415974199
** resulting in an appropriate error message toward the end of this routine
7416074200
*/
7416174201
if( zDb ){
74162
- for(i=0; i<db->nDb; i++){
74163
- assert( db->aDb[i].zName );
74164
- if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){
74165
- pSchema = db->aDb[i].pSchema;
74166
- break;
74202
+ testcase( pNC->ncFlags & NC_PartIdx );
74203
+ testcase( pNC->ncFlags & NC_IsCheck );
74204
+ if( (pNC->ncFlags & (NC_PartIdx|NC_IsCheck))!=0 ){
74205
+ /* Silently ignore database qualifiers inside CHECK constraints and partial
74206
+ ** indices. Do not raise errors because that might break legacy and
74207
+ ** because it does not hurt anything to just ignore the database name. */
74208
+ zDb = 0;
74209
+ }else{
74210
+ for(i=0; i<db->nDb; i++){
74211
+ assert( db->aDb[i].zName );
74212
+ if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){
74213
+ pSchema = db->aDb[i].pSchema;
74214
+ break;
74215
+ }
7416774216
}
7416874217
}
7416974218
}
7417074219
7417174220
/* Start at the inner-most context and move outward until a match is found */
@@ -74438,10 +74487,43 @@
7443874487
}
7443974488
ExprSetProperty(p, EP_Resolved);
7444074489
}
7444174490
return p;
7444274491
}
74492
+
74493
+/*
74494
+** Report an error that an expression is not valid for a partial index WHERE
74495
+** clause.
74496
+*/
74497
+static void notValidPartIdxWhere(
74498
+ Parse *pParse, /* Leave error message here */
74499
+ NameContext *pNC, /* The name context */
74500
+ const char *zMsg /* Type of error */
74501
+){
74502
+ if( (pNC->ncFlags & NC_PartIdx)!=0 ){
74503
+ sqlite3ErrorMsg(pParse, "%s prohibited in partial index WHERE clauses",
74504
+ zMsg);
74505
+ }
74506
+}
74507
+
74508
+#ifndef SQLITE_OMIT_CHECK
74509
+/*
74510
+** Report an error that an expression is not valid for a CHECK constraint.
74511
+*/
74512
+static void notValidCheckConstraint(
74513
+ Parse *pParse, /* Leave error message here */
74514
+ NameContext *pNC, /* The name context */
74515
+ const char *zMsg /* Type of error */
74516
+){
74517
+ if( (pNC->ncFlags & NC_IsCheck)!=0 ){
74518
+ sqlite3ErrorMsg(pParse,"%s prohibited in CHECK constraints", zMsg);
74519
+ }
74520
+}
74521
+#else
74522
+# define notValidCheckConstraint(P,N,M)
74523
+#endif
74524
+
7444374525
7444474526
/*
7444574527
** This routine is callback for sqlite3WalkExpr().
7444674528
**
7444774529
** Resolve symbolic names into TK_COLUMN operators for the current
@@ -74538,10 +74620,11 @@
7453874620
FuncDef *pDef; /* Information about the function */
7453974621
u8 enc = ENC(pParse->db); /* The database encoding */
7454074622
7454174623
testcase( pExpr->op==TK_CONST_FUNC );
7454274624
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
74625
+ notValidPartIdxWhere(pParse, pNC, "functions");
7454374626
zId = pExpr->u.zToken;
7454474627
nId = sqlite3Strlen30(zId);
7454574628
pDef = sqlite3FindFunction(pParse->db, zId, nId, n, enc, 0);
7454674629
if( pDef==0 ){
7454774630
pDef = sqlite3FindFunction(pParse->db, zId, nId, -2, enc, 0);
@@ -74603,31 +74686,25 @@
7460374686
#endif
7460474687
case TK_IN: {
7460574688
testcase( pExpr->op==TK_IN );
7460674689
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
7460774690
int nRef = pNC->nRef;
74608
-#ifndef SQLITE_OMIT_CHECK
74609
- if( (pNC->ncFlags & NC_IsCheck)!=0 ){
74610
- sqlite3ErrorMsg(pParse,"subqueries prohibited in CHECK constraints");
74611
- }
74612
-#endif
74691
+ notValidCheckConstraint(pParse, pNC, "subqueries");
74692
+ notValidPartIdxWhere(pParse, pNC, "subqueries");
7461374693
sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
7461474694
assert( pNC->nRef>=nRef );
7461574695
if( nRef!=pNC->nRef ){
7461674696
ExprSetProperty(pExpr, EP_VarSelect);
7461774697
}
7461874698
}
7461974699
break;
7462074700
}
74621
-#ifndef SQLITE_OMIT_CHECK
7462274701
case TK_VARIABLE: {
74623
- if( (pNC->ncFlags & NC_IsCheck)!=0 ){
74624
- sqlite3ErrorMsg(pParse,"parameters prohibited in CHECK constraints");
74625
- }
74702
+ notValidCheckConstraint(pParse, pNC, "parameters");
74703
+ notValidPartIdxWhere(pParse, pNC, "parameters");
7462674704
break;
7462774705
}
74628
-#endif
7462974706
}
7463074707
return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue;
7463174708
}
7463274709
7463374710
/*
@@ -74714,11 +74791,11 @@
7471474791
/* Try to match the ORDER BY expression against an expression
7471574792
** in the result set. Return an 1-based index of the matching
7471674793
** result-set entry.
7471774794
*/
7471874795
for(i=0; i<pEList->nExpr; i++){
74719
- if( sqlite3ExprCompare(pEList->a[i].pExpr, pE)<2 ){
74796
+ if( sqlite3ExprCompare(pEList->a[i].pExpr, pE, -1)<2 ){
7472074797
return i+1;
7472174798
}
7472274799
}
7472374800
7472474801
/* If no match, return 0. */
@@ -74942,11 +75019,11 @@
7494275019
pItem->iOrderByCol = 0;
7494375020
if( sqlite3ResolveExprNames(pNC, pE) ){
7494475021
return 1;
7494575022
}
7494675023
for(j=0; j<pSelect->pEList->nExpr; j++){
74947
- if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr)==0 ){
75024
+ if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
7494875025
pItem->iOrderByCol = j+1;
7494975026
}
7495075027
}
7495175028
}
7495275029
return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
@@ -75248,10 +75325,52 @@
7524875325
w.xSelectCallback = resolveSelectStep;
7524975326
w.pParse = pParse;
7525075327
w.u.pNC = pOuterNC;
7525175328
sqlite3WalkSelect(&w, p);
7525275329
}
75330
+
75331
+/*
75332
+** Resolve names in expressions that can only reference a single table:
75333
+**
75334
+** * CHECK constraints
75335
+** * WHERE clauses on partial indices
75336
+**
75337
+** The Expr.iTable value for Expr.op==TK_COLUMN nodes of the expression
75338
+** is set to -1 and the Expr.iColumn value is set to the column number.
75339
+**
75340
+** Any errors cause an error message to be set in pParse.
75341
+*/
75342
+SQLITE_PRIVATE void sqlite3ResolveSelfReference(
75343
+ Parse *pParse, /* Parsing context */
75344
+ Table *pTab, /* The table being referenced */
75345
+ int type, /* NC_IsCheck or NC_PartIdx */
75346
+ Expr *pExpr, /* Expression to resolve. May be NULL. */
75347
+ ExprList *pList /* Expression list to resolve. May be NUL. */
75348
+){
75349
+ SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
75350
+ NameContext sNC; /* Name context for pParse->pNewTable */
75351
+ int i; /* Loop counter */
75352
+
75353
+ assert( type==NC_IsCheck || type==NC_PartIdx );
75354
+ memset(&sNC, 0, sizeof(sNC));
75355
+ memset(&sSrc, 0, sizeof(sSrc));
75356
+ sSrc.nSrc = 1;
75357
+ sSrc.a[0].zName = pTab->zName;
75358
+ sSrc.a[0].pTab = pTab;
75359
+ sSrc.a[0].iCursor = -1;
75360
+ sNC.pParse = pParse;
75361
+ sNC.pSrcList = &sSrc;
75362
+ sNC.ncFlags = type;
75363
+ if( sqlite3ResolveExprNames(&sNC, pExpr) ) return;
75364
+ if( pList ){
75365
+ for(i=0; i<pList->nExpr; i++){
75366
+ if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){
75367
+ return;
75368
+ }
75369
+ }
75370
+ }
75371
+}
7525375372
7525475373
/************** End of resolve.c *********************************************/
7525575374
/************** Begin file expr.c ********************************************/
7525675375
/*
7525775376
** 2001 September 15
@@ -77614,19 +77733,24 @@
7761477733
break;
7761577734
}
7761677735
/* Otherwise, fall thru into the TK_COLUMN case */
7761777736
}
7761877737
case TK_COLUMN: {
77619
- if( pExpr->iTable<0 ){
77620
- /* This only happens when coding check constraints */
77621
- assert( pParse->ckBase>0 );
77622
- inReg = pExpr->iColumn + pParse->ckBase;
77623
- }else{
77624
- inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
77625
- pExpr->iColumn, pExpr->iTable, target,
77626
- pExpr->op2);
77627
- }
77738
+ int iTab = pExpr->iTable;
77739
+ if( iTab<0 ){
77740
+ if( pParse->ckBase>0 ){
77741
+ /* Generating CHECK constraints or inserting into partial index */
77742
+ inReg = pExpr->iColumn + pParse->ckBase;
77743
+ break;
77744
+ }else{
77745
+ /* Deleting from a partial index */
77746
+ iTab = pParse->iPartIdxTab;
77747
+ }
77748
+ }
77749
+ inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
77750
+ pExpr->iColumn, iTab, target,
77751
+ pExpr->op2);
7762877752
break;
7762977753
}
7763077754
case TK_INTEGER: {
7763177755
codeInteger(pParse, pExpr, 0, target);
7763277756
break;
@@ -79045,10 +79169,16 @@
7904579169
** Do a deep comparison of two expression trees. Return 0 if the two
7904679170
** expressions are completely identical. Return 1 if they differ only
7904779171
** by a COLLATE operator at the top level. Return 2 if there are differences
7904879172
** other than the top-level COLLATE operator.
7904979173
**
79174
+** If any subelement of pB has Expr.iTable==(-1) then it is allowed
79175
+** to compare equal to an equivalent element in pA with Expr.iTable==iTab.
79176
+**
79177
+** The pA side might be using TK_REGISTER. If that is the case and pB is
79178
+** not using TK_REGISTER but is otherwise equivalent, then still return 0.
79179
+**
7905079180
** Sometimes this routine will return 2 even if the two expressions
7905179181
** really are equivalent. If we cannot prove that the expressions are
7905279182
** identical, we return 2 just to be safe. So if this routine
7905379183
** returns 2, then you do not really know for certain if the two
7905479184
** expressions are the same. But if you get a 0 or 1 return, then you
@@ -79055,33 +79185,36 @@
7905579185
** can be sure the expressions are the same. In the places where
7905679186
** this routine is used, it does not hurt to get an extra 2 - that
7905779187
** just might result in some slightly slower code. But returning
7905879188
** an incorrect 0 or 1 could lead to a malfunction.
7905979189
*/
79060
-SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB){
79190
+SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB, int iTab){
7906179191
if( pA==0||pB==0 ){
7906279192
return pB==pA ? 0 : 2;
7906379193
}
7906479194
assert( !ExprHasAnyProperty(pA, EP_TokenOnly|EP_Reduced) );
7906579195
assert( !ExprHasAnyProperty(pB, EP_TokenOnly|EP_Reduced) );
7906679196
if( ExprHasProperty(pA, EP_xIsSelect) || ExprHasProperty(pB, EP_xIsSelect) ){
7906779197
return 2;
7906879198
}
7906979199
if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
79070
- if( pA->op!=pB->op ){
79071
- if( pA->op==TK_COLLATE && sqlite3ExprCompare(pA->pLeft, pB)<2 ){
79200
+ if( pA->op!=pB->op && (pA->op!=TK_REGISTER || pA->op2!=pB->op) ){
79201
+ if( pA->op==TK_COLLATE && sqlite3ExprCompare(pA->pLeft, pB, iTab)<2 ){
7907279202
return 1;
7907379203
}
79074
- if( pB->op==TK_COLLATE && sqlite3ExprCompare(pA, pB->pLeft)<2 ){
79204
+ if( pB->op==TK_COLLATE && sqlite3ExprCompare(pA, pB->pLeft, iTab)<2 ){
7907579205
return 1;
7907679206
}
7907779207
return 2;
7907879208
}
79079
- if( sqlite3ExprCompare(pA->pLeft, pB->pLeft) ) return 2;
79080
- if( sqlite3ExprCompare(pA->pRight, pB->pRight) ) return 2;
79081
- if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList) ) return 2;
79082
- if( pA->iTable!=pB->iTable || pA->iColumn!=pB->iColumn ) return 2;
79209
+ if( sqlite3ExprCompare(pA->pLeft, pB->pLeft, iTab) ) return 2;
79210
+ if( sqlite3ExprCompare(pA->pRight, pB->pRight, iTab) ) return 2;
79211
+ if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
79212
+ if( pA->iColumn!=pB->iColumn ) return 2;
79213
+ if( pA->iTable!=pB->iTable
79214
+ && pA->op!=TK_REGISTER
79215
+ && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
7908379216
if( ExprHasProperty(pA, EP_IntValue) ){
7908479217
if( !ExprHasProperty(pB, EP_IntValue) || pA->u.iValue!=pB->u.iValue ){
7908579218
return 2;
7908679219
}
7908779220
}else if( pA->op!=TK_COLUMN && ALWAYS(pA->op!=TK_AGG_COLUMN) && pA->u.zToken){
@@ -79095,28 +79228,70 @@
7909579228
7909679229
/*
7909779230
** Compare two ExprList objects. Return 0 if they are identical and
7909879231
** non-zero if they differ in any way.
7909979232
**
79233
+** If any subelement of pB has Expr.iTable==(-1) then it is allowed
79234
+** to compare equal to an equivalent element in pA with Expr.iTable==iTab.
79235
+**
7910079236
** This routine might return non-zero for equivalent ExprLists. The
7910179237
** only consequence will be disabled optimizations. But this routine
7910279238
** must never return 0 if the two ExprList objects are different, or
7910379239
** a malfunction will result.
7910479240
**
7910579241
** Two NULL pointers are considered to be the same. But a NULL pointer
7910679242
** always differs from a non-NULL pointer.
7910779243
*/
79108
-SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB){
79244
+SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB, int iTab){
7910979245
int i;
7911079246
if( pA==0 && pB==0 ) return 0;
7911179247
if( pA==0 || pB==0 ) return 1;
7911279248
if( pA->nExpr!=pB->nExpr ) return 1;
7911379249
for(i=0; i<pA->nExpr; i++){
7911479250
Expr *pExprA = pA->a[i].pExpr;
7911579251
Expr *pExprB = pB->a[i].pExpr;
7911679252
if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
79117
- if( sqlite3ExprCompare(pExprA, pExprB) ) return 1;
79253
+ if( sqlite3ExprCompare(pExprA, pExprB, iTab) ) return 1;
79254
+ }
79255
+ return 0;
79256
+}
79257
+
79258
+/*
79259
+** Return true if we can prove the pE2 will always be true if pE1 is
79260
+** true. Return false if we cannot complete the proof or if pE2 might
79261
+** be false. Examples:
79262
+**
79263
+** pE1: x==5 pE2: x==5 Result: true
79264
+** pE1: x>0 pE2: x==5 Result: false
79265
+** pE1: x=21 pE2: x=21 OR y=43 Result: true
79266
+** pE1: x!=123 pE2: x IS NOT NULL Result: true
79267
+** pE1: x!=?1 pE2: x IS NOT NULL Result: true
79268
+** pE1: x IS NULL pE2: x IS NOT NULL Result: false
79269
+** pE1: x IS ?2 pE2: x IS NOT NULL Reuslt: false
79270
+**
79271
+** When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has
79272
+** Expr.iTable<0 then assume a table number given by iTab.
79273
+**
79274
+** When in doubt, return false. Returning true might give a performance
79275
+** improvement. Returning false might cause a performance reduction, but
79276
+** it will always give the correct answer and is hence always safe.
79277
+*/
79278
+SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr *pE1, Expr *pE2, int iTab){
79279
+ if( sqlite3ExprCompare(pE1, pE2, iTab)==0 ){
79280
+ return 1;
79281
+ }
79282
+ if( pE2->op==TK_OR
79283
+ && (sqlite3ExprImpliesExpr(pE1, pE2->pLeft, iTab)
79284
+ || sqlite3ExprImpliesExpr(pE1, pE2->pRight, iTab) )
79285
+ ){
79286
+ return 1;
79287
+ }
79288
+ if( pE2->op==TK_NOTNULL
79289
+ && sqlite3ExprCompare(pE1->pLeft, pE2->pLeft, iTab)==0
79290
+ && (pE1->op!=TK_ISNULL && pE1->op!=TK_IS)
79291
+ ){
79292
+ return 1;
7911879293
}
7911979294
return 0;
7912079295
}
7912179296
7912279297
/*
@@ -79297,11 +79472,11 @@
7929779472
/* Check to see if pExpr is a duplicate of another aggregate
7929879473
** function that is already in the pAggInfo structure
7929979474
*/
7930079475
struct AggInfo_func *pItem = pAggInfo->aFunc;
7930179476
for(i=0; i<pAggInfo->nFunc; i++, pItem++){
79302
- if( sqlite3ExprCompare(pItem->pExpr, pExpr)==0 ){
79477
+ if( sqlite3ExprCompare(pItem->pExpr, pExpr, -1)==0 ){
7930379478
break;
7930479479
}
7930579480
}
7930679481
if( i>=pAggInfo->nFunc ){
7930779482
/* pExpr is original. Make a new entry in pAggInfo->aFunc[]
@@ -80714,10 +80889,11 @@
8071480889
int i; /* Loop counter */
8071580890
int topOfLoop; /* The top of the loop */
8071680891
int endOfLoop; /* The end of the loop */
8071780892
int jZeroRows = -1; /* Jump from here if number of rows is zero */
8071880893
int iDb; /* Index of database containing pTab */
80894
+ u8 needTableCnt = 1; /* True to count the table */
8071980895
int regTabname = iMem++; /* Register containing table name */
8072080896
int regIdxname = iMem++; /* Register containing index name */
8072180897
int regStat1 = iMem++; /* The stat column of sqlite_stat1 */
8072280898
#ifdef SQLITE_ENABLE_STAT3
8072380899
int regNumEq = regStat1; /* Number of instances. Same as regStat1 */
@@ -80773,10 +80949,11 @@
8077380949
KeyInfo *pKey;
8077480950
int addrIfNot = 0; /* address of OP_IfNot */
8077580951
int *aChngAddr; /* Array of jump instruction addresses */
8077680952
8077780953
if( pOnlyIdx && pOnlyIdx!=pIdx ) continue;
80954
+ if( pIdx->pPartIdxWhere==0 ) needTableCnt = 0;
8077880955
VdbeNoopComment((v, "Begin analysis of %s", pIdx->zName));
8077980956
nCol = pIdx->nColumn;
8078080957
aChngAddr = sqlite3DbMallocRaw(db, sizeof(int)*nCol);
8078180958
if( aChngAddr==0 ) continue;
8078280959
pKey = sqlite3IndexKeyinfo(pParse, pIdx);
@@ -80932,48 +81109,45 @@
8093281109
** If K==0 then no entry is made into the sqlite_stat1 table.
8093381110
** If K>0 then it is always the case the D>0 so division by zero
8093481111
** is never possible.
8093581112
*/
8093681113
sqlite3VdbeAddOp2(v, OP_SCopy, iMem, regStat1);
80937
- if( jZeroRows<0 ){
80938
- jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem);
80939
- }
81114
+ jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem);
8094081115
for(i=0; i<nCol; i++){
8094181116
sqlite3VdbeAddOp4(v, OP_String8, 0, regTemp, 0, " ", 0);
8094281117
sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1);
8094381118
sqlite3VdbeAddOp3(v, OP_Add, iMem, iMem+i+1, regTemp);
8094481119
sqlite3VdbeAddOp2(v, OP_AddImm, regTemp, -1);
8094581120
sqlite3VdbeAddOp3(v, OP_Divide, iMem+i+1, regTemp, regTemp);
8094681121
sqlite3VdbeAddOp1(v, OP_ToInt, regTemp);
8094781122
sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1);
8094881123
}
81124
+ if( pIdx->pPartIdxWhere!=0 ) sqlite3VdbeJumpHere(v, jZeroRows);
8094981125
sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0);
8095081126
sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
8095181127
sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);
8095281128
sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
81129
+ if( pIdx->pPartIdxWhere==0 ) sqlite3VdbeJumpHere(v, jZeroRows);
8095381130
}
8095481131
80955
- /* If the table has no indices, create a single sqlite_stat1 entry
80956
- ** containing NULL as the index name and the row count as the content.
81132
+ /* Create a single sqlite_stat1 entry containing NULL as the index
81133
+ ** name and the row count as the content.
8095781134
*/
80958
- if( pTab->pIndex==0 ){
81135
+ if( pOnlyIdx==0 && needTableCnt ){
8095981136
sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pTab->tnum, iDb);
8096081137
VdbeComment((v, "%s", pTab->zName));
8096181138
sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat1);
8096281139
sqlite3VdbeAddOp1(v, OP_Close, iIdxCur);
8096381140
jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1);
80964
- }else{
80965
- sqlite3VdbeJumpHere(v, jZeroRows);
80966
- jZeroRows = sqlite3VdbeAddOp0(v, OP_Goto);
80967
- }
80968
- sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname);
80969
- sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0);
80970
- sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
80971
- sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);
80972
- sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
80973
- if( pParse->nMem<regRec ) pParse->nMem = regRec;
80974
- sqlite3VdbeJumpHere(v, jZeroRows);
81141
+ sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname);
81142
+ sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0);
81143
+ sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
81144
+ sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);
81145
+ sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
81146
+ sqlite3VdbeJumpHere(v, jZeroRows);
81147
+ }
81148
+ if( pParse->nMem<regRec ) pParse->nMem = regRec;
8097581149
}
8097681150
8097781151
8097881152
/*
8097981153
** Generate code that will cause the most recent index analysis to
@@ -81152,12 +81326,14 @@
8115281326
v = 0;
8115381327
while( (c=z[0])>='0' && c<='9' ){
8115481328
v = v*10 + c - '0';
8115581329
z++;
8115681330
}
81157
- if( i==0 ) pTable->nRowEst = v;
81158
- if( pIndex==0 ) break;
81331
+ if( i==0 && (pIndex==0 || pIndex->pPartIdxWhere==0) ){
81332
+ if( v>0 ) pTable->nRowEst = v;
81333
+ if( pIndex==0 ) break;
81334
+ }
8115981335
pIndex->aiRowEst[i] = v;
8116081336
if( *z==' ' ) z++;
8116181337
if( strcmp(z, "unordered")==0 ){
8116281338
pIndex->bUnordered = 1;
8116381339
break;
@@ -82593,10 +82769,11 @@
8259382769
*/
8259482770
static void freeIndex(sqlite3 *db, Index *p){
8259582771
#ifndef SQLITE_OMIT_ANALYZE
8259682772
sqlite3DeleteIndexSamples(db, p);
8259782773
#endif
82774
+ sqlite3ExprDelete(db, p->pPartIdxWhere);
8259882775
sqlite3DbFree(db, p->zColAff);
8259982776
sqlite3DbFree(db, p);
8260082777
}
8260182778
8260282779
/*
@@ -83436,11 +83613,12 @@
8343683613
sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
8343783614
"INTEGER PRIMARY KEY");
8343883615
#endif
8343983616
}else{
8344083617
Index *p;
83441
- p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, 0, sortOrder, 0);
83618
+ p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0,
83619
+ 0, sortOrder, 0);
8344283620
if( p ){
8344383621
p->autoIndex = 2;
8344483622
}
8344583623
pList = 0;
8344683624
}
@@ -83731,30 +83909,11 @@
8373183909
8373283910
#ifndef SQLITE_OMIT_CHECK
8373383911
/* Resolve names in all CHECK constraint expressions.
8373483912
*/
8373583913
if( p->pCheck ){
83736
- SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
83737
- NameContext sNC; /* Name context for pParse->pNewTable */
83738
- ExprList *pList; /* List of all CHECK constraints */
83739
- int i; /* Loop counter */
83740
-
83741
- memset(&sNC, 0, sizeof(sNC));
83742
- memset(&sSrc, 0, sizeof(sSrc));
83743
- sSrc.nSrc = 1;
83744
- sSrc.a[0].zName = p->zName;
83745
- sSrc.a[0].pTab = p;
83746
- sSrc.a[0].iCursor = -1;
83747
- sNC.pParse = pParse;
83748
- sNC.pSrcList = &sSrc;
83749
- sNC.ncFlags = NC_IsCheck;
83750
- pList = p->pCheck;
83751
- for(i=0; i<pList->nExpr; i++){
83752
- if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){
83753
- return;
83754
- }
83755
- }
83914
+ sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck);
8375683915
}
8375783916
#endif /* !defined(SQLITE_OMIT_CHECK) */
8375883917
8375983918
/* If the db->init.busy is 1 it means we are reading the SQL off the
8376083919
** "sqlite_master" or "sqlite_temp_master" table on the disk.
@@ -84602,10 +84761,11 @@
8460284761
int iIdx = pParse->nTab++; /* Btree cursor used for pIndex */
8460384762
int iSorter; /* Cursor opened by OpenSorter (if in use) */
8460484763
int addr1; /* Address of top of loop */
8460584764
int addr2; /* Address to jump to for next iteration */
8460684765
int tnum; /* Root page of index */
84766
+ int iPartIdxLabel; /* Jump to this label to skip a row */
8460784767
Vdbe *v; /* Generate code into this virtual machine */
8460884768
KeyInfo *pKey; /* KeyInfo for index */
8460984769
int regRecord; /* Register holding assemblied index record */
8461084770
sqlite3 *db = pParse->db; /* The database connection */
8461184771
int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);
@@ -84641,12 +84801,13 @@
8464184801
** records into the sorter. */
8464284802
sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
8464384803
addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0);
8464484804
regRecord = sqlite3GetTempReg(pParse);
8464584805
84646
- sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1);
84806
+ sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1, &iPartIdxLabel);
8464784807
sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord);
84808
+ sqlite3VdbeResolveLabel(v, iPartIdxLabel);
8464884809
sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1);
8464984810
sqlite3VdbeJumpHere(v, addr1);
8465084811
addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0);
8465184812
if( pIndex->onError!=OE_None ){
8465284813
int j2 = sqlite3VdbeCurrentAddr(v) + 3;
@@ -84693,11 +84854,11 @@
8469384854
Token *pName2, /* Second part of index name. May be NULL */
8469484855
SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */
8469584856
ExprList *pList, /* A list of columns to be indexed */
8469684857
int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
8469784858
Token *pStart, /* The CREATE token that begins this statement */
84698
- Token *pEnd, /* The ")" that closes the CREATE INDEX statement */
84859
+ Expr *pPIWhere, /* WHERE clause for partial indices */
8469984860
int sortOrder, /* Sort order of primary key when pList==NULL */
8470084861
int ifNotExist /* Omit error if index already exists */
8470184862
){
8470284863
Index *pRet = 0; /* Pointer to return */
8470384864
Table *pTab = 0; /* Table to be indexed */
@@ -84715,11 +84876,10 @@
8471584876
struct ExprList_item *pListItem; /* For looping over pList */
8471684877
int nCol;
8471784878
int nExtra = 0;
8471884879
char *zExtra;
8471984880
84720
- assert( pStart==0 || pEnd!=0 ); /* pEnd must be non-NULL if pStart is */
8472184881
assert( pParse->nErr==0 ); /* Never called with prior errors */
8472284882
if( db->mallocFailed || IN_DECLARE_VTAB ){
8472384883
goto exit_create_index;
8472484884
}
8472584885
if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
@@ -84761,11 +84921,16 @@
8476184921
assert(0);
8476284922
}
8476384923
pTab = sqlite3LocateTableItem(pParse, 0, &pTblName->a[0]);
8476484924
assert( db->mallocFailed==0 || pTab==0 );
8476584925
if( pTab==0 ) goto exit_create_index;
84766
- assert( db->aDb[iDb].pSchema==pTab->pSchema );
84926
+ if( iDb==1 && db->aDb[iDb].pSchema!=pTab->pSchema ){
84927
+ sqlite3ErrorMsg(pParse,
84928
+ "cannot create a TEMP index on non-TEMP table \"%s\"",
84929
+ pTab->zName);
84930
+ goto exit_create_index;
84931
+ }
8476784932
}else{
8476884933
assert( pName==0 );
8476984934
assert( pStart==0 );
8477084935
pTab = pParse->pNewTable;
8477184936
if( !pTab ) goto exit_create_index;
@@ -84910,10 +85075,15 @@
8491085075
pIndex->nColumn = pList->nExpr;
8491185076
pIndex->onError = (u8)onError;
8491285077
pIndex->uniqNotNull = onError==OE_Abort;
8491385078
pIndex->autoIndex = (u8)(pName==0);
8491485079
pIndex->pSchema = db->aDb[iDb].pSchema;
85080
+ if( pPIWhere ){
85081
+ sqlite3ResolveSelfReference(pParse, pTab, NC_PartIdx, pPIWhere, 0);
85082
+ pIndex->pPartIdxWhere = pPIWhere;
85083
+ pPIWhere = 0;
85084
+ }
8491585085
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
8491685086
8491785087
/* Check to see if we should honor DESC requests on index columns
8491885088
*/
8491985089
if( pDb->pSchema->file_format>=4 ){
@@ -85065,11 +85235,11 @@
8506585235
** If pTblName==0 it means this index is generated as a primary key
8506685236
** or UNIQUE constraint of a CREATE TABLE statement. Since the table
8506785237
** has just been created, it contains no data and the index initialization
8506885238
** step can be skipped.
8506985239
*/
85070
- else{ /* if( db->init.busy==0 ) */
85240
+ else if( pParse->nErr==0 ){
8507185241
Vdbe *v;
8507285242
char *zStmt;
8507385243
int iMem = ++pParse->nMem;
8507485244
8507585245
v = sqlite3GetVdbe(pParse);
@@ -85083,16 +85253,15 @@
8508385253
8508485254
/* Gather the complete text of the CREATE INDEX statement into
8508585255
** the zStmt variable
8508685256
*/
8508785257
if( pStart ){
85088
- assert( pEnd!=0 );
85258
+ int n = (pParse->sLastToken.z - pName->z) + pParse->sLastToken.n;
85259
+ if( pName->z[n-1]==';' ) n--;
8508985260
/* A named index with an explicit CREATE INDEX statement */
8509085261
zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s",
85091
- onError==OE_None ? "" : " UNIQUE",
85092
- (int)(pEnd->z - pName->z) + 1,
85093
- pName->z);
85262
+ onError==OE_None ? "" : " UNIQUE", n, pName->z);
8509485263
}else{
8509585264
/* An automatic index created by a PRIMARY KEY or UNIQUE constraint */
8509685265
/* zStmt = sqlite3MPrintf(""); */
8509785266
zStmt = 0;
8509885267
}
@@ -85144,14 +85313,12 @@
8514485313
pIndex = 0;
8514585314
}
8514685315
8514785316
/* Clean up before exiting */
8514885317
exit_create_index:
85149
- if( pIndex ){
85150
- sqlite3DbFree(db, pIndex->zColAff);
85151
- sqlite3DbFree(db, pIndex);
85152
- }
85318
+ if( pIndex ) freeIndex(db, pIndex);
85319
+ sqlite3ExprDelete(db, pPIWhere);
8515385320
sqlite3ExprListDelete(db, pList);
8515485321
sqlite3SrcListDelete(db, pTblName);
8515585322
sqlite3DbFree(db, zName);
8515685323
return pRet;
8515785324
}
@@ -87123,15 +87290,18 @@
8712387290
int *aRegIdx /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */
8712487291
){
8712587292
int i;
8712687293
Index *pIdx;
8712787294
int r1;
87295
+ int iPartIdxLabel;
87296
+ Vdbe *v = pParse->pVdbe;
8712887297
8712987298
for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
8713087299
if( aRegIdx!=0 && aRegIdx[i-1]==0 ) continue;
87131
- r1 = sqlite3GenerateIndexKey(pParse, pIdx, iCur, 0, 0);
87132
- sqlite3VdbeAddOp3(pParse->pVdbe, OP_IdxDelete, iCur+i, r1,pIdx->nColumn+1);
87300
+ r1 = sqlite3GenerateIndexKey(pParse, pIdx, iCur, 0, 0, &iPartIdxLabel);
87301
+ sqlite3VdbeAddOp3(v, OP_IdxDelete, iCur+i, r1, pIdx->nColumn+1);
87302
+ sqlite3VdbeResolveLabel(v, iPartIdxLabel);
8713387303
}
8713487304
}
8713587305
8713687306
/*
8713787307
** Generate code that will assemble an index key and put it in register
@@ -87141,24 +87311,42 @@
8714187311
**
8714287312
** Return a register number which is the first in a block of
8714387313
** registers that holds the elements of the index key. The
8714487314
** block of registers has already been deallocated by the time
8714587315
** this routine returns.
87316
+**
87317
+** If *piPartIdxLabel is not NULL, fill it in with a label and jump
87318
+** to that label if pIdx is a partial index that should be skipped.
87319
+** A partial index should be skipped if its WHERE clause evaluates
87320
+** to false or null. If pIdx is not a partial index, *piPartIdxLabel
87321
+** will be set to zero which is an empty label that is ignored by
87322
+** sqlite3VdbeResolveLabel().
8714687323
*/
8714787324
SQLITE_PRIVATE int sqlite3GenerateIndexKey(
87148
- Parse *pParse, /* Parsing context */
87149
- Index *pIdx, /* The index for which to generate a key */
87150
- int iCur, /* Cursor number for the pIdx->pTable table */
87151
- int regOut, /* Write the new index key to this register */
87152
- int doMakeRec /* Run the OP_MakeRecord instruction if true */
87325
+ Parse *pParse, /* Parsing context */
87326
+ Index *pIdx, /* The index for which to generate a key */
87327
+ int iCur, /* Cursor number for the pIdx->pTable table */
87328
+ int regOut, /* Write the new index key to this register */
87329
+ int doMakeRec, /* Run the OP_MakeRecord instruction if true */
87330
+ int *piPartIdxLabel /* OUT: Jump to this label to skip partial index */
8715387331
){
8715487332
Vdbe *v = pParse->pVdbe;
8715587333
int j;
8715687334
Table *pTab = pIdx->pTable;
8715787335
int regBase;
8715887336
int nCol;
8715987337
87338
+ if( piPartIdxLabel ){
87339
+ if( pIdx->pPartIdxWhere ){
87340
+ *piPartIdxLabel = sqlite3VdbeMakeLabel(v);
87341
+ pParse->iPartIdxTab = iCur;
87342
+ sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel,
87343
+ SQLITE_JUMPIFNULL);
87344
+ }else{
87345
+ *piPartIdxLabel = 0;
87346
+ }
87347
+ }
8716087348
nCol = pIdx->nColumn;
8716187349
regBase = sqlite3GetTempRange(pParse, nCol+1);
8716287350
sqlite3VdbeAddOp2(v, OP_Rowid, iCur, regBase+nCol);
8716387351
for(j=0; j<nCol; j++){
8716487352
int idx = pIdx->aiColumn[j];
@@ -91518,12 +91706,22 @@
9151891706
** Add the new records to the indices as we go.
9151991707
*/
9152091708
for(iCur=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, iCur++){
9152191709
int regIdx;
9152291710
int regR;
91711
+ int addrSkipRow = 0;
9152391712
9152491713
if( aRegIdx[iCur]==0 ) continue; /* Skip unused indices */
91714
+
91715
+ if( pIdx->pPartIdxWhere ){
91716
+ sqlite3VdbeAddOp2(v, OP_Null, 0, aRegIdx[iCur]);
91717
+ addrSkipRow = sqlite3VdbeMakeLabel(v);
91718
+ pParse->ckBase = regData;
91719
+ sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, addrSkipRow,
91720
+ SQLITE_JUMPIFNULL);
91721
+ pParse->ckBase = 0;
91722
+ }
9152591723
9152691724
/* Create a key for accessing the index entry */
9152791725
regIdx = sqlite3GetTempRange(pParse, pIdx->nColumn+1);
9152891726
for(i=0; i<pIdx->nColumn; i++){
9152991727
int idx = pIdx->aiColumn[i];
@@ -91540,10 +91738,11 @@
9154091738
9154191739
/* Find out what action to take in case there is an indexing conflict */
9154291740
onError = pIdx->onError;
9154391741
if( onError==OE_None ){
9154491742
sqlite3ReleaseTempRange(pParse, regIdx, pIdx->nColumn+1);
91743
+ sqlite3VdbeResolveLabel(v, addrSkipRow);
9154591744
continue; /* pIdx is not a UNIQUE index */
9154691745
}
9154791746
if( overrideError!=OE_Default ){
9154891747
onError = overrideError;
9154991748
}else if( onError==OE_Default ){
@@ -91609,10 +91808,11 @@
9160991808
seenReplace = 1;
9161091809
break;
9161191810
}
9161291811
}
9161391812
sqlite3VdbeJumpHere(v, j3);
91813
+ sqlite3VdbeResolveLabel(v, addrSkipRow);
9161491814
sqlite3ReleaseTempReg(pParse, regR);
9161591815
}
9161691816
9161791817
if( pbMayReplace ){
9161891818
*pbMayReplace = seenReplace;
@@ -91638,22 +91838,23 @@
9163891838
int appendBias, /* True if this is likely to be an append */
9163991839
int useSeekResult /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */
9164091840
){
9164191841
int i;
9164291842
Vdbe *v;
91643
- int nIdx;
9164491843
Index *pIdx;
9164591844
u8 pik_flags;
9164691845
int regData;
9164791846
int regRec;
9164891847
9164991848
v = sqlite3GetVdbe(pParse);
9165091849
assert( v!=0 );
9165191850
assert( pTab->pSelect==0 ); /* This table is not a VIEW */
91652
- for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){}
91653
- for(i=nIdx-1; i>=0; i--){
91851
+ for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
9165491852
if( aRegIdx[i]==0 ) continue;
91853
+ if( pIdx->pPartIdxWhere ){
91854
+ sqlite3VdbeAddOp2(v, OP_IsNull, aRegIdx[i], sqlite3VdbeCurrentAddr(v)+2);
91855
+ }
9165591856
sqlite3VdbeAddOp2(v, OP_IdxInsert, baseCur+i+1, aRegIdx[i]);
9165691857
if( useSeekResult ){
9165791858
sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
9165891859
}
9165991860
}
@@ -91751,10 +91952,11 @@
9175191952
**
9175291953
** * The index is over the same set of columns
9175391954
** * The same DESC and ASC markings occurs on all columns
9175491955
** * The same onError processing (OE_Abort, OE_Ignore, etc)
9175591956
** * The same collating sequence on each column
91957
+** * The index has the exact same WHERE clause
9175691958
*/
9175791959
static int xferCompatibleIndex(Index *pDest, Index *pSrc){
9175891960
int i;
9175991961
assert( pDest && pSrc );
9176091962
assert( pDest->pTable!=pSrc->pTable );
@@ -91772,10 +91974,13 @@
9177291974
return 0; /* Different sort orders */
9177391975
}
9177491976
if( !xferCompatibleCollation(pSrc->azColl[i],pDest->azColl[i]) ){
9177591977
return 0; /* Different collating sequences */
9177691978
}
91979
+ }
91980
+ if( sqlite3ExprCompare(pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){
91981
+ return 0; /* Different WHERE clauses */
9177791982
}
9177891983
9177991984
/* If no test above fails then the indices must be compatible */
9178091985
return 1;
9178191986
}
@@ -91928,11 +92133,11 @@
9192892133
if( pSrcIdx==0 ){
9192992134
return 0; /* pDestIdx has no corresponding index in pSrc */
9193092135
}
9193192136
}
9193292137
#ifndef SQLITE_OMIT_CHECK
91933
- if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck, pDest->pCheck) ){
92138
+ if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) ){
9193492139
return 0; /* Tables have different CHECK constraints. Ticket #2252 */
9193592140
}
9193692141
#endif
9193792142
#ifndef SQLITE_OMIT_FOREIGN_KEY
9193892143
/* Disallow the transfer optimization if the destination table constains
@@ -94841,13 +95046,11 @@
9484195046
cnt++;
9484295047
}
9484395048
}
9484495049
9484595050
/* Make sure sufficient number of registers have been allocated */
94846
- if( pParse->nMem < cnt+4 ){
94847
- pParse->nMem = cnt+4;
94848
- }
95051
+ pParse->nMem = MAX( pParse->nMem, cnt+7 );
9484995052
9485095053
/* Do the b-tree integrity checks */
9485195054
sqlite3VdbeAddOp3(v, OP_IntegrityCk, 2, cnt, 1);
9485295055
sqlite3VdbeChangeP5(v, (u8)i);
9485395056
addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2);
@@ -94868,16 +95071,19 @@
9486895071
9486995072
if( pTab->pIndex==0 ) continue;
9487095073
addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Stop if out of errors */
9487195074
sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
9487295075
sqlite3VdbeJumpHere(v, addr);
95076
+ sqlite3ExprCacheClear(pParse);
9487395077
sqlite3OpenTableAndIndices(pParse, pTab, 1, OP_OpenRead);
94874
- sqlite3VdbeAddOp2(v, OP_Integer, 0, 2); /* reg(2) will count entries */
94875
- loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0);
94876
- sqlite3VdbeAddOp2(v, OP_AddImm, 2, 1); /* increment entry count */
95078
+ for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
95079
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, 7+j); /* index entries counter */
95080
+ }
95081
+ pParse->nMem = MAX(pParse->nMem, 7+j);
95082
+ loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0) + 1;
9487795083
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
94878
- int jmp2;
95084
+ int jmp2, jmp3;
9487995085
int r1;
9488095086
static const VdbeOpList idxErr[] = {
9488195087
{ OP_AddImm, 1, -1, 0},
9488295088
{ OP_String8, 0, 3, 0}, /* 1 */
9488395089
{ OP_Rowid, 1, 4, 0},
@@ -94888,47 +95094,38 @@
9488895094
{ OP_Concat, 6, 3, 3},
9488995095
{ OP_ResultRow, 3, 1, 0},
9489095096
{ OP_IfPos, 1, 0, 0}, /* 9 */
9489195097
{ OP_Halt, 0, 0, 0},
9489295098
};
94893
- r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 0);
95099
+ r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 0, &jmp3);
95100
+ sqlite3VdbeAddOp2(v, OP_AddImm, 7+j, 1); /* increment entry count */
9489495101
jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, j+2, 0, r1, pIdx->nColumn+1);
9489595102
addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr);
9489695103
sqlite3VdbeChangeP4(v, addr+1, "rowid ", P4_STATIC);
9489795104
sqlite3VdbeChangeP4(v, addr+3, " missing from index ", P4_STATIC);
9489895105
sqlite3VdbeChangeP4(v, addr+4, pIdx->zName, P4_TRANSIENT);
9489995106
sqlite3VdbeJumpHere(v, addr+9);
9490095107
sqlite3VdbeJumpHere(v, jmp2);
95108
+ sqlite3VdbeResolveLabel(v, jmp3);
9490195109
}
94902
- sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop+1);
94903
- sqlite3VdbeJumpHere(v, loopTop);
95110
+ sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop);
95111
+ sqlite3VdbeJumpHere(v, loopTop-1);
95112
+#ifndef SQLITE_OMIT_BTREECOUNT
95113
+ sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0,
95114
+ "wrong # of entries in index ", P4_STATIC);
9490495115
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
94905
- static const VdbeOpList cntIdx[] = {
94906
- { OP_Integer, 0, 3, 0},
94907
- { OP_Rewind, 0, 0, 0}, /* 1 */
94908
- { OP_AddImm, 3, 1, 0},
94909
- { OP_Next, 0, 0, 0}, /* 3 */
94910
- { OP_Eq, 2, 0, 3}, /* 4 */
94911
- { OP_AddImm, 1, -1, 0},
94912
- { OP_String8, 0, 2, 0}, /* 6 */
94913
- { OP_String8, 0, 3, 0}, /* 7 */
94914
- { OP_Concat, 3, 2, 2},
94915
- { OP_ResultRow, 2, 1, 0},
94916
- };
94917
- addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1);
95116
+ addr = sqlite3VdbeCurrentAddr(v);
95117
+ sqlite3VdbeAddOp2(v, OP_IfPos, 1, addr+2);
9491895118
sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
94919
- sqlite3VdbeJumpHere(v, addr);
94920
- addr = sqlite3VdbeAddOpList(v, ArraySize(cntIdx), cntIdx);
94921
- sqlite3VdbeChangeP1(v, addr+1, j+2);
94922
- sqlite3VdbeChangeP2(v, addr+1, addr+4);
94923
- sqlite3VdbeChangeP1(v, addr+3, j+2);
94924
- sqlite3VdbeChangeP2(v, addr+3, addr+2);
94925
- sqlite3VdbeJumpHere(v, addr+4);
94926
- sqlite3VdbeChangeP4(v, addr+6,
94927
- "wrong # of entries in index ", P4_STATIC);
94928
- sqlite3VdbeChangeP4(v, addr+7, pIdx->zName, P4_TRANSIENT);
94929
- }
95119
+ sqlite3VdbeAddOp2(v, OP_Count, j+2, 3);
95120
+ sqlite3VdbeAddOp3(v, OP_Eq, 7+j, addr+8, 3);
95121
+ sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1);
95122
+ sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pIdx->zName, P4_TRANSIENT);
95123
+ sqlite3VdbeAddOp3(v, OP_Concat, 3, 2, 7);
95124
+ sqlite3VdbeAddOp2(v, OP_ResultRow, 7, 1);
95125
+ }
95126
+#endif /* SQLITE_OMIT_BTREECOUNT */
9493095127
}
9493195128
}
9493295129
addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode);
9493395130
sqlite3VdbeChangeP2(v, addr, -mxErr);
9493495131
sqlite3VdbeJumpHere(v, addr+1);
@@ -100327,11 +100524,11 @@
100327100524
** will cause elements to come out in the correct order. This is
100328100525
** an optimization - the correct answer should result regardless.
100329100526
** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER
100330100527
** to disable this optimization for testing purposes.
100331100528
*/
100332
- if( sqlite3ExprListCompare(p->pGroupBy, pOrderBy)==0
100529
+ if( sqlite3ExprListCompare(p->pGroupBy, pOrderBy, -1)==0
100333100530
&& OptimizationEnabled(db, SQLITE_GroupByOrder) ){
100334100531
pOrderBy = 0;
100335100532
}
100336100533
100337100534
/* If the query is DISTINCT with an ORDER BY but is not an aggregate, and
@@ -100348,11 +100545,11 @@
100348100545
** used for both the ORDER BY and DISTINCT processing. As originally
100349100546
** written the query must use a temp-table for at least one of the ORDER
100350100547
** BY and DISTINCT, and an index or separate temp-table for the other.
100351100548
*/
100352100549
if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct
100353
- && sqlite3ExprListCompare(pOrderBy, p->pEList)==0
100550
+ && sqlite3ExprListCompare(pOrderBy, p->pEList, -1)==0
100354100551
){
100355100552
p->selFlags &= ~SF_Distinct;
100356100553
p->pGroupBy = sqlite3ExprListDup(db, p->pEList, 0);
100357100554
pGroupBy = p->pGroupBy;
100358100555
pOrderBy = 0;
@@ -102575,11 +102772,11 @@
102575102772
aRegIdx = sqlite3DbMallocRaw(db, sizeof(Index*) * nIdx );
102576102773
if( aRegIdx==0 ) goto update_cleanup;
102577102774
}
102578102775
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
102579102776
int reg;
102580
- if( hasFK || chngRowid ){
102777
+ if( hasFK || chngRowid || pIdx->pPartIdxWhere ){
102581102778
reg = ++pParse->nMem;
102582102779
}else{
102583102780
reg = 0;
102584102781
for(i=0; i<pIdx->nColumn; i++){
102585102782
if( aXRef[pIdx->aiColumn[i]]>=0 ){
@@ -105115,11 +105312,11 @@
105115105312
** the pWC->a[] array.
105116105313
*/
105117105314
static int whereClauseInsert(WhereClause *pWC, Expr *p, u8 wtFlags){
105118105315
WhereTerm *pTerm;
105119105316
int idx;
105120
- testcase( wtFlags & TERM_VIRTUAL ); /* EV: R-00211-15100 */
105317
+ testcase( wtFlags & TERM_VIRTUAL );
105121105318
if( pWC->nTerm>=pWC->nSlot ){
105122105319
WhereTerm *pOld = pWC->a;
105123105320
sqlite3 *db = pWC->pWInfo->pParse->db;
105124105321
pWC->a = sqlite3DbMallocRaw(db, sizeof(pWC->a[0])*pWC->nSlot*2 );
105125105322
if( pWC->a==0 ){
@@ -105260,17 +105457,10 @@
105260105457
105261105458
/*
105262105459
** Return TRUE if the given operator is one of the operators that is
105263105460
** allowed for an indexable WHERE clause term. The allowed operators are
105264105461
** "=", "<", ">", "<=", ">=", "IN", and "IS NULL"
105265
-**
105266
-** IMPLEMENTATION-OF: R-59926-26393 To be usable by an index a term must be
105267
-** of one of the following forms: column = expression column > expression
105268
-** column >= expression column < expression column <= expression
105269
-** expression = column expression > column expression >= column
105270
-** expression < column expression <= column column IN
105271
-** (expression-list) column IN (subquery) column IS NULL
105272105462
*/
105273105463
static int allowedOp(int op){
105274105464
assert( TK_GT>TK_EQ && TK_GT<TK_GE );
105275105465
assert( TK_LT>TK_EQ && TK_LT<TK_GE );
105276105466
assert( TK_LE>TK_EQ && TK_LE<TK_GE );
@@ -105585,11 +105775,11 @@
105585105775
op = pRight->op2;
105586105776
}
105587105777
if( op==TK_VARIABLE ){
105588105778
Vdbe *pReprepare = pParse->pReprepare;
105589105779
int iCol = pRight->iColumn;
105590
- pVal = sqlite3VdbeGetValue(pReprepare, iCol, SQLITE_AFF_NONE);
105780
+ pVal = sqlite3VdbeGetBoundValue(pReprepare, iCol, SQLITE_AFF_NONE);
105591105781
if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
105592105782
z = (char *)sqlite3_value_text(pVal);
105593105783
}
105594105784
sqlite3VdbeSetVarmask(pParse->pVdbe, iCol);
105595105785
assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );
@@ -105940,12 +106130,10 @@
105940106130
}
105941106131
105942106132
/* At this point, okToChngToIN is true if original pTerm satisfies
105943106133
** case 1. In that case, construct a new virtual term that is
105944106134
** pTerm converted into an IN operator.
105945
- **
105946
- ** EV: R-00211-15100
105947106135
*/
105948106136
if( okToChngToIN ){
105949106137
Expr *pDup; /* A transient duplicate expression */
105950106138
ExprList *pList = 0; /* The RHS of the IN operator */
105951106139
Expr *pLeft = 0; /* The LHS of the IN operator */
@@ -106183,13 +106371,11 @@
106183106371
** wildcard. But if we increment '@', that will push it into the
106184106372
** alphabetic range where case conversions will mess up the
106185106373
** inequality. To avoid this, make sure to also run the full
106186106374
** LIKE on all candidate expressions by clearing the isComplete flag
106187106375
*/
106188
- if( c=='A'-1 ) isComplete = 0; /* EV: R-64339-08207 */
106189
-
106190
-
106376
+ if( c=='A'-1 ) isComplete = 0;
106191106377
c = sqlite3UpperToLower[c];
106192106378
}
106193106379
*pC = c + 1;
106194106380
}
106195106381
sCollSeqName.z = noCase ? "NOCASE" : "BINARY";
@@ -106692,11 +106878,11 @@
106692106878
VdbeComment((v, "for %s", pTable->zName));
106693106879
106694106880
/* Fill the automatic index with content */
106695106881
addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur);
106696106882
regRecord = sqlite3GetTempReg(pParse);
106697
- sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 1);
106883
+ sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 1, 0);
106698106884
sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
106699106885
sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
106700106886
sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1);
106701106887
sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
106702106888
sqlite3VdbeJumpHere(v, addrTop);
@@ -107049,11 +107235,11 @@
107049107235
if( pExpr->op==TK_VARIABLE
107050107236
|| (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
107051107237
){
107052107238
int iVar = pExpr->iColumn;
107053107239
sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);
107054
- *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff);
107240
+ *pp = sqlite3VdbeGetBoundValue(pParse->pReprepare, iVar, aff);
107055107241
return SQLITE_OK;
107056107242
}
107057107243
return sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, aff, pp);
107058107244
}
107059107245
#endif
@@ -107275,13 +107461,10 @@
107275107461
**
107276107462
** The t2.z='ok' is disabled in the in (2) because it originates
107277107463
** in the ON clause. The term is disabled in (3) because it is not part
107278107464
** of a LEFT OUTER JOIN. In (1), the term is not disabled.
107279107465
**
107280
-** IMPLEMENTATION-OF: R-24597-58655 No tests are done for terms that are
107281
-** completely satisfied by indices.
107282
-**
107283107466
** Disabling a term causes that term to not be tested in the inner loop
107284107467
** of the join. Disabling is an optimization. When terms are satisfied
107285107468
** by indices, we disable them to prevent redundant tests in the inner
107286107469
** loop. We would get the correct results if nothing were ever disabled,
107287107470
** but joins might run a little slower. The trick is to disable as much
@@ -107507,11 +107690,11 @@
107507107690
pTerm = pLoop->aLTerm[j];
107508107691
assert( pTerm!=0 );
107509107692
/* The following true for indices with redundant columns.
107510107693
** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */
107511107694
testcase( (pTerm->wtFlags & TERM_CODED)!=0 );
107512
- testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
107695
+ testcase( pTerm->wtFlags & TERM_VIRTUAL );
107513107696
r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, regBase+j);
107514107697
if( r1!=regBase+j ){
107515107698
if( nReg==1 ){
107516107699
sqlite3ReleaseTempReg(pParse, regBase);
107517107700
regBase = r1;
@@ -107707,10 +107890,11 @@
107707107890
WhereLevel *pLevel; /* The where level to be coded */
107708107891
WhereLoop *pLoop; /* The WhereLoop object being coded */
107709107892
WhereClause *pWC; /* Decomposition of the entire WHERE clause */
107710107893
WhereTerm *pTerm; /* A WHERE clause term */
107711107894
Parse *pParse; /* Parsing context */
107895
+ sqlite3 *db; /* Database connection */
107712107896
Vdbe *v; /* The prepared stmt under constructions */
107713107897
struct SrcList_item *pTabItem; /* FROM clause term being coded */
107714107898
int addrBrk; /* Jump here to break out of the loop */
107715107899
int addrCont; /* Jump here to continue with next cycle */
107716107900
int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
@@ -107718,10 +107902,11 @@
107718107902
Bitmask newNotReady; /* Return value */
107719107903
107720107904
pParse = pWInfo->pParse;
107721107905
v = pParse->pVdbe;
107722107906
pWC = &pWInfo->sWC;
107907
+ db = pParse->db;
107723107908
pLevel = &pWInfo->a[iLevel];
107724107909
pLoop = pLevel->pWLoop;
107725107910
pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
107726107911
iCur = pTabItem->iCursor;
107727107912
bRev = (pWInfo->revMask>>iLevel)&1;
@@ -107816,11 +108001,11 @@
107816108001
iReleaseReg = sqlite3GetTempReg(pParse);
107817108002
pTerm = pLoop->aLTerm[0];
107818108003
assert( pTerm!=0 );
107819108004
assert( pTerm->pExpr!=0 );
107820108005
assert( omitTable==0 );
107821
- testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108006
+ testcase( pTerm->wtFlags & TERM_VIRTUAL );
107822108007
iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
107823108008
addrNxt = pLevel->addrNxt;
107824108009
sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt);
107825108010
sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg);
107826108011
sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1);
@@ -107864,11 +108049,11 @@
107864108049
assert( TK_LE==TK_GT+1 ); /* Make sure the ordering.. */
107865108050
assert( TK_LT==TK_GT+2 ); /* ... of the TK_xx values... */
107866108051
assert( TK_GE==TK_GT+3 ); /* ... is correcct. */
107867108052
107868108053
assert( (pStart->wtFlags & TERM_VNULL)==0 );
107869
- testcase( pStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108054
+ testcase( pStart->wtFlags & TERM_VIRTUAL );
107870108055
pX = pStart->pExpr;
107871108056
assert( pX!=0 );
107872108057
testcase( pStart->leftCursor!=iCur ); /* transitive constraints */
107873108058
r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);
107874108059
sqlite3VdbeAddOp3(v, aMoveOp[pX->op-TK_GT], iCur, addrBrk, r1);
@@ -107883,11 +108068,11 @@
107883108068
Expr *pX;
107884108069
pX = pEnd->pExpr;
107885108070
assert( pX!=0 );
107886108071
assert( (pEnd->wtFlags & TERM_VNULL)==0 );
107887108072
testcase( pEnd->leftCursor!=iCur ); /* Transitive constraints */
107888
- testcase( pEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108073
+ testcase( pEnd->wtFlags & TERM_VIRTUAL );
107889108074
memEndValue = ++pParse->nMem;
107890108075
sqlite3ExprCode(pParse, pX->pRight, memEndValue);
107891108076
if( pX->op==TK_LT || pX->op==TK_GT ){
107892108077
testOp = bRev ? OP_Le : OP_Ge;
107893108078
}else{
@@ -108008,11 +108193,11 @@
108008108193
/* Generate code to evaluate all constraint terms using == or IN
108009108194
** and store the values of those terms in an array of registers
108010108195
** starting at regBase.
108011108196
*/
108012108197
regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
108013
- zEndAff = sqlite3DbStrDup(pParse->db, zStartAff);
108198
+ zEndAff = sqlite3DbStrDup(db, zStartAff);
108014108199
addrNxt = pLevel->addrNxt;
108015108200
108016108201
/* If we are doing a reverse order scan on an ascending index, or
108017108202
** a forward order scan on a descending index, interchange the
108018108203
** start and end terms (pRangeStart and pRangeEnd).
@@ -108049,11 +108234,11 @@
108049108234
if( sqlite3ExprNeedsNoAffinityChange(pRight, zStartAff[nEq]) ){
108050108235
zStartAff[nEq] = SQLITE_AFF_NONE;
108051108236
}
108052108237
}
108053108238
nConstraint++;
108054
- testcase( pRangeStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108239
+ testcase( pRangeStart->wtFlags & TERM_VIRTUAL );
108055108240
}else if( isMinQuery ){
108056108241
sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
108057108242
nConstraint++;
108058108243
startEq = 0;
108059108244
start_constraints = 1;
@@ -108091,14 +108276,14 @@
108091108276
zEndAff[nEq] = SQLITE_AFF_NONE;
108092108277
}
108093108278
}
108094108279
codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
108095108280
nConstraint++;
108096
- testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108281
+ testcase( pRangeEnd->wtFlags & TERM_VIRTUAL );
108097108282
}
108098
- sqlite3DbFree(pParse->db, zStartAff);
108099
- sqlite3DbFree(pParse->db, zEndAff);
108283
+ sqlite3DbFree(db, zStartAff);
108284
+ sqlite3DbFree(db, zEndAff);
108100108285
108101108286
/* Top of the loop body */
108102108287
pLevel->p2 = sqlite3VdbeCurrentAddr(v);
108103108288
108104108289
/* Check if the index cursor is past the end of the range. */
@@ -108221,11 +108406,11 @@
108221108406
*/
108222108407
if( pWInfo->nLevel>1 ){
108223108408
int nNotReady; /* The number of notReady tables */
108224108409
struct SrcList_item *origSrc; /* Original list of tables */
108225108410
nNotReady = pWInfo->nLevel - iLevel - 1;
108226
- pOrTab = sqlite3StackAllocRaw(pParse->db,
108411
+ pOrTab = sqlite3StackAllocRaw(db,
108227108412
sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
108228108413
if( pOrTab==0 ) return notReady;
108229108414
pOrTab->nAlloc = (u8)(nNotReady + 1);
108230108415
pOrTab->nSrc = pOrTab->nAlloc;
108231108416
memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
@@ -108275,12 +108460,12 @@
108275108460
Expr *pExpr = pWC->a[iTerm].pExpr;
108276108461
if( &pWC->a[iTerm] == pTerm ) continue;
108277108462
if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
108278108463
if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue;
108279108464
if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
108280
- pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
108281
- pAndExpr = sqlite3ExprAnd(pParse->db, pAndExpr, pExpr);
108465
+ pExpr = sqlite3ExprDup(db, pExpr, 0);
108466
+ pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);
108282108467
}
108283108468
if( pAndExpr ){
108284108469
pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);
108285108470
}
108286108471
}
@@ -108296,11 +108481,11 @@
108296108481
}
108297108482
/* Loop through table entries that match term pOrTerm. */
108298108483
pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
108299108484
WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
108300108485
WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);
108301
- assert( pSubWInfo || pParse->nErr || pParse->db->mallocFailed );
108486
+ assert( pSubWInfo || pParse->nErr || db->mallocFailed );
108302108487
if( pSubWInfo ){
108303108488
WhereLoop *pSubLoop;
108304108489
explainOneScan(
108305108490
pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
108306108491
);
@@ -108351,17 +108536,17 @@
108351108536
}
108352108537
pLevel->u.pCovidx = pCov;
108353108538
if( pCov ) pLevel->iIdxCur = iCovCur;
108354108539
if( pAndExpr ){
108355108540
pAndExpr->pLeft = 0;
108356
- sqlite3ExprDelete(pParse->db, pAndExpr);
108541
+ sqlite3ExprDelete(db, pAndExpr);
108357108542
}
108358108543
sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
108359108544
sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
108360108545
sqlite3VdbeResolveLabel(v, iLoopBody);
108361108546
108362
- if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab);
108547
+ if( pWInfo->nLevel>1 ) sqlite3StackFree(db, pOrTab);
108363108548
if( !untestedTerms ) disableTerm(pLevel, pTerm);
108364108549
}else
108365108550
#endif /* SQLITE_OMIT_OR_OPTIMIZATION */
108366108551
108367108552
{
@@ -108378,18 +108563,14 @@
108378108563
}
108379108564
newNotReady = notReady & ~getMask(&pWInfo->sMaskSet, iCur);
108380108565
108381108566
/* Insert code to test every subexpression that can be completely
108382108567
** computed using the current set of tables.
108383
- **
108384
- ** IMPLEMENTATION-OF: R-49525-50935 Terms that cannot be satisfied through
108385
- ** the use of indices become tests that are evaluated against each row of
108386
- ** the relevant input tables.
108387108568
*/
108388108569
for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108389108570
Expr *pE;
108390
- testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */
108571
+ testcase( pTerm->wtFlags & TERM_VIRTUAL );
108391108572
testcase( pTerm->wtFlags & TERM_CODED );
108392108573
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108393108574
if( (pTerm->prereqAll & newNotReady)!=0 ){
108394108575
testcase( pWInfo->untestedTerms==0
108395108576
&& (pWInfo->wctrlFlags & WHERE_ONETABLE_ONLY)!=0 );
@@ -108412,13 +108593,12 @@
108412108593
** and we are coding the t1 loop and the t2 loop has not yet coded,
108413108594
** then we cannot use the "t1.a=t2.b" constraint, but we can code
108414108595
** the implied "t1.a=123" constraint.
108415108596
*/
108416108597
for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108417
- Expr *pE;
108598
+ Expr *pE, *pEAlt;
108418108599
WhereTerm *pAlt;
108419
- Expr sEq;
108420108600
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108421108601
if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108422108602
if( pTerm->leftCursor!=iCur ) continue;
108423108603
if( pLevel->iLeftJoin ) continue;
108424108604
pE = pTerm->pExpr;
@@ -108428,13 +108608,17 @@
108428108608
if( pAlt==0 ) continue;
108429108609
if( pAlt->wtFlags & (TERM_CODED) ) continue;
108430108610
testcase( pAlt->eOperator & WO_EQ );
108431108611
testcase( pAlt->eOperator & WO_IN );
108432108612
VdbeNoopComment((v, "begin transitive constraint"));
108433
- sEq = *pAlt->pExpr;
108434
- sEq.pLeft = pE->pLeft;
108435
- sqlite3ExprIfFalse(pParse, &sEq, addrCont, SQLITE_JUMPIFNULL);
108613
+ pEAlt = sqlite3StackAllocRaw(db, sizeof(*pEAlt));
108614
+ if( pEAlt ){
108615
+ *pEAlt = *pAlt->pExpr;
108616
+ pEAlt->pLeft = pE->pLeft;
108617
+ sqlite3ExprIfFalse(pParse, pEAlt, addrCont, SQLITE_JUMPIFNULL);
108618
+ sqlite3StackFree(db, pEAlt);
108619
+ }
108436108620
}
108437108621
108438108622
/* For a LEFT OUTER JOIN, generate code that will record the fact that
108439108623
** at least one row of the right table has matched the left table.
108440108624
*/
@@ -108442,11 +108626,11 @@
108442108626
pLevel->addrFirst = sqlite3VdbeCurrentAddr(v);
108443108627
sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin);
108444108628
VdbeComment((v, "record LEFT JOIN hit"));
108445108629
sqlite3ExprCacheClear(pParse);
108446108630
for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){
108447
- testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */
108631
+ testcase( pTerm->wtFlags & TERM_VIRTUAL );
108448108632
testcase( pTerm->wtFlags & TERM_CODED );
108449108633
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108450108634
if( (pTerm->prereqAll & newNotReady)!=0 ){
108451108635
assert( pWInfo->untestedTerms );
108452108636
continue;
@@ -108883,11 +109067,12 @@
108883109067
rc = whereEqualScanEst(pParse, pProbe, pTerm->pExpr->pRight, &nOut);
108884109068
}else if( (pTerm->eOperator & WO_IN)
108885109069
&& !ExprHasProperty(pTerm->pExpr, EP_xIsSelect) ){
108886109070
rc = whereInScanEst(pParse, pProbe, pTerm->pExpr->x.pList, &nOut);
108887109071
}
108888
- if( rc==SQLITE_OK ) pNew->nOut = whereCost(nOut);
109072
+ assert( nOut==0 || rc==SQLITE_OK );
109073
+ if( nOut ) pNew->nOut = whereCost(nOut);
108889109074
}
108890109075
#endif
108891109076
if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
108892109077
/* Each row involves a step of the index, then a binary search of
108893109078
** the main table */
@@ -108955,10 +109140,21 @@
108955109140
if( x<BMS-1 ) m |= MASKBIT(x);
108956109141
}
108957109142
return m;
108958109143
}
108959109144
109145
+/* Check to see if a partial index with pPartIndexWhere can be used
109146
+** in the current query. Return true if it can be and false if not.
109147
+*/
109148
+static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){
109149
+ int i;
109150
+ WhereTerm *pTerm;
109151
+ for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
109152
+ if( sqlite3ExprImpliesExpr(pTerm->pExpr, pWhere, iTab) ) return 1;
109153
+ }
109154
+ return 0;
109155
+}
108960109156
108961109157
/*
108962109158
** Add all WhereLoop objects for a single table of the join where the table
108963109159
** is idenfied by pBuilder->pNew->iTab. That table is guaranteed to be
108964109160
** a b-tree table, not a virtual table.
@@ -108978,15 +109174,17 @@
108978109174
int rc = SQLITE_OK; /* Return code */
108979109175
int iSortIdx = 1; /* Index number */
108980109176
int b; /* A boolean value */
108981109177
WhereCost rSize; /* number of rows in the table */
108982109178
WhereCost rLogSize; /* Logarithm of the number of rows in the table */
109179
+ WhereClause *pWC; /* The parsed WHERE clause */
108983109180
108984109181
pNew = pBuilder->pNew;
108985109182
pWInfo = pBuilder->pWInfo;
108986109183
pTabList = pWInfo->pTabList;
108987109184
pSrc = pTabList->a + pNew->iTab;
109185
+ pWC = pBuilder->pWC;
108988109186
assert( !IsVirtual(pSrc->pTab) );
108989109187
108990109188
if( pSrc->pIndex ){
108991109189
/* An INDEXED BY clause specifies a particular index to use */
108992109190
pProbe = pSrc->pIndex;
@@ -109022,11 +109220,10 @@
109022109220
&& !pSrc->viaCoroutine
109023109221
&& !pSrc->notIndexed
109024109222
&& !pSrc->isCorrelated
109025109223
){
109026109224
/* Generate auto-index WhereLoops */
109027
- WhereClause *pWC = pBuilder->pWC;
109028109225
WhereTerm *pTerm;
109029109226
WhereTerm *pWCEnd = pWC->a + pWC->nTerm;
109030109227
for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){
109031109228
if( pTerm->prereqRight & pNew->maskSelf ) continue;
109032109229
if( termCanDriveIndex(pTerm, pSrc, 0) ){
@@ -109052,10 +109249,14 @@
109052109249
}
109053109250
109054109251
/* Loop over all indices
109055109252
*/
109056109253
for(; rc==SQLITE_OK && pProbe; pProbe=pProbe->pNext, iSortIdx++){
109254
+ if( pProbe->pPartIdxWhere!=0
109255
+ && !whereUsablePartialIndex(pNew->iTab, pWC, pProbe->pPartIdxWhere) ){
109256
+ continue; /* Partial index inappropriate for this query */
109257
+ }
109057109258
pNew->u.btree.nEq = 0;
109058109259
pNew->nLTerm = 0;
109059109260
pNew->iSortIdx = 0;
109060109261
pNew->rSetup = 0;
109061109262
pNew->prereq = mExtra;
@@ -109992,11 +110193,11 @@
109992110193
pLoop->u.btree.nEq = 1;
109993110194
/* TUNING: Cost of a rowid lookup is 10 */
109994110195
pLoop->rRun = 33; /* 33==whereCost(10) */
109995110196
}else{
109996110197
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
109997
- if( pIdx->onError==OE_None ) continue;
110198
+ if( pIdx->onError==OE_None || pIdx->pPartIdxWhere!=0 ) continue;
109998110199
for(j=0; j<pIdx->nColumn; j++){
109999110200
pTerm = findTerm(pWC, iCur, pIdx->aiColumn[j], 0, WO_EQ, pIdx);
110000110201
if( pTerm==0 ) break;
110001110202
whereLoopResize(pWInfo->pParse->db, pLoop, j);
110002110203
pLoop->aLTerm[j] = pTerm;
@@ -110198,11 +110399,11 @@
110198110399
** subexpression is separated by an AND operator.
110199110400
*/
110200110401
initMaskSet(pMaskSet);
110201110402
whereClauseInit(&pWInfo->sWC, pWInfo);
110202110403
sqlite3ExprCodeConstants(pParse, pWhere);
110203
- whereSplit(&pWInfo->sWC, pWhere, TK_AND); /* IMP: R-15842-53296 */
110404
+ whereSplit(&pWInfo->sWC, pWhere, TK_AND);
110204110405
sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */
110205110406
110206110407
/* Special case: a WHERE clause that is constant. Evaluate the
110207110408
** expression and either jump over all of the code or fall thru.
110208110409
*/
@@ -110832,11 +111033,11 @@
110832111033
#endif
110833111034
#define sqlite3ParserARG_SDECL Parse *pParse;
110834111035
#define sqlite3ParserARG_PDECL ,Parse *pParse
110835111036
#define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
110836111037
#define sqlite3ParserARG_STORE yypParser->pParse = pParse
110837
-#define YYNSTATE 627
111038
+#define YYNSTATE 628
110838111039
#define YYNRULE 327
110839111040
#define YYFALLBACK 1
110840111041
#define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
110841111042
#define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
110842111043
#define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
@@ -110905,167 +111106,167 @@
110905111106
** shifting non-terminals after a reduce.
110906111107
** yy_default[] Default action for each state.
110907111108
*/
110908111109
#define YY_ACTTAB_COUNT (1564)
110909111110
static const YYACTIONTYPE yy_action[] = {
110910
- /* 0 */ 309, 955, 184, 417, 2, 171, 624, 594, 56, 56,
111111
+ /* 0 */ 310, 956, 184, 418, 2, 171, 625, 595, 56, 56,
110911111112
/* 10 */ 56, 56, 49, 54, 54, 54, 54, 53, 53, 52,
110912
- /* 20 */ 52, 52, 51, 233, 620, 619, 298, 620, 619, 234,
110913
- /* 30 */ 587, 581, 56, 56, 56, 56, 19, 54, 54, 54,
110914
- /* 40 */ 54, 53, 53, 52, 52, 52, 51, 233, 605, 57,
110915
- /* 50 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56,
110916
- /* 60 */ 56, 56, 541, 54, 54, 54, 54, 53, 53, 52,
110917
- /* 70 */ 52, 52, 51, 233, 309, 594, 325, 196, 195, 194,
111113
+ /* 20 */ 52, 52, 51, 233, 621, 620, 299, 621, 620, 234,
111114
+ /* 30 */ 588, 582, 56, 56, 56, 56, 19, 54, 54, 54,
111115
+ /* 40 */ 54, 53, 53, 52, 52, 52, 51, 233, 606, 57,
111116
+ /* 50 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
111117
+ /* 60 */ 56, 56, 542, 54, 54, 54, 54, 53, 53, 52,
111118
+ /* 70 */ 52, 52, 51, 233, 310, 595, 326, 196, 195, 194,
110918111119
/* 80 */ 33, 54, 54, 54, 54, 53, 53, 52, 52, 52,
110919
- /* 90 */ 51, 233, 617, 616, 165, 617, 616, 380, 377, 376,
110920
- /* 100 */ 407, 532, 576, 576, 587, 581, 303, 422, 375, 59,
111120
+ /* 90 */ 51, 233, 618, 617, 165, 618, 617, 381, 378, 377,
111121
+ /* 100 */ 408, 533, 577, 577, 588, 582, 304, 423, 376, 59,
110921111122
/* 110 */ 53, 53, 52, 52, 52, 51, 233, 50, 47, 146,
110922
- /* 120 */ 574, 545, 65, 57, 58, 48, 579, 578, 580, 580,
111123
+ /* 120 */ 575, 546, 65, 57, 58, 48, 580, 579, 581, 581,
110923111124
/* 130 */ 55, 55, 56, 56, 56, 56, 213, 54, 54, 54,
110924
- /* 140 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 223,
110925
- /* 150 */ 539, 420, 170, 176, 138, 280, 383, 275, 382, 168,
110926
- /* 160 */ 489, 551, 409, 668, 620, 619, 271, 438, 409, 438,
110927
- /* 170 */ 550, 604, 67, 482, 507, 618, 599, 412, 587, 581,
110928
- /* 180 */ 600, 483, 618, 412, 618, 598, 91, 439, 440, 439,
110929
- /* 190 */ 335, 598, 73, 669, 222, 266, 480, 57, 58, 48,
110930
- /* 200 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56,
110931
- /* 210 */ 670, 54, 54, 54, 54, 53, 53, 52, 52, 52,
110932
- /* 220 */ 51, 233, 309, 279, 232, 231, 1, 132, 200, 385,
110933
- /* 230 */ 620, 619, 617, 616, 278, 435, 289, 563, 175, 262,
110934
- /* 240 */ 409, 264, 437, 497, 436, 166, 441, 568, 336, 568,
110935
- /* 250 */ 201, 537, 587, 581, 599, 412, 165, 594, 600, 380,
110936
- /* 260 */ 377, 376, 597, 598, 92, 523, 618, 569, 569, 592,
110937
- /* 270 */ 375, 57, 58, 48, 579, 578, 580, 580, 55, 55,
110938
- /* 280 */ 56, 56, 56, 56, 597, 54, 54, 54, 54, 53,
110939
- /* 290 */ 53, 52, 52, 52, 51, 233, 309, 463, 617, 616,
110940
- /* 300 */ 590, 590, 590, 174, 272, 396, 409, 272, 409, 548,
110941
- /* 310 */ 397, 620, 619, 68, 326, 620, 619, 620, 619, 618,
110942
- /* 320 */ 546, 412, 618, 412, 471, 594, 587, 581, 472, 598,
110943
- /* 330 */ 92, 598, 92, 52, 52, 52, 51, 233, 513, 512,
110944
- /* 340 */ 206, 322, 363, 464, 221, 57, 58, 48, 579, 578,
110945
- /* 350 */ 580, 580, 55, 55, 56, 56, 56, 56, 529, 54,
111125
+ /* 140 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 223,
111126
+ /* 150 */ 540, 421, 170, 176, 138, 281, 384, 276, 383, 168,
111127
+ /* 160 */ 490, 552, 410, 669, 621, 620, 272, 439, 410, 439,
111128
+ /* 170 */ 551, 605, 67, 483, 508, 619, 600, 413, 588, 582,
111129
+ /* 180 */ 601, 484, 619, 413, 619, 599, 91, 440, 441, 440,
111130
+ /* 190 */ 336, 599, 73, 670, 222, 267, 481, 57, 58, 48,
111131
+ /* 200 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
111132
+ /* 210 */ 671, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111133
+ /* 220 */ 51, 233, 310, 280, 232, 231, 1, 132, 200, 386,
111134
+ /* 230 */ 621, 620, 618, 617, 279, 436, 290, 564, 175, 263,
111135
+ /* 240 */ 410, 265, 438, 498, 437, 166, 442, 569, 337, 569,
111136
+ /* 250 */ 201, 538, 588, 582, 600, 413, 165, 595, 601, 381,
111137
+ /* 260 */ 378, 377, 598, 599, 92, 524, 619, 570, 570, 593,
111138
+ /* 270 */ 376, 57, 58, 48, 580, 579, 581, 581, 55, 55,
111139
+ /* 280 */ 56, 56, 56, 56, 598, 54, 54, 54, 54, 53,
111140
+ /* 290 */ 53, 52, 52, 52, 51, 233, 310, 464, 618, 617,
111141
+ /* 300 */ 591, 591, 591, 174, 273, 397, 410, 273, 410, 549,
111142
+ /* 310 */ 398, 621, 620, 68, 327, 621, 620, 621, 620, 619,
111143
+ /* 320 */ 547, 413, 619, 413, 472, 595, 588, 582, 473, 599,
111144
+ /* 330 */ 92, 599, 92, 52, 52, 52, 51, 233, 514, 513,
111145
+ /* 340 */ 206, 323, 364, 465, 221, 57, 58, 48, 580, 579,
111146
+ /* 350 */ 581, 581, 55, 55, 56, 56, 56, 56, 530, 54,
110946111147
/* 360 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
110947
- /* 370 */ 309, 396, 409, 396, 597, 372, 386, 530, 347, 617,
110948
- /* 380 */ 616, 575, 202, 617, 616, 617, 616, 412, 620, 619,
110949
- /* 390 */ 145, 255, 346, 254, 577, 598, 74, 351, 45, 489,
110950
- /* 400 */ 587, 581, 235, 189, 464, 544, 167, 296, 187, 469,
110951
- /* 410 */ 479, 67, 62, 39, 618, 546, 597, 345, 573, 57,
110952
- /* 420 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56,
111148
+ /* 370 */ 310, 397, 410, 397, 598, 373, 387, 531, 348, 618,
111149
+ /* 380 */ 617, 576, 202, 618, 617, 618, 617, 413, 621, 620,
111150
+ /* 390 */ 145, 255, 347, 254, 578, 599, 74, 352, 45, 490,
111151
+ /* 400 */ 588, 582, 235, 189, 465, 545, 167, 297, 187, 470,
111152
+ /* 410 */ 480, 67, 62, 39, 619, 547, 598, 346, 574, 57,
111153
+ /* 420 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
110953111154
/* 430 */ 56, 56, 6, 54, 54, 54, 54, 53, 53, 52,
110954
- /* 440 */ 52, 52, 51, 233, 309, 562, 558, 407, 528, 576,
110955
- /* 450 */ 576, 344, 255, 346, 254, 182, 617, 616, 503, 504,
110956
- /* 460 */ 314, 409, 557, 235, 166, 271, 409, 352, 564, 181,
110957
- /* 470 */ 407, 546, 576, 576, 587, 581, 412, 537, 556, 561,
110958
- /* 480 */ 517, 412, 618, 249, 598, 16, 7, 36, 467, 598,
110959
- /* 490 */ 92, 516, 618, 57, 58, 48, 579, 578, 580, 580,
110960
- /* 500 */ 55, 55, 56, 56, 56, 56, 541, 54, 54, 54,
110961
- /* 510 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 327,
110962
- /* 520 */ 572, 571, 525, 558, 560, 394, 871, 246, 409, 248,
110963
- /* 530 */ 171, 392, 594, 219, 407, 409, 576, 576, 502, 557,
110964
- /* 540 */ 364, 145, 510, 412, 407, 229, 576, 576, 587, 581,
110965
- /* 550 */ 412, 598, 92, 381, 269, 556, 166, 400, 598, 69,
110966
- /* 560 */ 501, 419, 945, 199, 945, 198, 546, 57, 58, 48,
110967
- /* 570 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56,
110968
- /* 580 */ 568, 54, 54, 54, 54, 53, 53, 52, 52, 52,
110969
- /* 590 */ 51, 233, 309, 317, 419, 944, 508, 944, 308, 597,
110970
- /* 600 */ 594, 565, 490, 212, 173, 247, 423, 615, 614, 613,
110971
- /* 610 */ 323, 197, 143, 405, 572, 571, 489, 66, 50, 47,
110972
- /* 620 */ 146, 594, 587, 581, 232, 231, 559, 427, 67, 555,
110973
- /* 630 */ 15, 618, 186, 543, 303, 421, 35, 206, 432, 423,
110974
- /* 640 */ 552, 57, 58, 48, 579, 578, 580, 580, 55, 55,
111155
+ /* 440 */ 52, 52, 51, 233, 310, 563, 559, 408, 529, 577,
111156
+ /* 450 */ 577, 345, 255, 347, 254, 182, 618, 617, 504, 505,
111157
+ /* 460 */ 315, 410, 558, 235, 166, 272, 410, 353, 565, 181,
111158
+ /* 470 */ 408, 547, 577, 577, 588, 582, 413, 538, 557, 562,
111159
+ /* 480 */ 518, 413, 619, 249, 599, 16, 7, 36, 468, 599,
111160
+ /* 490 */ 92, 517, 619, 57, 58, 48, 580, 579, 581, 581,
111161
+ /* 500 */ 55, 55, 56, 56, 56, 56, 542, 54, 54, 54,
111162
+ /* 510 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 328,
111163
+ /* 520 */ 573, 572, 526, 559, 561, 395, 872, 246, 410, 248,
111164
+ /* 530 */ 171, 393, 595, 219, 408, 410, 577, 577, 503, 558,
111165
+ /* 540 */ 365, 145, 511, 413, 408, 229, 577, 577, 588, 582,
111166
+ /* 550 */ 413, 599, 92, 382, 270, 557, 166, 401, 599, 69,
111167
+ /* 560 */ 502, 420, 946, 199, 946, 198, 547, 57, 58, 48,
111168
+ /* 570 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
111169
+ /* 580 */ 569, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111170
+ /* 590 */ 51, 233, 310, 318, 420, 945, 509, 945, 309, 598,
111171
+ /* 600 */ 595, 566, 491, 212, 173, 247, 424, 616, 615, 614,
111172
+ /* 610 */ 324, 197, 143, 406, 573, 572, 490, 66, 50, 47,
111173
+ /* 620 */ 146, 595, 588, 582, 232, 231, 560, 428, 67, 556,
111174
+ /* 630 */ 15, 619, 186, 544, 304, 422, 35, 206, 433, 424,
111175
+ /* 640 */ 553, 57, 58, 48, 580, 579, 581, 581, 55, 55,
110975111176
/* 650 */ 56, 56, 56, 56, 205, 54, 54, 54, 54, 53,
110976
- /* 660 */ 53, 52, 52, 52, 51, 233, 309, 569, 569, 260,
110977
- /* 670 */ 268, 597, 12, 373, 568, 166, 409, 313, 409, 420,
110978
- /* 680 */ 409, 473, 473, 365, 618, 50, 47, 146, 597, 594,
110979
- /* 690 */ 468, 412, 166, 412, 351, 412, 587, 581, 32, 598,
110980
- /* 700 */ 94, 598, 97, 598, 95, 627, 625, 329, 142, 50,
110981
- /* 710 */ 47, 146, 333, 349, 358, 57, 58, 48, 579, 578,
110982
- /* 720 */ 580, 580, 55, 55, 56, 56, 56, 56, 409, 54,
111177
+ /* 660 */ 53, 52, 52, 52, 51, 233, 310, 570, 570, 261,
111178
+ /* 670 */ 269, 598, 12, 374, 569, 166, 410, 314, 410, 421,
111179
+ /* 680 */ 410, 474, 474, 366, 619, 50, 47, 146, 598, 595,
111180
+ /* 690 */ 256, 413, 166, 413, 352, 413, 588, 582, 32, 599,
111181
+ /* 700 */ 94, 599, 97, 599, 95, 628, 626, 330, 142, 50,
111182
+ /* 710 */ 47, 146, 334, 350, 359, 57, 58, 48, 580, 579,
111183
+ /* 720 */ 581, 581, 55, 55, 56, 56, 56, 56, 410, 54,
110983111184
/* 730 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
110984
- /* 740 */ 309, 409, 388, 412, 409, 22, 565, 404, 212, 362,
110985
- /* 750 */ 389, 598, 104, 359, 409, 156, 412, 409, 603, 412,
110986
- /* 760 */ 537, 331, 569, 569, 598, 103, 493, 598, 105, 412,
110987
- /* 770 */ 587, 581, 412, 260, 549, 618, 11, 598, 106, 521,
110988
- /* 780 */ 598, 133, 169, 457, 456, 170, 35, 601, 618, 57,
110989
- /* 790 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56,
110990
- /* 800 */ 56, 56, 409, 54, 54, 54, 54, 53, 53, 52,
110991
- /* 810 */ 52, 52, 51, 233, 309, 409, 259, 412, 409, 50,
110992
- /* 820 */ 47, 146, 357, 318, 355, 598, 134, 527, 352, 337,
110993
- /* 830 */ 412, 409, 356, 412, 357, 409, 357, 618, 598, 98,
110994
- /* 840 */ 129, 598, 102, 618, 587, 581, 412, 21, 235, 618,
110995
- /* 850 */ 412, 618, 211, 143, 598, 101, 30, 167, 598, 93,
110996
- /* 860 */ 350, 535, 203, 57, 58, 48, 579, 578, 580, 580,
110997
- /* 870 */ 55, 55, 56, 56, 56, 56, 409, 54, 54, 54,
110998
- /* 880 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 409,
110999
- /* 890 */ 526, 412, 409, 425, 215, 305, 597, 551, 141, 598,
111000
- /* 900 */ 100, 40, 409, 38, 412, 409, 550, 412, 409, 228,
111001
- /* 910 */ 220, 314, 598, 77, 500, 598, 96, 412, 587, 581,
111002
- /* 920 */ 412, 338, 253, 412, 218, 598, 137, 379, 598, 136,
111003
- /* 930 */ 28, 598, 135, 270, 715, 210, 481, 57, 58, 48,
111004
- /* 940 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56,
111005
- /* 950 */ 409, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111006
- /* 960 */ 51, 233, 309, 409, 272, 412, 409, 315, 147, 597,
111007
- /* 970 */ 272, 626, 2, 598, 76, 209, 409, 127, 412, 618,
111008
- /* 980 */ 126, 412, 409, 621, 235, 618, 598, 90, 374, 598,
111009
- /* 990 */ 89, 412, 587, 581, 27, 260, 350, 412, 618, 598,
111010
- /* 1000 */ 75, 321, 541, 541, 125, 598, 88, 320, 278, 597,
111011
- /* 1010 */ 618, 57, 46, 48, 579, 578, 580, 580, 55, 55,
111012
- /* 1020 */ 56, 56, 56, 56, 409, 54, 54, 54, 54, 53,
111013
- /* 1030 */ 53, 52, 52, 52, 51, 233, 309, 409, 450, 412,
111014
- /* 1040 */ 164, 284, 282, 272, 609, 424, 304, 598, 87, 370,
111015
- /* 1050 */ 409, 477, 412, 409, 608, 409, 607, 602, 618, 618,
111016
- /* 1060 */ 598, 99, 586, 585, 122, 412, 587, 581, 412, 618,
111017
- /* 1070 */ 412, 618, 618, 598, 86, 366, 598, 17, 598, 85,
111018
- /* 1080 */ 319, 185, 519, 518, 583, 582, 58, 48, 579, 578,
111019
- /* 1090 */ 580, 580, 55, 55, 56, 56, 56, 56, 409, 54,
111185
+ /* 740 */ 310, 410, 389, 413, 410, 22, 566, 405, 212, 363,
111186
+ /* 750 */ 390, 599, 104, 360, 410, 156, 413, 410, 604, 413,
111187
+ /* 760 */ 538, 332, 570, 570, 599, 103, 494, 599, 105, 413,
111188
+ /* 770 */ 588, 582, 413, 261, 550, 619, 11, 599, 106, 522,
111189
+ /* 780 */ 599, 133, 169, 458, 457, 170, 35, 602, 619, 57,
111190
+ /* 790 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
111191
+ /* 800 */ 56, 56, 410, 54, 54, 54, 54, 53, 53, 52,
111192
+ /* 810 */ 52, 52, 51, 233, 310, 410, 260, 413, 410, 50,
111193
+ /* 820 */ 47, 146, 358, 319, 356, 599, 134, 528, 353, 338,
111194
+ /* 830 */ 413, 410, 357, 413, 358, 410, 358, 619, 599, 98,
111195
+ /* 840 */ 129, 599, 102, 619, 588, 582, 413, 21, 235, 619,
111196
+ /* 850 */ 413, 619, 211, 143, 599, 101, 30, 167, 599, 93,
111197
+ /* 860 */ 351, 536, 203, 57, 58, 48, 580, 579, 581, 581,
111198
+ /* 870 */ 55, 55, 56, 56, 56, 56, 410, 54, 54, 54,
111199
+ /* 880 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 410,
111200
+ /* 890 */ 527, 413, 410, 426, 215, 306, 598, 552, 141, 599,
111201
+ /* 900 */ 100, 40, 410, 38, 413, 410, 551, 413, 410, 228,
111202
+ /* 910 */ 220, 315, 599, 77, 501, 599, 96, 413, 588, 582,
111203
+ /* 920 */ 413, 339, 253, 413, 218, 599, 137, 380, 599, 136,
111204
+ /* 930 */ 28, 599, 135, 271, 716, 210, 482, 57, 58, 48,
111205
+ /* 940 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
111206
+ /* 950 */ 410, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111207
+ /* 960 */ 51, 233, 310, 410, 273, 413, 410, 316, 147, 598,
111208
+ /* 970 */ 273, 627, 2, 599, 76, 209, 410, 127, 413, 619,
111209
+ /* 980 */ 126, 413, 410, 622, 235, 619, 599, 90, 375, 599,
111210
+ /* 990 */ 89, 413, 588, 582, 27, 261, 351, 413, 619, 599,
111211
+ /* 1000 */ 75, 322, 542, 542, 125, 599, 88, 321, 279, 598,
111212
+ /* 1010 */ 619, 57, 46, 48, 580, 579, 581, 581, 55, 55,
111213
+ /* 1020 */ 56, 56, 56, 56, 410, 54, 54, 54, 54, 53,
111214
+ /* 1030 */ 53, 52, 52, 52, 51, 233, 310, 410, 451, 413,
111215
+ /* 1040 */ 164, 285, 283, 273, 610, 425, 305, 599, 87, 371,
111216
+ /* 1050 */ 410, 478, 413, 410, 609, 410, 608, 603, 619, 619,
111217
+ /* 1060 */ 599, 99, 587, 586, 122, 413, 588, 582, 413, 619,
111218
+ /* 1070 */ 413, 619, 619, 599, 86, 367, 599, 17, 599, 85,
111219
+ /* 1080 */ 320, 185, 520, 519, 584, 583, 58, 48, 580, 579,
111220
+ /* 1090 */ 581, 581, 55, 55, 56, 56, 56, 56, 410, 54,
111020111221
/* 1100 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
111021
- /* 1110 */ 309, 584, 409, 412, 409, 260, 260, 260, 408, 591,
111022
- /* 1120 */ 474, 598, 84, 170, 409, 466, 518, 412, 121, 412,
111023
- /* 1130 */ 618, 618, 618, 618, 618, 598, 83, 598, 72, 412,
111024
- /* 1140 */ 587, 581, 51, 233, 625, 329, 470, 598, 71, 257,
111025
- /* 1150 */ 159, 120, 14, 462, 157, 158, 117, 260, 448, 447,
111026
- /* 1160 */ 446, 48, 579, 578, 580, 580, 55, 55, 56, 56,
111027
- /* 1170 */ 56, 56, 618, 54, 54, 54, 54, 53, 53, 52,
111028
- /* 1180 */ 52, 52, 51, 233, 44, 403, 260, 3, 409, 459,
111029
- /* 1190 */ 260, 413, 619, 118, 398, 10, 25, 24, 554, 348,
111030
- /* 1200 */ 217, 618, 406, 412, 409, 618, 4, 44, 403, 618,
111031
- /* 1210 */ 3, 598, 82, 618, 413, 619, 455, 542, 115, 412,
111032
- /* 1220 */ 538, 401, 536, 274, 506, 406, 251, 598, 81, 216,
111033
- /* 1230 */ 273, 563, 618, 243, 453, 618, 154, 618, 618, 618,
111034
- /* 1240 */ 449, 416, 623, 110, 401, 618, 409, 236, 64, 123,
111035
- /* 1250 */ 487, 41, 42, 531, 563, 204, 409, 267, 43, 411,
111036
- /* 1260 */ 410, 412, 265, 592, 108, 618, 107, 434, 332, 598,
111037
- /* 1270 */ 80, 412, 618, 263, 41, 42, 443, 618, 409, 598,
111038
- /* 1280 */ 70, 43, 411, 410, 433, 261, 592, 149, 618, 597,
111039
- /* 1290 */ 256, 237, 188, 412, 590, 590, 590, 589, 588, 13,
111040
- /* 1300 */ 618, 598, 18, 328, 235, 618, 44, 403, 360, 3,
111041
- /* 1310 */ 418, 461, 339, 413, 619, 227, 124, 590, 590, 590,
111042
- /* 1320 */ 589, 588, 13, 618, 406, 409, 618, 409, 139, 34,
111043
- /* 1330 */ 403, 387, 3, 148, 622, 312, 413, 619, 311, 330,
111044
- /* 1340 */ 412, 460, 412, 401, 180, 353, 412, 406, 598, 79,
111045
- /* 1350 */ 598, 78, 250, 563, 598, 9, 618, 612, 611, 610,
111046
- /* 1360 */ 618, 8, 452, 442, 242, 415, 401, 618, 239, 235,
111047
- /* 1370 */ 179, 238, 428, 41, 42, 288, 563, 618, 618, 618,
111048
- /* 1380 */ 43, 411, 410, 618, 144, 592, 618, 618, 177, 61,
111049
- /* 1390 */ 618, 596, 391, 620, 619, 287, 41, 42, 414, 618,
111050
- /* 1400 */ 293, 30, 393, 43, 411, 410, 292, 618, 592, 31,
111051
- /* 1410 */ 618, 395, 291, 60, 230, 37, 590, 590, 590, 589,
111052
- /* 1420 */ 588, 13, 214, 553, 183, 290, 172, 301, 300, 299,
111053
- /* 1430 */ 178, 297, 595, 563, 451, 29, 285, 390, 540, 590,
111054
- /* 1440 */ 590, 590, 589, 588, 13, 283, 520, 534, 150, 533,
111055
- /* 1450 */ 241, 281, 384, 192, 191, 324, 515, 514, 276, 240,
111056
- /* 1460 */ 510, 523, 307, 511, 128, 592, 509, 225, 226, 486,
111057
- /* 1470 */ 485, 224, 152, 491, 464, 306, 484, 163, 153, 371,
111058
- /* 1480 */ 478, 151, 162, 258, 369, 161, 367, 208, 475, 476,
111059
- /* 1490 */ 26, 160, 465, 140, 361, 131, 590, 590, 590, 116,
111060
- /* 1500 */ 119, 454, 343, 155, 114, 342, 113, 112, 445, 111,
111061
- /* 1510 */ 130, 109, 431, 316, 426, 430, 23, 429, 20, 606,
111062
- /* 1520 */ 190, 507, 255, 341, 244, 63, 294, 593, 310, 570,
111063
- /* 1530 */ 277, 402, 354, 235, 567, 496, 495, 492, 494, 302,
111064
- /* 1540 */ 458, 378, 286, 245, 566, 5, 252, 547, 193, 444,
111065
- /* 1550 */ 233, 340, 207, 524, 368, 505, 334, 522, 499, 399,
111066
- /* 1560 */ 295, 498, 956, 488,
111222
+ /* 1110 */ 310, 585, 410, 413, 410, 261, 261, 261, 409, 592,
111223
+ /* 1120 */ 475, 599, 84, 170, 410, 467, 519, 413, 121, 413,
111224
+ /* 1130 */ 619, 619, 619, 619, 619, 599, 83, 599, 72, 413,
111225
+ /* 1140 */ 588, 582, 51, 233, 626, 330, 471, 599, 71, 258,
111226
+ /* 1150 */ 159, 120, 14, 463, 157, 158, 117, 261, 449, 448,
111227
+ /* 1160 */ 447, 48, 580, 579, 581, 581, 55, 55, 56, 56,
111228
+ /* 1170 */ 56, 56, 619, 54, 54, 54, 54, 53, 53, 52,
111229
+ /* 1180 */ 52, 52, 51, 233, 44, 404, 261, 3, 410, 460,
111230
+ /* 1190 */ 261, 414, 620, 118, 399, 10, 25, 24, 555, 349,
111231
+ /* 1200 */ 217, 619, 407, 413, 410, 619, 4, 44, 404, 619,
111232
+ /* 1210 */ 3, 599, 82, 619, 414, 620, 456, 543, 115, 413,
111233
+ /* 1220 */ 539, 402, 537, 275, 507, 407, 251, 599, 81, 216,
111234
+ /* 1230 */ 274, 564, 619, 243, 454, 619, 154, 619, 619, 619,
111235
+ /* 1240 */ 450, 417, 624, 110, 402, 619, 410, 236, 64, 123,
111236
+ /* 1250 */ 488, 41, 42, 532, 564, 204, 410, 268, 43, 412,
111237
+ /* 1260 */ 411, 413, 266, 593, 108, 619, 107, 435, 333, 599,
111238
+ /* 1270 */ 80, 413, 619, 264, 41, 42, 444, 619, 410, 599,
111239
+ /* 1280 */ 70, 43, 412, 411, 434, 262, 593, 149, 619, 598,
111240
+ /* 1290 */ 257, 237, 188, 413, 591, 591, 591, 590, 589, 13,
111241
+ /* 1300 */ 619, 599, 18, 329, 235, 619, 44, 404, 361, 3,
111242
+ /* 1310 */ 419, 462, 340, 414, 620, 227, 124, 591, 591, 591,
111243
+ /* 1320 */ 590, 589, 13, 619, 407, 410, 619, 410, 139, 34,
111244
+ /* 1330 */ 404, 388, 3, 148, 623, 313, 414, 620, 312, 331,
111245
+ /* 1340 */ 413, 461, 413, 402, 180, 354, 413, 407, 599, 79,
111246
+ /* 1350 */ 599, 78, 250, 564, 599, 9, 619, 613, 612, 611,
111247
+ /* 1360 */ 619, 8, 453, 443, 242, 416, 402, 619, 239, 235,
111248
+ /* 1370 */ 179, 238, 429, 41, 42, 289, 564, 619, 619, 619,
111249
+ /* 1380 */ 43, 412, 411, 619, 144, 593, 619, 619, 177, 61,
111250
+ /* 1390 */ 619, 597, 392, 621, 620, 288, 41, 42, 415, 619,
111251
+ /* 1400 */ 294, 30, 394, 43, 412, 411, 293, 619, 593, 31,
111252
+ /* 1410 */ 619, 396, 292, 60, 230, 37, 591, 591, 591, 590,
111253
+ /* 1420 */ 589, 13, 214, 554, 183, 291, 172, 302, 301, 300,
111254
+ /* 1430 */ 178, 298, 596, 564, 452, 29, 286, 391, 541, 591,
111255
+ /* 1440 */ 591, 591, 590, 589, 13, 284, 521, 535, 150, 534,
111256
+ /* 1450 */ 241, 282, 385, 192, 191, 325, 516, 515, 277, 240,
111257
+ /* 1460 */ 511, 524, 308, 512, 128, 593, 510, 225, 226, 487,
111258
+ /* 1470 */ 486, 224, 152, 492, 465, 307, 485, 163, 153, 372,
111259
+ /* 1480 */ 479, 151, 162, 259, 370, 161, 368, 208, 476, 477,
111260
+ /* 1490 */ 26, 160, 469, 466, 362, 140, 591, 591, 591, 116,
111261
+ /* 1500 */ 119, 455, 344, 155, 114, 343, 113, 112, 446, 111,
111262
+ /* 1510 */ 131, 109, 432, 317, 130, 431, 23, 20, 430, 427,
111263
+ /* 1520 */ 190, 63, 255, 342, 244, 607, 295, 287, 311, 594,
111264
+ /* 1530 */ 278, 508, 496, 235, 493, 571, 497, 568, 495, 403,
111265
+ /* 1540 */ 459, 379, 355, 245, 193, 303, 567, 296, 341, 5,
111266
+ /* 1550 */ 445, 548, 506, 207, 525, 500, 335, 489, 252, 369,
111267
+ /* 1560 */ 400, 499, 523, 233,
111067111268
};
111068111269
static const YYCODETYPE yy_lookahead[] = {
111069111270
/* 0 */ 19, 142, 143, 144, 145, 24, 1, 26, 77, 78,
111070111271
/* 10 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
111071111272
/* 20 */ 89, 90, 91, 92, 26, 27, 15, 26, 27, 197,
@@ -111213,21 +111414,21 @@
111213111414
/* 1440 */ 130, 131, 132, 133, 134, 210, 175, 211, 31, 211,
111214111415
/* 1450 */ 33, 210, 104, 86, 87, 47, 175, 183, 175, 42,
111215111416
/* 1460 */ 103, 94, 178, 177, 22, 98, 175, 92, 228, 175,
111216111417
/* 1470 */ 175, 228, 55, 183, 57, 178, 175, 156, 61, 18,
111217111418
/* 1480 */ 157, 64, 156, 235, 157, 156, 45, 157, 236, 157,
111218
- /* 1490 */ 135, 156, 189, 68, 157, 218, 129, 130, 131, 22,
111419
+ /* 1490 */ 135, 156, 199, 189, 157, 68, 129, 130, 131, 22,
111219111420
/* 1500 */ 189, 199, 157, 156, 192, 18, 192, 192, 199, 192,
111220
- /* 1510 */ 218, 189, 40, 157, 38, 157, 240, 157, 240, 153,
111221
- /* 1520 */ 196, 181, 105, 106, 107, 243, 198, 166, 111, 230,
111222
- /* 1530 */ 176, 226, 239, 116, 230, 176, 166, 166, 176, 148,
111223
- /* 1540 */ 199, 177, 209, 209, 166, 196, 239, 208, 185, 199,
111224
- /* 1550 */ 92, 209, 233, 173, 234, 182, 139, 173, 182, 191,
111225
- /* 1560 */ 195, 182, 250, 186,
111421
+ /* 1510 */ 218, 189, 40, 157, 218, 157, 240, 240, 157, 38,
111422
+ /* 1520 */ 196, 243, 105, 106, 107, 153, 198, 209, 111, 166,
111423
+ /* 1530 */ 176, 181, 166, 116, 166, 230, 176, 230, 176, 226,
111424
+ /* 1540 */ 199, 177, 239, 209, 185, 148, 166, 195, 209, 196,
111425
+ /* 1550 */ 199, 208, 182, 233, 173, 182, 139, 186, 239, 234,
111426
+ /* 1560 */ 191, 182, 173, 92,
111226111427
};
111227111428
#define YY_SHIFT_USE_DFLT (-70)
111228
-#define YY_SHIFT_COUNT (416)
111429
+#define YY_SHIFT_COUNT (417)
111229111430
#define YY_SHIFT_MIN (-69)
111230111431
#define YY_SHIFT_MAX (1487)
111231111432
static const short yy_shift_ofst[] = {
111232111433
/* 0 */ 1143, 1188, 1417, 1188, 1287, 1287, 138, 138, -2, -19,
111233111434
/* 10 */ 1287, 1287, 1287, 1287, 347, 362, 129, 129, 795, 1165,
@@ -111240,44 +111441,44 @@
111240111441
/* 80 */ 869, 869, 869, 869, 869, 869, 869, 869, 869, 869,
111241111442
/* 90 */ 869, 869, 869, 943, 869, 1017, 1091, 1091, -69, -45,
111242111443
/* 100 */ -45, -45, -45, -45, -1, 24, 245, 362, 362, 362,
111243111444
/* 110 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111244111445
/* 120 */ 362, 362, 362, 388, 356, 362, 362, 362, 362, 362,
111245
- /* 130 */ 732, 868, 231, 1051, 1458, -70, -70, -70, 1367, 57,
111446
+ /* 130 */ 732, 868, 231, 1051, 1471, -70, -70, -70, 1367, 57,
111246111447
/* 140 */ 434, 434, 289, 291, 285, 1, 204, 572, 539, 362,
111247111448
/* 150 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111248111449
/* 160 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111249111450
/* 170 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111250111451
/* 180 */ 362, 506, 506, 506, 705, 1253, 1253, 1253, -70, -70,
111251111452
/* 190 */ -70, 171, 171, 160, 502, 502, 502, 446, 432, 511,
111252111453
/* 200 */ 422, 358, 335, -12, -12, -12, -12, 576, 294, -12,
111253111454
/* 210 */ -12, 295, 595, 141, 600, 730, 723, 723, 805, 730,
111254111455
/* 220 */ 805, 439, 911, 231, 865, 231, 865, 807, 865, 723,
111255
- /* 230 */ 766, 633, 633, 231, 284, 63, 608, 1476, 1308, 1308,
111256
- /* 240 */ 1472, 1472, 1308, 1477, 1425, 1275, 1487, 1487, 1487, 1487,
111257
- /* 250 */ 1308, 1461, 1275, 1477, 1425, 1425, 1308, 1461, 1355, 1441,
111258
- /* 260 */ 1308, 1308, 1461, 1308, 1461, 1308, 1461, 1442, 1348, 1348,
111259
- /* 270 */ 1348, 1408, 1375, 1375, 1442, 1348, 1357, 1348, 1408, 1348,
111260
- /* 280 */ 1348, 1316, 1331, 1316, 1331, 1316, 1331, 1308, 1308, 1280,
111261
- /* 290 */ 1288, 1289, 1285, 1279, 1275, 1253, 1336, 1346, 1346, 1338,
111262
- /* 300 */ 1338, 1338, 1338, -70, -70, -70, -70, -70, -70, 1013,
111263
- /* 310 */ 467, 612, 84, 179, -28, 870, 410, 761, 760, 667,
111264
- /* 320 */ 650, 531, 220, 361, 331, 125, 127, 97, 1306, 1300,
111265
- /* 330 */ 1270, 1151, 1272, 1203, 1232, 1261, 1244, 1148, 1174, 1139,
111266
- /* 340 */ 1156, 1124, 1220, 1115, 1210, 1233, 1099, 1193, 1184, 1174,
111267
- /* 350 */ 1173, 1029, 1121, 1120, 1085, 1162, 1119, 1037, 1152, 1147,
111268
- /* 360 */ 1129, 1046, 1011, 1093, 1098, 1075, 1061, 1032, 960, 1057,
111269
- /* 370 */ 1031, 1030, 899, 938, 982, 936, 972, 958, 910, 955,
111270
- /* 380 */ 875, 885, 908, 857, 859, 867, 804, 590, 834, 747,
111271
- /* 390 */ 818, 513, 611, 741, 673, 637, 611, 606, 603, 579,
111272
- /* 400 */ 501, 541, 468, 386, 445, 395, 376, 281, 185, 120,
111273
- /* 410 */ 92, 75, 45, 114, 25, 11, 5,
111456
+ /* 230 */ 766, 633, 633, 231, 284, 63, 608, 1481, 1308, 1308,
111457
+ /* 240 */ 1472, 1472, 1308, 1477, 1427, 1275, 1487, 1487, 1487, 1487,
111458
+ /* 250 */ 1308, 1461, 1275, 1477, 1427, 1427, 1275, 1308, 1461, 1355,
111459
+ /* 260 */ 1441, 1308, 1308, 1461, 1308, 1461, 1308, 1461, 1442, 1348,
111460
+ /* 270 */ 1348, 1348, 1408, 1375, 1375, 1442, 1348, 1357, 1348, 1408,
111461
+ /* 280 */ 1348, 1348, 1316, 1331, 1316, 1331, 1316, 1331, 1308, 1308,
111462
+ /* 290 */ 1280, 1288, 1289, 1285, 1279, 1275, 1253, 1336, 1346, 1346,
111463
+ /* 300 */ 1338, 1338, 1338, 1338, -70, -70, -70, -70, -70, -70,
111464
+ /* 310 */ 1013, 467, 612, 84, 179, -28, 870, 410, 761, 760,
111465
+ /* 320 */ 667, 650, 531, 220, 361, 331, 125, 127, 97, 1306,
111466
+ /* 330 */ 1300, 1270, 1151, 1272, 1203, 1232, 1261, 1244, 1148, 1174,
111467
+ /* 340 */ 1139, 1156, 1124, 1220, 1115, 1210, 1233, 1099, 1193, 1184,
111468
+ /* 350 */ 1174, 1173, 1029, 1121, 1120, 1085, 1162, 1119, 1037, 1152,
111469
+ /* 360 */ 1147, 1129, 1046, 1011, 1093, 1098, 1075, 1061, 1032, 960,
111470
+ /* 370 */ 1057, 1031, 1030, 899, 938, 982, 936, 972, 958, 910,
111471
+ /* 380 */ 955, 875, 885, 908, 857, 859, 867, 804, 590, 834,
111472
+ /* 390 */ 747, 818, 513, 611, 741, 673, 637, 611, 606, 603,
111473
+ /* 400 */ 579, 501, 541, 468, 386, 445, 395, 376, 281, 185,
111474
+ /* 410 */ 120, 92, 75, 45, 114, 25, 11, 5,
111274111475
};
111275111476
#define YY_REDUCE_USE_DFLT (-169)
111276
-#define YY_REDUCE_COUNT (308)
111477
+#define YY_REDUCE_COUNT (309)
111277111478
#define YY_REDUCE_MIN (-168)
111278
-#define YY_REDUCE_MAX (1391)
111479
+#define YY_REDUCE_MAX (1397)
111279111480
static const short yy_reduce_ofst[] = {
111280111481
/* 0 */ -141, 90, 1095, 222, 158, 156, 19, 17, 10, -104,
111281111482
/* 10 */ 378, 316, 311, 12, 180, 249, 598, 464, 397, 1181,
111282111483
/* 20 */ 1177, 1175, 1128, 1106, 1096, 1054, 1038, 974, 964, 962,
111283111484
/* 30 */ 948, 905, 903, 900, 887, 874, 832, 826, 816, 813,
@@ -111294,87 +111495,87 @@
111294111495
/* 140 */ 935, 892, 968, 1245, 1242, 1234, 1225, 798, 798, 1222,
111295111496
/* 150 */ 1221, 1218, 1214, 1213, 1212, 1202, 1195, 1191, 1161, 1158,
111296111497
/* 160 */ 1140, 1135, 1123, 1112, 1107, 1100, 1080, 1074, 1073, 1072,
111297111498
/* 170 */ 1070, 1067, 1048, 1044, 969, 968, 907, 906, 904, 894,
111298111499
/* 180 */ 833, 837, 836, 340, 827, 815, 775, 68, 722, 646,
111299
- /* 190 */ -168, 1384, 1380, 1377, 1379, 1376, 1373, 1339, 1365, 1368,
111300
- /* 200 */ 1365, 1365, 1365, 1365, 1365, 1365, 1365, 1320, 1319, 1365,
111301
- /* 210 */ 1365, 1339, 1378, 1349, 1391, 1350, 1342, 1334, 1307, 1341,
111302
- /* 220 */ 1293, 1364, 1363, 1371, 1362, 1370, 1359, 1340, 1354, 1333,
111303
- /* 230 */ 1305, 1304, 1299, 1361, 1328, 1324, 1366, 1282, 1360, 1358,
111304
- /* 240 */ 1278, 1276, 1356, 1292, 1322, 1309, 1317, 1315, 1314, 1312,
111305
- /* 250 */ 1345, 1347, 1302, 1277, 1311, 1303, 1337, 1335, 1252, 1248,
111306
- /* 260 */ 1332, 1330, 1329, 1327, 1326, 1323, 1321, 1297, 1301, 1295,
111307
- /* 270 */ 1294, 1290, 1243, 1240, 1284, 1291, 1286, 1283, 1274, 1281,
111308
- /* 280 */ 1271, 1238, 1241, 1236, 1235, 1227, 1226, 1267, 1266, 1189,
111309
- /* 290 */ 1229, 1223, 1211, 1206, 1201, 1197, 1239, 1237, 1219, 1216,
111310
- /* 300 */ 1209, 1208, 1185, 1089, 1086, 1087, 1137, 1136, 1164,
111500
+ /* 190 */ -168, 1389, 1381, 1371, 1379, 1373, 1370, 1343, 1352, 1369,
111501
+ /* 200 */ 1352, 1352, 1352, 1352, 1352, 1352, 1352, 1325, 1320, 1352,
111502
+ /* 210 */ 1352, 1343, 1380, 1353, 1397, 1351, 1339, 1334, 1319, 1341,
111503
+ /* 220 */ 1303, 1364, 1359, 1368, 1362, 1366, 1360, 1350, 1354, 1318,
111504
+ /* 230 */ 1313, 1307, 1305, 1363, 1328, 1324, 1372, 1278, 1361, 1358,
111505
+ /* 240 */ 1277, 1276, 1356, 1296, 1322, 1309, 1317, 1315, 1314, 1312,
111506
+ /* 250 */ 1345, 1347, 1302, 1292, 1311, 1304, 1293, 1337, 1335, 1252,
111507
+ /* 260 */ 1248, 1332, 1330, 1329, 1327, 1326, 1323, 1321, 1297, 1301,
111508
+ /* 270 */ 1295, 1294, 1290, 1243, 1240, 1284, 1291, 1286, 1283, 1274,
111509
+ /* 280 */ 1281, 1271, 1238, 1241, 1236, 1235, 1227, 1226, 1267, 1266,
111510
+ /* 290 */ 1189, 1229, 1223, 1211, 1206, 1201, 1197, 1239, 1237, 1219,
111511
+ /* 300 */ 1216, 1209, 1208, 1185, 1089, 1086, 1087, 1137, 1136, 1164,
111311111512
};
111312111513
static const YYACTIONTYPE yy_default[] = {
111313
- /* 0 */ 632, 866, 954, 954, 866, 866, 954, 954, 954, 756,
111314
- /* 10 */ 954, 954, 954, 864, 954, 954, 784, 784, 928, 954,
111315
- /* 20 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111316
- /* 30 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111317
- /* 40 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111318
- /* 50 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111319
- /* 60 */ 954, 954, 954, 954, 954, 954, 954, 671, 760, 790,
111320
- /* 70 */ 954, 954, 954, 954, 954, 954, 954, 954, 927, 929,
111321
- /* 80 */ 798, 797, 907, 771, 795, 788, 792, 867, 860, 861,
111322
- /* 90 */ 859, 863, 868, 954, 791, 827, 844, 826, 838, 843,
111323
- /* 100 */ 850, 842, 839, 829, 828, 830, 831, 954, 954, 954,
111324
- /* 110 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111325
- /* 120 */ 954, 954, 954, 658, 725, 954, 954, 954, 954, 954,
111326
- /* 130 */ 954, 954, 954, 832, 833, 847, 846, 845, 954, 663,
111327
- /* 140 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111328
- /* 150 */ 934, 932, 954, 879, 954, 954, 954, 954, 954, 954,
111329
- /* 160 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111330
- /* 170 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111331
- /* 180 */ 638, 756, 756, 756, 632, 954, 954, 954, 946, 760,
111332
- /* 190 */ 750, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111333
- /* 200 */ 954, 954, 954, 800, 739, 917, 919, 954, 900, 737,
111334
- /* 210 */ 660, 758, 673, 748, 640, 794, 773, 773, 912, 794,
111335
- /* 220 */ 912, 696, 719, 954, 784, 954, 784, 693, 784, 773,
111336
- /* 230 */ 862, 954, 954, 954, 757, 748, 954, 939, 764, 764,
111337
- /* 240 */ 931, 931, 764, 806, 729, 794, 736, 736, 736, 736,
111338
- /* 250 */ 764, 655, 794, 806, 729, 729, 764, 655, 906, 904,
111339
- /* 260 */ 764, 764, 655, 764, 655, 764, 655, 872, 727, 727,
111340
- /* 270 */ 727, 711, 876, 876, 872, 727, 696, 727, 711, 727,
111341
- /* 280 */ 727, 777, 772, 777, 772, 777, 772, 764, 764, 954,
111342
- /* 290 */ 789, 778, 787, 785, 794, 954, 714, 648, 648, 637,
111343
- /* 300 */ 637, 637, 637, 951, 951, 946, 698, 698, 681, 954,
111344
- /* 310 */ 954, 954, 954, 954, 954, 954, 881, 954, 954, 954,
111345
- /* 320 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 633,
111346
- /* 330 */ 941, 954, 954, 938, 954, 954, 954, 954, 799, 954,
111347
- /* 340 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 916,
111348
- /* 350 */ 954, 954, 954, 954, 954, 954, 954, 910, 954, 954,
111349
- /* 360 */ 954, 954, 954, 954, 903, 902, 954, 954, 954, 954,
111350
- /* 370 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111351
- /* 380 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111352
- /* 390 */ 954, 954, 786, 954, 779, 954, 865, 954, 954, 954,
111353
- /* 400 */ 954, 954, 954, 954, 954, 954, 954, 742, 815, 954,
111354
- /* 410 */ 814, 818, 813, 665, 954, 646, 954, 629, 634, 950,
111355
- /* 420 */ 953, 952, 949, 948, 947, 942, 940, 937, 936, 935,
111356
- /* 430 */ 933, 930, 926, 885, 883, 890, 889, 888, 887, 886,
111357
- /* 440 */ 884, 882, 880, 801, 796, 793, 925, 878, 738, 735,
111358
- /* 450 */ 734, 654, 943, 909, 918, 805, 804, 807, 915, 914,
111359
- /* 460 */ 913, 911, 908, 895, 803, 802, 730, 870, 869, 657,
111360
- /* 470 */ 899, 898, 897, 901, 905, 896, 766, 656, 653, 662,
111361
- /* 480 */ 717, 718, 726, 724, 723, 722, 721, 720, 716, 664,
111362
- /* 490 */ 672, 710, 695, 694, 875, 877, 874, 873, 703, 702,
111363
- /* 500 */ 708, 707, 706, 705, 704, 701, 700, 699, 692, 691,
111364
- /* 510 */ 697, 690, 713, 712, 709, 689, 733, 732, 731, 728,
111365
- /* 520 */ 688, 687, 686, 818, 685, 684, 824, 823, 811, 854,
111366
- /* 530 */ 753, 752, 751, 763, 762, 775, 774, 809, 808, 776,
111367
- /* 540 */ 761, 755, 754, 770, 769, 768, 767, 759, 749, 781,
111368
- /* 550 */ 783, 782, 780, 856, 765, 853, 924, 923, 922, 921,
111369
- /* 560 */ 920, 858, 857, 825, 822, 676, 677, 893, 892, 894,
111370
- /* 570 */ 891, 679, 678, 675, 674, 855, 744, 743, 851, 848,
111371
- /* 580 */ 840, 836, 852, 849, 841, 837, 835, 834, 820, 819,
111372
- /* 590 */ 817, 816, 812, 821, 667, 745, 741, 740, 810, 747,
111373
- /* 600 */ 746, 683, 682, 680, 661, 659, 652, 650, 649, 651,
111374
- /* 610 */ 647, 645, 644, 643, 642, 641, 670, 669, 668, 666,
111375
- /* 620 */ 665, 639, 636, 635, 631, 630, 628,
111514
+ /* 0 */ 633, 867, 955, 955, 867, 867, 955, 955, 955, 757,
111515
+ /* 10 */ 955, 955, 955, 865, 955, 955, 785, 785, 929, 955,
111516
+ /* 20 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111517
+ /* 30 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111518
+ /* 40 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111519
+ /* 50 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111520
+ /* 60 */ 955, 955, 955, 955, 955, 955, 955, 672, 761, 791,
111521
+ /* 70 */ 955, 955, 955, 955, 955, 955, 955, 955, 928, 930,
111522
+ /* 80 */ 799, 798, 908, 772, 796, 789, 793, 868, 861, 862,
111523
+ /* 90 */ 860, 864, 869, 955, 792, 828, 845, 827, 839, 844,
111524
+ /* 100 */ 851, 843, 840, 830, 829, 831, 832, 955, 955, 955,
111525
+ /* 110 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111526
+ /* 120 */ 955, 955, 955, 659, 726, 955, 955, 955, 955, 955,
111527
+ /* 130 */ 955, 955, 955, 833, 834, 848, 847, 846, 955, 664,
111528
+ /* 140 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111529
+ /* 150 */ 935, 933, 955, 880, 955, 955, 955, 955, 955, 955,
111530
+ /* 160 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111531
+ /* 170 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111532
+ /* 180 */ 639, 757, 757, 757, 633, 955, 955, 955, 947, 761,
111533
+ /* 190 */ 751, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111534
+ /* 200 */ 955, 955, 955, 801, 740, 918, 920, 955, 901, 738,
111535
+ /* 210 */ 661, 759, 674, 749, 641, 795, 774, 774, 913, 795,
111536
+ /* 220 */ 913, 697, 720, 955, 785, 955, 785, 694, 785, 774,
111537
+ /* 230 */ 863, 955, 955, 955, 758, 749, 955, 940, 765, 765,
111538
+ /* 240 */ 932, 932, 765, 807, 730, 795, 737, 737, 737, 737,
111539
+ /* 250 */ 765, 656, 795, 807, 730, 730, 795, 765, 656, 907,
111540
+ /* 260 */ 905, 765, 765, 656, 765, 656, 765, 656, 873, 728,
111541
+ /* 270 */ 728, 728, 712, 877, 877, 873, 728, 697, 728, 712,
111542
+ /* 280 */ 728, 728, 778, 773, 778, 773, 778, 773, 765, 765,
111543
+ /* 290 */ 955, 790, 779, 788, 786, 795, 955, 715, 649, 649,
111544
+ /* 300 */ 638, 638, 638, 638, 952, 952, 947, 699, 699, 682,
111545
+ /* 310 */ 955, 955, 955, 955, 955, 955, 955, 882, 955, 955,
111546
+ /* 320 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111547
+ /* 330 */ 634, 942, 955, 955, 939, 955, 955, 955, 955, 800,
111548
+ /* 340 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111549
+ /* 350 */ 917, 955, 955, 955, 955, 955, 955, 955, 911, 955,
111550
+ /* 360 */ 955, 955, 955, 955, 955, 904, 903, 955, 955, 955,
111551
+ /* 370 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111552
+ /* 380 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111553
+ /* 390 */ 955, 955, 955, 787, 955, 780, 955, 866, 955, 955,
111554
+ /* 400 */ 955, 955, 955, 955, 955, 955, 955, 955, 743, 816,
111555
+ /* 410 */ 955, 815, 819, 814, 666, 955, 647, 955, 630, 635,
111556
+ /* 420 */ 951, 954, 953, 950, 949, 948, 943, 941, 938, 937,
111557
+ /* 430 */ 936, 934, 931, 927, 886, 884, 891, 890, 889, 888,
111558
+ /* 440 */ 887, 885, 883, 881, 802, 797, 794, 926, 879, 739,
111559
+ /* 450 */ 736, 735, 655, 944, 910, 919, 806, 805, 808, 916,
111560
+ /* 460 */ 915, 914, 912, 909, 896, 804, 803, 731, 871, 870,
111561
+ /* 470 */ 658, 900, 899, 898, 902, 906, 897, 767, 657, 654,
111562
+ /* 480 */ 663, 718, 719, 727, 725, 724, 723, 722, 721, 717,
111563
+ /* 490 */ 665, 673, 711, 696, 695, 876, 878, 875, 874, 704,
111564
+ /* 500 */ 703, 709, 708, 707, 706, 705, 702, 701, 700, 693,
111565
+ /* 510 */ 692, 698, 691, 714, 713, 710, 690, 734, 733, 732,
111566
+ /* 520 */ 729, 689, 688, 687, 819, 686, 685, 825, 824, 812,
111567
+ /* 530 */ 855, 754, 753, 752, 764, 763, 776, 775, 810, 809,
111568
+ /* 540 */ 777, 762, 756, 755, 771, 770, 769, 768, 760, 750,
111569
+ /* 550 */ 782, 784, 783, 781, 857, 766, 854, 925, 924, 923,
111570
+ /* 560 */ 922, 921, 859, 858, 826, 823, 677, 678, 894, 893,
111571
+ /* 570 */ 895, 892, 680, 679, 676, 675, 856, 745, 744, 852,
111572
+ /* 580 */ 849, 841, 837, 853, 850, 842, 838, 836, 835, 821,
111573
+ /* 590 */ 820, 818, 817, 813, 822, 668, 746, 742, 741, 811,
111574
+ /* 600 */ 748, 747, 684, 683, 681, 662, 660, 653, 651, 650,
111575
+ /* 610 */ 652, 648, 646, 645, 644, 643, 642, 671, 670, 669,
111576
+ /* 620 */ 667, 666, 640, 637, 636, 632, 631, 629,
111376111577
};
111377111578
111378111579
/* The next table maps tokens into fallback tokens. If a construct
111379111580
** like the following:
111380111581
**
@@ -111842,11 +112043,11 @@
111842112043
/* 237 */ "case_operand ::=",
111843112044
/* 238 */ "exprlist ::= nexprlist",
111844112045
/* 239 */ "exprlist ::=",
111845112046
/* 240 */ "nexprlist ::= nexprlist COMMA expr",
111846112047
/* 241 */ "nexprlist ::= expr",
111847
- /* 242 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP",
112048
+ /* 242 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt",
111848112049
/* 243 */ "uniqueflag ::= UNIQUE",
111849112050
/* 244 */ "uniqueflag ::=",
111850112051
/* 245 */ "idxlist_opt ::=",
111851112052
/* 246 */ "idxlist_opt ::= LP idxlist RP",
111852112053
/* 247 */ "idxlist ::= idxlist COMMA nm collate sortorder",
@@ -112561,11 +112762,11 @@
112561112762
{ 224, 0 },
112562112763
{ 220, 1 },
112563112764
{ 220, 0 },
112564112765
{ 215, 3 },
112565112766
{ 215, 1 },
112566
- { 147, 11 },
112767
+ { 147, 12 },
112567112768
{ 227, 1 },
112568112769
{ 227, 0 },
112569112770
{ 178, 0 },
112570112771
{ 178, 3 },
112571112772
{ 187, 5 },
@@ -113565,15 +113766,15 @@
113565113766
{yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);}
113566113767
break;
113567113768
case 241: /* nexprlist ::= expr */
113568113769
{yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr);}
113569113770
break;
113570
- case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
113771
+ case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt */
113571113772
{
113572
- sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0,
113573
- sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy442, yymsp[-9].minor.yy392,
113574
- &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy392);
113773
+ sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
113774
+ sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy442, yymsp[-10].minor.yy392,
113775
+ &yymsp[-11].minor.yy0, yymsp[0].minor.yy122, SQLITE_SO_ASC, yymsp[-8].minor.yy392);
113575113776
}
113576113777
break;
113577113778
case 243: /* uniqueflag ::= UNIQUE */
113578113779
case 296: /* raisetype ::= ABORT */ yytestcase(yyruleno==296);
113579113780
{yygotominor.yy392 = OE_Abort;}
@@ -114495,11 +114696,10 @@
114495114696
*tokenType = TK_SPACE;
114496114697
return i;
114497114698
}
114498114699
case '-': {
114499114700
if( z[1]=='-' ){
114500
- /* IMP: R-50417-27976 -- syntax diagram for comments */
114501114701
for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
114502114702
*tokenType = TK_SPACE; /* IMP: R-22934-25134 */
114503114703
return i;
114504114704
}
114505114705
*tokenType = TK_MINUS;
@@ -114528,11 +114728,10 @@
114528114728
case '/': {
114529114729
if( z[1]!='*' || z[2]==0 ){
114530114730
*tokenType = TK_SLASH;
114531114731
return 1;
114532114732
}
114533
- /* IMP: R-50417-27976 -- syntax diagram for comments */
114534114733
for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}
114535114734
if( c ) i++;
114536114735
*tokenType = TK_SPACE; /* IMP: R-22934-25134 */
114537114736
return i;
114538114737
}
@@ -116373,10 +116572,11 @@
116373116572
case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break;
116374116573
case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
116375116574
case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
116376116575
case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
116377116576
case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
116577
+ case SQLITE_IOERR_GETTEMPPATH: zName = "SQLITE_IOERR_GETTEMPPATH"; break;
116378116578
case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
116379116579
case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
116380116580
case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
116381116581
case SQLITE_FULL: zName = "SQLITE_FULL"; break;
116382116582
case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
@@ -117728,11 +117928,11 @@
117728117928
db->autoCommit = 1;
117729117929
db->nextAutovac = -1;
117730117930
db->szMmap = sqlite3GlobalConfig.szMmap;
117731117931
db->nextPagesize = 0;
117732117932
db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger
117733
-#if !defined(SQLITE_DEAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
117933
+#if !defined(SQLITE_DEFAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
117734117934
| SQLITE_AutoIndex
117735117935
#endif
117736117936
#if SQLITE_DEFAULT_FILE_FORMAT<4
117737117937
| SQLITE_LegacyFileFmt
117738117938
#endif
@@ -128201,11 +128401,11 @@
128201128401
}
128202128402
128203128403
128204128404
#ifdef SQLITE_TEST
128205128405
128206
-/* #include <tcl.h> */
128406
+#include <tcl.h>
128207128407
/* #include <string.h> */
128208128408
128209128409
/*
128210128410
** Implementation of a special SQL scalar function for testing tokenizers
128211128411
** designed to be used in concert with the Tcl testing framework. This
128212128412
--- 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 */
@@ -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
@@ -10762,10 +10746,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 +11227,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 **
@@ -11426,10 +11412,11 @@
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 +11994,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 +12042,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 +12071,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 +12274,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*);
@@ -13257,10 +13246,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 +13435,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 +13465,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 +13570,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 +13594,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*);
@@ -30499,10 +30489,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 */
@@ -30919,10 +30910,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 */
@@ -34384,14 +34376,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 +34548,19 @@
34556 #endif
34557 /* caller will handle out of memory */
34558 return zConverted;
34559 }
34560
 
 
 
 
 
 
 
 
 
34561 /*
34562 ** Create a temporary file name in zBuf. zBuf must be big enough to
34563 ** hold at pVfs->mxPathname characters.
34564 */
34565 static int getTempname(int nBuf, char *zBuf){
@@ -34567,53 +34568,74 @@
34567 "abcdefghijklmnopqrstuvwxyz"
34568 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
34569 "0123456789";
34570 size_t i, j;
34571 int nTempPath;
34572 char zTempPath[MAX_PATH+2];
34573
34574 /* It's odd to simulate an io-error here, but really this is just
34575 ** using the io-error infrastructure to test that SQLite handles this
34576 ** function failing.
34577 */
34578 SimulateIOError( return SQLITE_IOERR );
34579
34580 memset(zTempPath, 0, MAX_PATH+2);
34581
34582 if( sqlite3_temp_directory ){
34583 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
 
34584 }
34585 #if !SQLITE_OS_WINRT
34586 else if( isNT() ){
34587 char *zMulti;
34588 WCHAR zWidePath[MAX_PATH];
34589 osGetTempPathW(MAX_PATH-30, zWidePath);
 
 
 
34590 zMulti = unicodeToUtf8(zWidePath);
34591 if( zMulti ){
34592 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti);
34593 sqlite3_free(zMulti);
34594 }else{
34595 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34596 return SQLITE_IOERR_NOMEM;
34597 }
34598 }
34599 #ifdef SQLITE_WIN32_HAS_ANSI
34600 else{
34601 char *zUtf8;
34602 char zMbcsPath[MAX_PATH];
34603 osGetTempPathA(MAX_PATH-30, zMbcsPath);
 
 
 
34604 zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
34605 if( zUtf8 ){
34606 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8);
34607 sqlite3_free(zUtf8);
34608 }else{
34609 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34610 return SQLITE_IOERR_NOMEM;
34611 }
34612 }
34613 #endif
34614 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34615
34616 /* Check that the output buffer is large enough for the temporary file
34617 ** name. If it is not, return SQLITE_ERROR.
34618 */
34619 nTempPath = sqlite3Strlen30(zTempPath);
@@ -34695,11 +34717,11 @@
34695 int cnt = 0;
34696
34697 /* If argument zPath is a NULL pointer, this function is required to open
34698 ** a temporary file. Use this buffer to store the file name in.
34699 */
34700 char zTmpname[MAX_PATH+2]; /* Buffer used to create temp filename */
34701
34702 int rc = SQLITE_OK; /* Function Return Code */
34703 #if !defined(NDEBUG) || SQLITE_OS_WINCE
34704 int eType = flags&0xFFFFFF00; /* Type of file to open */
34705 #endif
@@ -34761,12 +34783,11 @@
34761 /* If the second argument to this function is NULL, generate a
34762 ** temporary file name to use
34763 */
34764 if( !zUtf8Name ){
34765 assert(isDelete && !isOpenJournal);
34766 memset(zTmpname, 0, MAX_PATH+2);
34767 rc = getTempname(MAX_PATH+2, zTmpname);
34768 if( rc!=SQLITE_OK ){
34769 OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
34770 return rc;
34771 }
34772 zUtf8Name = zTmpname;
@@ -35193,27 +35214,34 @@
35193 ){
35194
35195 #if defined(__CYGWIN__)
35196 SimulateIOError( return SQLITE_ERROR );
35197 UNUSED_PARAMETER(nFull);
35198 assert( pVfs->mxPathname>=MAX_PATH );
35199 assert( nFull>=pVfs->mxPathname );
35200 if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
35201 /*
35202 ** NOTE: We are dealing with a relative path name and the data
35203 ** directory has been set. Therefore, use it as the basis
35204 ** for converting the relative path name to an absolute
35205 ** one by prepending the data directory and a slash.
35206 */
35207 char zOut[MAX_PATH+1];
35208 memset(zOut, 0, MAX_PATH+1);
35209 cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35210 MAX_PATH+1);
 
 
 
35211 sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s",
35212 sqlite3_data_directory, zOut);
35213 }else{
35214 cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull);
 
 
 
 
35215 }
35216 return SQLITE_OK;
35217 #endif
35218
35219 #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
@@ -35551,11 +35579,11 @@
35551 */
35552 SQLITE_API int sqlite3_os_init(void){
35553 static sqlite3_vfs winVfs = {
35554 3, /* iVersion */
35555 sizeof(winFile), /* szOsFile */
35556 MAX_PATH, /* mxPathname */
35557 0, /* pNext */
35558 "win32", /* zName */
35559 0, /* pAppData */
35560 winOpen, /* xOpen */
35561 winDelete, /* xDelete */
@@ -60176,12 +60204,12 @@
60176 ** a prior call to sqlite3VdbeMakeLabel().
60177 */
60178 SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *p, int x){
60179 int j = -1-x;
60180 assert( p->magic==VDBE_MAGIC_INIT );
60181 assert( j>=0 && j<p->nLabel );
60182 if( p->aLabel ){
60183 p->aLabel[j] = p->nOp;
60184 }
60185 }
60186
60187 /*
@@ -60501,12 +60529,11 @@
60501 /*
60502 ** Change the P2 operand of instruction addr so that it points to
60503 ** the address of the next instruction to be coded.
60504 */
60505 SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe *p, int addr){
60506 assert( addr>=0 || p->db->mallocFailed );
60507 if( addr>=0 ) sqlite3VdbeChangeP2(p, addr, p->nOp);
60508 }
60509
60510
60511 /*
60512 ** If the input FuncDef structure is ephemeral, then free it. If
@@ -60538,17 +60565,10 @@
60538 }
60539 case P4_MPRINTF: {
60540 if( db->pnBytesFreed==0 ) sqlite3_free(p4);
60541 break;
60542 }
60543 case P4_VDBEFUNC: {
60544 VdbeFunc *pVdbeFunc = (VdbeFunc *)p4;
60545 freeEphemeralFunction(db, pVdbeFunc->pFunc);
60546 if( db->pnBytesFreed==0 ) sqlite3VdbeDeleteAuxData(pVdbeFunc, 0);
60547 sqlite3DbFree(db, pVdbeFunc);
60548 break;
60549 }
60550 case P4_FUNCDEF: {
60551 freeEphemeralFunction(db, (FuncDef*)p4);
60552 break;
60553 }
60554 case P4_MEM: {
@@ -61574,10 +61594,14 @@
61574 while( p->pDelFrame ){
61575 VdbeFrame *pDel = p->pDelFrame;
61576 p->pDelFrame = pDel->pParent;
61577 sqlite3VdbeFrameDelete(pDel);
61578 }
 
 
 
 
61579 }
61580
61581 /*
61582 ** Clean up the VM after execution.
61583 **
@@ -62372,24 +62396,39 @@
62372 sqlite3VdbeDelete(p);
62373 return rc;
62374 }
62375
62376 /*
62377 ** Call the destructor for each auxdata entry in pVdbeFunc for which
62378 ** the corresponding bit in mask is clear. Auxdata entries beyond 31
62379 ** are always destroyed. To destroy all auxdata entries, call this
62380 ** routine with mask==0.
 
 
 
 
 
 
 
 
 
 
62381 */
62382 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc *pVdbeFunc, int mask){
62383 int i;
62384 for(i=0; i<pVdbeFunc->nAux; i++){
62385 struct AuxData *pAux = &pVdbeFunc->apAux[i];
62386 if( (i>31 || !(mask&(((u32)1)<<i))) && pAux->pAux ){
 
 
62387 if( pAux->xDelete ){
62388 pAux->xDelete(pAux->pAux);
62389 }
62390 pAux->pAux = 0;
 
 
 
62391 }
62392 }
62393 }
62394
62395 /*
@@ -62904,11 +62943,11 @@
62904 */
62905 SQLITE_PRIVATE int sqlite3VdbeRecordCompare(
62906 int nKey1, const void *pKey1, /* Left key */
62907 UnpackedRecord *pPKey2 /* Right key */
62908 ){
62909 int d1; /* Offset into aKey[] of next data element */
62910 u32 idx1; /* Offset into aKey[] of next header element */
62911 u32 szHdr1; /* Number of bytes in header */
62912 int i = 0;
62913 int nField;
62914 int rc = 0;
@@ -62938,11 +62977,11 @@
62938 while( idx1<szHdr1 && i<pPKey2->nField ){
62939 u32 serial_type1;
62940
62941 /* Read the serial types for the next element in each key. */
62942 idx1 += getVarint32( aKey1+idx1, serial_type1 );
62943 if( d1>=nKey1 && sqlite3VdbeSerialTypeLen(serial_type1)>0 ) break;
62944
62945 /* Extract the values to be compared.
62946 */
62947 d1 += sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1);
62948
@@ -63167,11 +63206,11 @@
63167 ** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*
63168 ** constants) to the value before returning it.
63169 **
63170 ** The returned value must be freed by the caller using sqlite3ValueFree().
63171 */
63172 SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetValue(Vdbe *v, int iVar, u8 aff){
63173 assert( iVar>0 );
63174 if( v ){
63175 Mem *pMem = &v->aVar[iVar-1];
63176 if( 0==(pMem->flags & MEM_Null) ){
63177 sqlite3_value *pRet = sqlite3ValueNew(v->db);
@@ -63784,18 +63823,18 @@
63784 /*
63785 ** Return the auxilary data pointer, if any, for the iArg'th argument to
63786 ** the user-function defined by pCtx.
63787 */
63788 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
63789 VdbeFunc *pVdbeFunc;
63790
63791 assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63792 pVdbeFunc = pCtx->pVdbeFunc;
63793 if( !pVdbeFunc || iArg>=pVdbeFunc->nAux || iArg<0 ){
63794 return 0;
63795 }
63796 return pVdbeFunc->apAux[iArg].pAux;
 
63797 }
63798
63799 /*
63800 ** Set the auxilary data pointer and delete function, for the iArg'th
63801 ** argument to the user-function defined by pCtx. Any previous value is
@@ -63805,33 +63844,30 @@
63805 sqlite3_context *pCtx,
63806 int iArg,
63807 void *pAux,
63808 void (*xDelete)(void*)
63809 ){
63810 struct AuxData *pAuxData;
63811 VdbeFunc *pVdbeFunc;
63812 if( iArg<0 ) goto failed;
63813
63814 assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63815 pVdbeFunc = pCtx->pVdbeFunc;
63816 if( !pVdbeFunc || pVdbeFunc->nAux<=iArg ){
63817 int nAux = (pVdbeFunc ? pVdbeFunc->nAux : 0);
63818 int nMalloc = sizeof(VdbeFunc) + sizeof(struct AuxData)*iArg;
63819 pVdbeFunc = sqlite3DbRealloc(pCtx->s.db, pVdbeFunc, nMalloc);
63820 if( !pVdbeFunc ){
63821 goto failed;
63822 }
63823 pCtx->pVdbeFunc = pVdbeFunc;
63824 memset(&pVdbeFunc->apAux[nAux], 0, sizeof(struct AuxData)*(iArg+1-nAux));
63825 pVdbeFunc->nAux = iArg+1;
63826 pVdbeFunc->pFunc = pCtx->pFunc;
63827 }
63828
63829 pAuxData = &pVdbeFunc->apAux[iArg];
63830 if( pAuxData->pAux && pAuxData->xDelete ){
63831 pAuxData->xDelete(pAuxData->pAux);
63832 }
 
63833 pAuxData->pAux = pAux;
63834 pAuxData->xDelete = xDelete;
63835 return;
63836
63837 failed:
@@ -65439,11 +65475,11 @@
65439 u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
65440 u8 encoding = ENC(db); /* The database encoding */
65441 int iCompare = 0; /* Result of last OP_Compare operation */
65442 unsigned nVmStep = 0; /* Number of virtual machine steps */
65443 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65444 unsigned nProgressOps = 0; /* nVmStep at last progress callback. */
65445 #endif
65446 Mem *aMem = p->aMem; /* Copy of p->aMem */
65447 Mem *pIn1 = 0; /* 1st input operand */
65448 Mem *pIn2 = 0; /* 2nd input operand */
65449 Mem *pIn3 = 0; /* 3rd input operand */
@@ -65898,10 +65934,21 @@
65898 assert( p->explain==0 );
65899 p->pResultSet = 0;
65900 db->busyHandler.nBusy = 0;
65901 CHECK_FOR_INTERRUPT;
65902 sqlite3VdbeIOTraceSql(p);
 
 
 
 
 
 
 
 
 
 
 
65903 #ifdef SQLITE_DEBUG
65904 sqlite3BeginBenignMalloc();
65905 if( p->pc==0 && (p->db->flags & SQLITE_VdbeListing)!=0 ){
65906 int i;
65907 printf("VDBE Program Listing:\n");
@@ -66058,18 +66105,20 @@
66058 ** of VDBE ops have been executed (either since this invocation of
66059 ** sqlite3VdbeExec() or since last time the progress callback was called).
66060 ** If the progress callback returns non-zero, exit the virtual machine with
66061 ** a return code SQLITE_ABORT.
66062 */
66063 if( db->xProgress!=0 && (nVmStep - nProgressOps)>=db->nProgressOps ){
66064 int prc;
66065 prc = db->xProgress(db->pProgressArg);
66066 if( prc!=0 ){
66067 rc = SQLITE_INTERRUPT;
66068 goto vdbe_error_halt;
66069 }
66070 nProgressOps = nVmStep;
 
 
66071 }
66072 #endif
66073
66074 break;
66075 }
@@ -66751,23 +66800,18 @@
66751 Deephemeralize(u.ai.pArg);
66752 sqlite3VdbeMemStoreType(u.ai.pArg);
66753 REGISTER_TRACE(pOp->p2+u.ai.i, u.ai.pArg);
66754 }
66755
66756 assert( pOp->p4type==P4_FUNCDEF || pOp->p4type==P4_VDBEFUNC );
66757 if( pOp->p4type==P4_FUNCDEF ){
66758 u.ai.ctx.pFunc = pOp->p4.pFunc;
66759 u.ai.ctx.pVdbeFunc = 0;
66760 }else{
66761 u.ai.ctx.pVdbeFunc = (VdbeFunc*)pOp->p4.pVdbeFunc;
66762 u.ai.ctx.pFunc = u.ai.ctx.pVdbeFunc->pFunc;
66763 }
66764
66765 u.ai.ctx.s.flags = MEM_Null;
66766 u.ai.ctx.s.db = db;
66767 u.ai.ctx.s.xDel = 0;
66768 u.ai.ctx.s.zMalloc = 0;
 
 
66769
66770 /* The output cell may already have a buffer allocated. Move
66771 ** the pointer to u.ai.ctx.s so in case the user-function can use
66772 ** the already allocated buffer instead of allocating a new one.
66773 */
@@ -66786,15 +66830,11 @@
66786 lastRowid = db->lastRowid;
66787
66788 /* If any auxiliary data functions have been called by this user function,
66789 ** immediately call the destructor for any non-static values.
66790 */
66791 if( u.ai.ctx.pVdbeFunc ){
66792 sqlite3VdbeDeleteAuxData(u.ai.ctx.pVdbeFunc, pOp->p1);
66793 pOp->p4.pVdbeFunc = u.ai.ctx.pVdbeFunc;
66794 pOp->p4type = P4_VDBEFUNC;
66795 }
66796
66797 if( db->mallocFailed ){
66798 /* Even though a malloc() has failed, the implementation of the
66799 ** user function may have called an sqlite3_result_XXX() function
66800 ** to return a value. The following call releases any resources
@@ -74157,15 +74197,24 @@
74157 /* Translate the schema name in zDb into a pointer to the corresponding
74158 ** schema. If not found, pSchema will remain NULL and nothing will match
74159 ** resulting in an appropriate error message toward the end of this routine
74160 */
74161 if( zDb ){
74162 for(i=0; i<db->nDb; i++){
74163 assert( db->aDb[i].zName );
74164 if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){
74165 pSchema = db->aDb[i].pSchema;
74166 break;
 
 
 
 
 
 
 
 
 
74167 }
74168 }
74169 }
74170
74171 /* Start at the inner-most context and move outward until a match is found */
@@ -74438,10 +74487,43 @@
74438 }
74439 ExprSetProperty(p, EP_Resolved);
74440 }
74441 return p;
74442 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74443
74444 /*
74445 ** This routine is callback for sqlite3WalkExpr().
74446 **
74447 ** Resolve symbolic names into TK_COLUMN operators for the current
@@ -74538,10 +74620,11 @@
74538 FuncDef *pDef; /* Information about the function */
74539 u8 enc = ENC(pParse->db); /* The database encoding */
74540
74541 testcase( pExpr->op==TK_CONST_FUNC );
74542 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
 
74543 zId = pExpr->u.zToken;
74544 nId = sqlite3Strlen30(zId);
74545 pDef = sqlite3FindFunction(pParse->db, zId, nId, n, enc, 0);
74546 if( pDef==0 ){
74547 pDef = sqlite3FindFunction(pParse->db, zId, nId, -2, enc, 0);
@@ -74603,31 +74686,25 @@
74603 #endif
74604 case TK_IN: {
74605 testcase( pExpr->op==TK_IN );
74606 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
74607 int nRef = pNC->nRef;
74608 #ifndef SQLITE_OMIT_CHECK
74609 if( (pNC->ncFlags & NC_IsCheck)!=0 ){
74610 sqlite3ErrorMsg(pParse,"subqueries prohibited in CHECK constraints");
74611 }
74612 #endif
74613 sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
74614 assert( pNC->nRef>=nRef );
74615 if( nRef!=pNC->nRef ){
74616 ExprSetProperty(pExpr, EP_VarSelect);
74617 }
74618 }
74619 break;
74620 }
74621 #ifndef SQLITE_OMIT_CHECK
74622 case TK_VARIABLE: {
74623 if( (pNC->ncFlags & NC_IsCheck)!=0 ){
74624 sqlite3ErrorMsg(pParse,"parameters prohibited in CHECK constraints");
74625 }
74626 break;
74627 }
74628 #endif
74629 }
74630 return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue;
74631 }
74632
74633 /*
@@ -74714,11 +74791,11 @@
74714 /* Try to match the ORDER BY expression against an expression
74715 ** in the result set. Return an 1-based index of the matching
74716 ** result-set entry.
74717 */
74718 for(i=0; i<pEList->nExpr; i++){
74719 if( sqlite3ExprCompare(pEList->a[i].pExpr, pE)<2 ){
74720 return i+1;
74721 }
74722 }
74723
74724 /* If no match, return 0. */
@@ -74942,11 +75019,11 @@
74942 pItem->iOrderByCol = 0;
74943 if( sqlite3ResolveExprNames(pNC, pE) ){
74944 return 1;
74945 }
74946 for(j=0; j<pSelect->pEList->nExpr; j++){
74947 if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr)==0 ){
74948 pItem->iOrderByCol = j+1;
74949 }
74950 }
74951 }
74952 return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
@@ -75248,10 +75325,52 @@
75248 w.xSelectCallback = resolveSelectStep;
75249 w.pParse = pParse;
75250 w.u.pNC = pOuterNC;
75251 sqlite3WalkSelect(&w, p);
75252 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75253
75254 /************** End of resolve.c *********************************************/
75255 /************** Begin file expr.c ********************************************/
75256 /*
75257 ** 2001 September 15
@@ -77614,19 +77733,24 @@
77614 break;
77615 }
77616 /* Otherwise, fall thru into the TK_COLUMN case */
77617 }
77618 case TK_COLUMN: {
77619 if( pExpr->iTable<0 ){
77620 /* This only happens when coding check constraints */
77621 assert( pParse->ckBase>0 );
77622 inReg = pExpr->iColumn + pParse->ckBase;
77623 }else{
77624 inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
77625 pExpr->iColumn, pExpr->iTable, target,
77626 pExpr->op2);
77627 }
 
 
 
 
 
77628 break;
77629 }
77630 case TK_INTEGER: {
77631 codeInteger(pParse, pExpr, 0, target);
77632 break;
@@ -79045,10 +79169,16 @@
79045 ** Do a deep comparison of two expression trees. Return 0 if the two
79046 ** expressions are completely identical. Return 1 if they differ only
79047 ** by a COLLATE operator at the top level. Return 2 if there are differences
79048 ** other than the top-level COLLATE operator.
79049 **
 
 
 
 
 
 
79050 ** Sometimes this routine will return 2 even if the two expressions
79051 ** really are equivalent. If we cannot prove that the expressions are
79052 ** identical, we return 2 just to be safe. So if this routine
79053 ** returns 2, then you do not really know for certain if the two
79054 ** expressions are the same. But if you get a 0 or 1 return, then you
@@ -79055,33 +79185,36 @@
79055 ** can be sure the expressions are the same. In the places where
79056 ** this routine is used, it does not hurt to get an extra 2 - that
79057 ** just might result in some slightly slower code. But returning
79058 ** an incorrect 0 or 1 could lead to a malfunction.
79059 */
79060 SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB){
79061 if( pA==0||pB==0 ){
79062 return pB==pA ? 0 : 2;
79063 }
79064 assert( !ExprHasAnyProperty(pA, EP_TokenOnly|EP_Reduced) );
79065 assert( !ExprHasAnyProperty(pB, EP_TokenOnly|EP_Reduced) );
79066 if( ExprHasProperty(pA, EP_xIsSelect) || ExprHasProperty(pB, EP_xIsSelect) ){
79067 return 2;
79068 }
79069 if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
79070 if( pA->op!=pB->op ){
79071 if( pA->op==TK_COLLATE && sqlite3ExprCompare(pA->pLeft, pB)<2 ){
79072 return 1;
79073 }
79074 if( pB->op==TK_COLLATE && sqlite3ExprCompare(pA, pB->pLeft)<2 ){
79075 return 1;
79076 }
79077 return 2;
79078 }
79079 if( sqlite3ExprCompare(pA->pLeft, pB->pLeft) ) return 2;
79080 if( sqlite3ExprCompare(pA->pRight, pB->pRight) ) return 2;
79081 if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList) ) return 2;
79082 if( pA->iTable!=pB->iTable || pA->iColumn!=pB->iColumn ) return 2;
 
 
 
79083 if( ExprHasProperty(pA, EP_IntValue) ){
79084 if( !ExprHasProperty(pB, EP_IntValue) || pA->u.iValue!=pB->u.iValue ){
79085 return 2;
79086 }
79087 }else if( pA->op!=TK_COLUMN && ALWAYS(pA->op!=TK_AGG_COLUMN) && pA->u.zToken){
@@ -79095,28 +79228,70 @@
79095
79096 /*
79097 ** Compare two ExprList objects. Return 0 if they are identical and
79098 ** non-zero if they differ in any way.
79099 **
 
 
 
79100 ** This routine might return non-zero for equivalent ExprLists. The
79101 ** only consequence will be disabled optimizations. But this routine
79102 ** must never return 0 if the two ExprList objects are different, or
79103 ** a malfunction will result.
79104 **
79105 ** Two NULL pointers are considered to be the same. But a NULL pointer
79106 ** always differs from a non-NULL pointer.
79107 */
79108 SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB){
79109 int i;
79110 if( pA==0 && pB==0 ) return 0;
79111 if( pA==0 || pB==0 ) return 1;
79112 if( pA->nExpr!=pB->nExpr ) return 1;
79113 for(i=0; i<pA->nExpr; i++){
79114 Expr *pExprA = pA->a[i].pExpr;
79115 Expr *pExprB = pB->a[i].pExpr;
79116 if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
79117 if( sqlite3ExprCompare(pExprA, pExprB) ) return 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79118 }
79119 return 0;
79120 }
79121
79122 /*
@@ -79297,11 +79472,11 @@
79297 /* Check to see if pExpr is a duplicate of another aggregate
79298 ** function that is already in the pAggInfo structure
79299 */
79300 struct AggInfo_func *pItem = pAggInfo->aFunc;
79301 for(i=0; i<pAggInfo->nFunc; i++, pItem++){
79302 if( sqlite3ExprCompare(pItem->pExpr, pExpr)==0 ){
79303 break;
79304 }
79305 }
79306 if( i>=pAggInfo->nFunc ){
79307 /* pExpr is original. Make a new entry in pAggInfo->aFunc[]
@@ -80714,10 +80889,11 @@
80714 int i; /* Loop counter */
80715 int topOfLoop; /* The top of the loop */
80716 int endOfLoop; /* The end of the loop */
80717 int jZeroRows = -1; /* Jump from here if number of rows is zero */
80718 int iDb; /* Index of database containing pTab */
 
80719 int regTabname = iMem++; /* Register containing table name */
80720 int regIdxname = iMem++; /* Register containing index name */
80721 int regStat1 = iMem++; /* The stat column of sqlite_stat1 */
80722 #ifdef SQLITE_ENABLE_STAT3
80723 int regNumEq = regStat1; /* Number of instances. Same as regStat1 */
@@ -80773,10 +80949,11 @@
80773 KeyInfo *pKey;
80774 int addrIfNot = 0; /* address of OP_IfNot */
80775 int *aChngAddr; /* Array of jump instruction addresses */
80776
80777 if( pOnlyIdx && pOnlyIdx!=pIdx ) continue;
 
80778 VdbeNoopComment((v, "Begin analysis of %s", pIdx->zName));
80779 nCol = pIdx->nColumn;
80780 aChngAddr = sqlite3DbMallocRaw(db, sizeof(int)*nCol);
80781 if( aChngAddr==0 ) continue;
80782 pKey = sqlite3IndexKeyinfo(pParse, pIdx);
@@ -80932,48 +81109,45 @@
80932 ** If K==0 then no entry is made into the sqlite_stat1 table.
80933 ** If K>0 then it is always the case the D>0 so division by zero
80934 ** is never possible.
80935 */
80936 sqlite3VdbeAddOp2(v, OP_SCopy, iMem, regStat1);
80937 if( jZeroRows<0 ){
80938 jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem);
80939 }
80940 for(i=0; i<nCol; i++){
80941 sqlite3VdbeAddOp4(v, OP_String8, 0, regTemp, 0, " ", 0);
80942 sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1);
80943 sqlite3VdbeAddOp3(v, OP_Add, iMem, iMem+i+1, regTemp);
80944 sqlite3VdbeAddOp2(v, OP_AddImm, regTemp, -1);
80945 sqlite3VdbeAddOp3(v, OP_Divide, iMem+i+1, regTemp, regTemp);
80946 sqlite3VdbeAddOp1(v, OP_ToInt, regTemp);
80947 sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1);
80948 }
 
80949 sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0);
80950 sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
80951 sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);
80952 sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
 
80953 }
80954
80955 /* If the table has no indices, create a single sqlite_stat1 entry
80956 ** containing NULL as the index name and the row count as the content.
80957 */
80958 if( pTab->pIndex==0 ){
80959 sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pTab->tnum, iDb);
80960 VdbeComment((v, "%s", pTab->zName));
80961 sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat1);
80962 sqlite3VdbeAddOp1(v, OP_Close, iIdxCur);
80963 jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1);
80964 }else{
80965 sqlite3VdbeJumpHere(v, jZeroRows);
80966 jZeroRows = sqlite3VdbeAddOp0(v, OP_Goto);
80967 }
80968 sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname);
80969 sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0);
80970 sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
80971 sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);
80972 sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
80973 if( pParse->nMem<regRec ) pParse->nMem = regRec;
80974 sqlite3VdbeJumpHere(v, jZeroRows);
80975 }
80976
80977
80978 /*
80979 ** Generate code that will cause the most recent index analysis to
@@ -81152,12 +81326,14 @@
81152 v = 0;
81153 while( (c=z[0])>='0' && c<='9' ){
81154 v = v*10 + c - '0';
81155 z++;
81156 }
81157 if( i==0 ) pTable->nRowEst = v;
81158 if( pIndex==0 ) break;
 
 
81159 pIndex->aiRowEst[i] = v;
81160 if( *z==' ' ) z++;
81161 if( strcmp(z, "unordered")==0 ){
81162 pIndex->bUnordered = 1;
81163 break;
@@ -82593,10 +82769,11 @@
82593 */
82594 static void freeIndex(sqlite3 *db, Index *p){
82595 #ifndef SQLITE_OMIT_ANALYZE
82596 sqlite3DeleteIndexSamples(db, p);
82597 #endif
 
82598 sqlite3DbFree(db, p->zColAff);
82599 sqlite3DbFree(db, p);
82600 }
82601
82602 /*
@@ -83436,11 +83613,12 @@
83436 sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
83437 "INTEGER PRIMARY KEY");
83438 #endif
83439 }else{
83440 Index *p;
83441 p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, 0, sortOrder, 0);
 
83442 if( p ){
83443 p->autoIndex = 2;
83444 }
83445 pList = 0;
83446 }
@@ -83731,30 +83909,11 @@
83731
83732 #ifndef SQLITE_OMIT_CHECK
83733 /* Resolve names in all CHECK constraint expressions.
83734 */
83735 if( p->pCheck ){
83736 SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
83737 NameContext sNC; /* Name context for pParse->pNewTable */
83738 ExprList *pList; /* List of all CHECK constraints */
83739 int i; /* Loop counter */
83740
83741 memset(&sNC, 0, sizeof(sNC));
83742 memset(&sSrc, 0, sizeof(sSrc));
83743 sSrc.nSrc = 1;
83744 sSrc.a[0].zName = p->zName;
83745 sSrc.a[0].pTab = p;
83746 sSrc.a[0].iCursor = -1;
83747 sNC.pParse = pParse;
83748 sNC.pSrcList = &sSrc;
83749 sNC.ncFlags = NC_IsCheck;
83750 pList = p->pCheck;
83751 for(i=0; i<pList->nExpr; i++){
83752 if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){
83753 return;
83754 }
83755 }
83756 }
83757 #endif /* !defined(SQLITE_OMIT_CHECK) */
83758
83759 /* If the db->init.busy is 1 it means we are reading the SQL off the
83760 ** "sqlite_master" or "sqlite_temp_master" table on the disk.
@@ -84602,10 +84761,11 @@
84602 int iIdx = pParse->nTab++; /* Btree cursor used for pIndex */
84603 int iSorter; /* Cursor opened by OpenSorter (if in use) */
84604 int addr1; /* Address of top of loop */
84605 int addr2; /* Address to jump to for next iteration */
84606 int tnum; /* Root page of index */
 
84607 Vdbe *v; /* Generate code into this virtual machine */
84608 KeyInfo *pKey; /* KeyInfo for index */
84609 int regRecord; /* Register holding assemblied index record */
84610 sqlite3 *db = pParse->db; /* The database connection */
84611 int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);
@@ -84641,12 +84801,13 @@
84641 ** records into the sorter. */
84642 sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
84643 addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0);
84644 regRecord = sqlite3GetTempReg(pParse);
84645
84646 sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1);
84647 sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord);
 
84648 sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1);
84649 sqlite3VdbeJumpHere(v, addr1);
84650 addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0);
84651 if( pIndex->onError!=OE_None ){
84652 int j2 = sqlite3VdbeCurrentAddr(v) + 3;
@@ -84693,11 +84854,11 @@
84693 Token *pName2, /* Second part of index name. May be NULL */
84694 SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */
84695 ExprList *pList, /* A list of columns to be indexed */
84696 int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
84697 Token *pStart, /* The CREATE token that begins this statement */
84698 Token *pEnd, /* The ")" that closes the CREATE INDEX statement */
84699 int sortOrder, /* Sort order of primary key when pList==NULL */
84700 int ifNotExist /* Omit error if index already exists */
84701 ){
84702 Index *pRet = 0; /* Pointer to return */
84703 Table *pTab = 0; /* Table to be indexed */
@@ -84715,11 +84876,10 @@
84715 struct ExprList_item *pListItem; /* For looping over pList */
84716 int nCol;
84717 int nExtra = 0;
84718 char *zExtra;
84719
84720 assert( pStart==0 || pEnd!=0 ); /* pEnd must be non-NULL if pStart is */
84721 assert( pParse->nErr==0 ); /* Never called with prior errors */
84722 if( db->mallocFailed || IN_DECLARE_VTAB ){
84723 goto exit_create_index;
84724 }
84725 if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
@@ -84761,11 +84921,16 @@
84761 assert(0);
84762 }
84763 pTab = sqlite3LocateTableItem(pParse, 0, &pTblName->a[0]);
84764 assert( db->mallocFailed==0 || pTab==0 );
84765 if( pTab==0 ) goto exit_create_index;
84766 assert( db->aDb[iDb].pSchema==pTab->pSchema );
 
 
 
 
 
84767 }else{
84768 assert( pName==0 );
84769 assert( pStart==0 );
84770 pTab = pParse->pNewTable;
84771 if( !pTab ) goto exit_create_index;
@@ -84910,10 +85075,15 @@
84910 pIndex->nColumn = pList->nExpr;
84911 pIndex->onError = (u8)onError;
84912 pIndex->uniqNotNull = onError==OE_Abort;
84913 pIndex->autoIndex = (u8)(pName==0);
84914 pIndex->pSchema = db->aDb[iDb].pSchema;
 
 
 
 
 
84915 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
84916
84917 /* Check to see if we should honor DESC requests on index columns
84918 */
84919 if( pDb->pSchema->file_format>=4 ){
@@ -85065,11 +85235,11 @@
85065 ** If pTblName==0 it means this index is generated as a primary key
85066 ** or UNIQUE constraint of a CREATE TABLE statement. Since the table
85067 ** has just been created, it contains no data and the index initialization
85068 ** step can be skipped.
85069 */
85070 else{ /* if( db->init.busy==0 ) */
85071 Vdbe *v;
85072 char *zStmt;
85073 int iMem = ++pParse->nMem;
85074
85075 v = sqlite3GetVdbe(pParse);
@@ -85083,16 +85253,15 @@
85083
85084 /* Gather the complete text of the CREATE INDEX statement into
85085 ** the zStmt variable
85086 */
85087 if( pStart ){
85088 assert( pEnd!=0 );
 
85089 /* A named index with an explicit CREATE INDEX statement */
85090 zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s",
85091 onError==OE_None ? "" : " UNIQUE",
85092 (int)(pEnd->z - pName->z) + 1,
85093 pName->z);
85094 }else{
85095 /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */
85096 /* zStmt = sqlite3MPrintf(""); */
85097 zStmt = 0;
85098 }
@@ -85144,14 +85313,12 @@
85144 pIndex = 0;
85145 }
85146
85147 /* Clean up before exiting */
85148 exit_create_index:
85149 if( pIndex ){
85150 sqlite3DbFree(db, pIndex->zColAff);
85151 sqlite3DbFree(db, pIndex);
85152 }
85153 sqlite3ExprListDelete(db, pList);
85154 sqlite3SrcListDelete(db, pTblName);
85155 sqlite3DbFree(db, zName);
85156 return pRet;
85157 }
@@ -87123,15 +87290,18 @@
87123 int *aRegIdx /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */
87124 ){
87125 int i;
87126 Index *pIdx;
87127 int r1;
 
 
87128
87129 for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
87130 if( aRegIdx!=0 && aRegIdx[i-1]==0 ) continue;
87131 r1 = sqlite3GenerateIndexKey(pParse, pIdx, iCur, 0, 0);
87132 sqlite3VdbeAddOp3(pParse->pVdbe, OP_IdxDelete, iCur+i, r1,pIdx->nColumn+1);
 
87133 }
87134 }
87135
87136 /*
87137 ** Generate code that will assemble an index key and put it in register
@@ -87141,24 +87311,42 @@
87141 **
87142 ** Return a register number which is the first in a block of
87143 ** registers that holds the elements of the index key. The
87144 ** block of registers has already been deallocated by the time
87145 ** this routine returns.
 
 
 
 
 
 
 
87146 */
87147 SQLITE_PRIVATE int sqlite3GenerateIndexKey(
87148 Parse *pParse, /* Parsing context */
87149 Index *pIdx, /* The index for which to generate a key */
87150 int iCur, /* Cursor number for the pIdx->pTable table */
87151 int regOut, /* Write the new index key to this register */
87152 int doMakeRec /* Run the OP_MakeRecord instruction if true */
 
87153 ){
87154 Vdbe *v = pParse->pVdbe;
87155 int j;
87156 Table *pTab = pIdx->pTable;
87157 int regBase;
87158 int nCol;
87159
 
 
 
 
 
 
 
 
 
 
87160 nCol = pIdx->nColumn;
87161 regBase = sqlite3GetTempRange(pParse, nCol+1);
87162 sqlite3VdbeAddOp2(v, OP_Rowid, iCur, regBase+nCol);
87163 for(j=0; j<nCol; j++){
87164 int idx = pIdx->aiColumn[j];
@@ -91518,12 +91706,22 @@
91518 ** Add the new records to the indices as we go.
91519 */
91520 for(iCur=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, iCur++){
91521 int regIdx;
91522 int regR;
 
91523
91524 if( aRegIdx[iCur]==0 ) continue; /* Skip unused indices */
 
 
 
 
 
 
 
 
 
91525
91526 /* Create a key for accessing the index entry */
91527 regIdx = sqlite3GetTempRange(pParse, pIdx->nColumn+1);
91528 for(i=0; i<pIdx->nColumn; i++){
91529 int idx = pIdx->aiColumn[i];
@@ -91540,10 +91738,11 @@
91540
91541 /* Find out what action to take in case there is an indexing conflict */
91542 onError = pIdx->onError;
91543 if( onError==OE_None ){
91544 sqlite3ReleaseTempRange(pParse, regIdx, pIdx->nColumn+1);
 
91545 continue; /* pIdx is not a UNIQUE index */
91546 }
91547 if( overrideError!=OE_Default ){
91548 onError = overrideError;
91549 }else if( onError==OE_Default ){
@@ -91609,10 +91808,11 @@
91609 seenReplace = 1;
91610 break;
91611 }
91612 }
91613 sqlite3VdbeJumpHere(v, j3);
 
91614 sqlite3ReleaseTempReg(pParse, regR);
91615 }
91616
91617 if( pbMayReplace ){
91618 *pbMayReplace = seenReplace;
@@ -91638,22 +91838,23 @@
91638 int appendBias, /* True if this is likely to be an append */
91639 int useSeekResult /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */
91640 ){
91641 int i;
91642 Vdbe *v;
91643 int nIdx;
91644 Index *pIdx;
91645 u8 pik_flags;
91646 int regData;
91647 int regRec;
91648
91649 v = sqlite3GetVdbe(pParse);
91650 assert( v!=0 );
91651 assert( pTab->pSelect==0 ); /* This table is not a VIEW */
91652 for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){}
91653 for(i=nIdx-1; i>=0; i--){
91654 if( aRegIdx[i]==0 ) continue;
 
 
 
91655 sqlite3VdbeAddOp2(v, OP_IdxInsert, baseCur+i+1, aRegIdx[i]);
91656 if( useSeekResult ){
91657 sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
91658 }
91659 }
@@ -91751,10 +91952,11 @@
91751 **
91752 ** * The index is over the same set of columns
91753 ** * The same DESC and ASC markings occurs on all columns
91754 ** * The same onError processing (OE_Abort, OE_Ignore, etc)
91755 ** * The same collating sequence on each column
 
91756 */
91757 static int xferCompatibleIndex(Index *pDest, Index *pSrc){
91758 int i;
91759 assert( pDest && pSrc );
91760 assert( pDest->pTable!=pSrc->pTable );
@@ -91772,10 +91974,13 @@
91772 return 0; /* Different sort orders */
91773 }
91774 if( !xferCompatibleCollation(pSrc->azColl[i],pDest->azColl[i]) ){
91775 return 0; /* Different collating sequences */
91776 }
 
 
 
91777 }
91778
91779 /* If no test above fails then the indices must be compatible */
91780 return 1;
91781 }
@@ -91928,11 +92133,11 @@
91928 if( pSrcIdx==0 ){
91929 return 0; /* pDestIdx has no corresponding index in pSrc */
91930 }
91931 }
91932 #ifndef SQLITE_OMIT_CHECK
91933 if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck, pDest->pCheck) ){
91934 return 0; /* Tables have different CHECK constraints. Ticket #2252 */
91935 }
91936 #endif
91937 #ifndef SQLITE_OMIT_FOREIGN_KEY
91938 /* Disallow the transfer optimization if the destination table constains
@@ -94841,13 +95046,11 @@
94841 cnt++;
94842 }
94843 }
94844
94845 /* Make sure sufficient number of registers have been allocated */
94846 if( pParse->nMem < cnt+4 ){
94847 pParse->nMem = cnt+4;
94848 }
94849
94850 /* Do the b-tree integrity checks */
94851 sqlite3VdbeAddOp3(v, OP_IntegrityCk, 2, cnt, 1);
94852 sqlite3VdbeChangeP5(v, (u8)i);
94853 addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2);
@@ -94868,16 +95071,19 @@
94868
94869 if( pTab->pIndex==0 ) continue;
94870 addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Stop if out of errors */
94871 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
94872 sqlite3VdbeJumpHere(v, addr);
 
94873 sqlite3OpenTableAndIndices(pParse, pTab, 1, OP_OpenRead);
94874 sqlite3VdbeAddOp2(v, OP_Integer, 0, 2); /* reg(2) will count entries */
94875 loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0);
94876 sqlite3VdbeAddOp2(v, OP_AddImm, 2, 1); /* increment entry count */
 
 
94877 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
94878 int jmp2;
94879 int r1;
94880 static const VdbeOpList idxErr[] = {
94881 { OP_AddImm, 1, -1, 0},
94882 { OP_String8, 0, 3, 0}, /* 1 */
94883 { OP_Rowid, 1, 4, 0},
@@ -94888,47 +95094,38 @@
94888 { OP_Concat, 6, 3, 3},
94889 { OP_ResultRow, 3, 1, 0},
94890 { OP_IfPos, 1, 0, 0}, /* 9 */
94891 { OP_Halt, 0, 0, 0},
94892 };
94893 r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 0);
 
94894 jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, j+2, 0, r1, pIdx->nColumn+1);
94895 addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr);
94896 sqlite3VdbeChangeP4(v, addr+1, "rowid ", P4_STATIC);
94897 sqlite3VdbeChangeP4(v, addr+3, " missing from index ", P4_STATIC);
94898 sqlite3VdbeChangeP4(v, addr+4, pIdx->zName, P4_TRANSIENT);
94899 sqlite3VdbeJumpHere(v, addr+9);
94900 sqlite3VdbeJumpHere(v, jmp2);
 
94901 }
94902 sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop+1);
94903 sqlite3VdbeJumpHere(v, loopTop);
 
 
 
94904 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
94905 static const VdbeOpList cntIdx[] = {
94906 { OP_Integer, 0, 3, 0},
94907 { OP_Rewind, 0, 0, 0}, /* 1 */
94908 { OP_AddImm, 3, 1, 0},
94909 { OP_Next, 0, 0, 0}, /* 3 */
94910 { OP_Eq, 2, 0, 3}, /* 4 */
94911 { OP_AddImm, 1, -1, 0},
94912 { OP_String8, 0, 2, 0}, /* 6 */
94913 { OP_String8, 0, 3, 0}, /* 7 */
94914 { OP_Concat, 3, 2, 2},
94915 { OP_ResultRow, 2, 1, 0},
94916 };
94917 addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1);
94918 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
94919 sqlite3VdbeJumpHere(v, addr);
94920 addr = sqlite3VdbeAddOpList(v, ArraySize(cntIdx), cntIdx);
94921 sqlite3VdbeChangeP1(v, addr+1, j+2);
94922 sqlite3VdbeChangeP2(v, addr+1, addr+4);
94923 sqlite3VdbeChangeP1(v, addr+3, j+2);
94924 sqlite3VdbeChangeP2(v, addr+3, addr+2);
94925 sqlite3VdbeJumpHere(v, addr+4);
94926 sqlite3VdbeChangeP4(v, addr+6,
94927 "wrong # of entries in index ", P4_STATIC);
94928 sqlite3VdbeChangeP4(v, addr+7, pIdx->zName, P4_TRANSIENT);
94929 }
94930 }
94931 }
94932 addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode);
94933 sqlite3VdbeChangeP2(v, addr, -mxErr);
94934 sqlite3VdbeJumpHere(v, addr+1);
@@ -100327,11 +100524,11 @@
100327 ** will cause elements to come out in the correct order. This is
100328 ** an optimization - the correct answer should result regardless.
100329 ** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER
100330 ** to disable this optimization for testing purposes.
100331 */
100332 if( sqlite3ExprListCompare(p->pGroupBy, pOrderBy)==0
100333 && OptimizationEnabled(db, SQLITE_GroupByOrder) ){
100334 pOrderBy = 0;
100335 }
100336
100337 /* If the query is DISTINCT with an ORDER BY but is not an aggregate, and
@@ -100348,11 +100545,11 @@
100348 ** used for both the ORDER BY and DISTINCT processing. As originally
100349 ** written the query must use a temp-table for at least one of the ORDER
100350 ** BY and DISTINCT, and an index or separate temp-table for the other.
100351 */
100352 if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct
100353 && sqlite3ExprListCompare(pOrderBy, p->pEList)==0
100354 ){
100355 p->selFlags &= ~SF_Distinct;
100356 p->pGroupBy = sqlite3ExprListDup(db, p->pEList, 0);
100357 pGroupBy = p->pGroupBy;
100358 pOrderBy = 0;
@@ -102575,11 +102772,11 @@
102575 aRegIdx = sqlite3DbMallocRaw(db, sizeof(Index*) * nIdx );
102576 if( aRegIdx==0 ) goto update_cleanup;
102577 }
102578 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
102579 int reg;
102580 if( hasFK || chngRowid ){
102581 reg = ++pParse->nMem;
102582 }else{
102583 reg = 0;
102584 for(i=0; i<pIdx->nColumn; i++){
102585 if( aXRef[pIdx->aiColumn[i]]>=0 ){
@@ -105115,11 +105312,11 @@
105115 ** the pWC->a[] array.
105116 */
105117 static int whereClauseInsert(WhereClause *pWC, Expr *p, u8 wtFlags){
105118 WhereTerm *pTerm;
105119 int idx;
105120 testcase( wtFlags & TERM_VIRTUAL ); /* EV: R-00211-15100 */
105121 if( pWC->nTerm>=pWC->nSlot ){
105122 WhereTerm *pOld = pWC->a;
105123 sqlite3 *db = pWC->pWInfo->pParse->db;
105124 pWC->a = sqlite3DbMallocRaw(db, sizeof(pWC->a[0])*pWC->nSlot*2 );
105125 if( pWC->a==0 ){
@@ -105260,17 +105457,10 @@
105260
105261 /*
105262 ** Return TRUE if the given operator is one of the operators that is
105263 ** allowed for an indexable WHERE clause term. The allowed operators are
105264 ** "=", "<", ">", "<=", ">=", "IN", and "IS NULL"
105265 **
105266 ** IMPLEMENTATION-OF: R-59926-26393 To be usable by an index a term must be
105267 ** of one of the following forms: column = expression column > expression
105268 ** column >= expression column < expression column <= expression
105269 ** expression = column expression > column expression >= column
105270 ** expression < column expression <= column column IN
105271 ** (expression-list) column IN (subquery) column IS NULL
105272 */
105273 static int allowedOp(int op){
105274 assert( TK_GT>TK_EQ && TK_GT<TK_GE );
105275 assert( TK_LT>TK_EQ && TK_LT<TK_GE );
105276 assert( TK_LE>TK_EQ && TK_LE<TK_GE );
@@ -105585,11 +105775,11 @@
105585 op = pRight->op2;
105586 }
105587 if( op==TK_VARIABLE ){
105588 Vdbe *pReprepare = pParse->pReprepare;
105589 int iCol = pRight->iColumn;
105590 pVal = sqlite3VdbeGetValue(pReprepare, iCol, SQLITE_AFF_NONE);
105591 if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
105592 z = (char *)sqlite3_value_text(pVal);
105593 }
105594 sqlite3VdbeSetVarmask(pParse->pVdbe, iCol);
105595 assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );
@@ -105940,12 +106130,10 @@
105940 }
105941
105942 /* At this point, okToChngToIN is true if original pTerm satisfies
105943 ** case 1. In that case, construct a new virtual term that is
105944 ** pTerm converted into an IN operator.
105945 **
105946 ** EV: R-00211-15100
105947 */
105948 if( okToChngToIN ){
105949 Expr *pDup; /* A transient duplicate expression */
105950 ExprList *pList = 0; /* The RHS of the IN operator */
105951 Expr *pLeft = 0; /* The LHS of the IN operator */
@@ -106183,13 +106371,11 @@
106183 ** wildcard. But if we increment '@', that will push it into the
106184 ** alphabetic range where case conversions will mess up the
106185 ** inequality. To avoid this, make sure to also run the full
106186 ** LIKE on all candidate expressions by clearing the isComplete flag
106187 */
106188 if( c=='A'-1 ) isComplete = 0; /* EV: R-64339-08207 */
106189
106190
106191 c = sqlite3UpperToLower[c];
106192 }
106193 *pC = c + 1;
106194 }
106195 sCollSeqName.z = noCase ? "NOCASE" : "BINARY";
@@ -106692,11 +106878,11 @@
106692 VdbeComment((v, "for %s", pTable->zName));
106693
106694 /* Fill the automatic index with content */
106695 addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur);
106696 regRecord = sqlite3GetTempReg(pParse);
106697 sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 1);
106698 sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
106699 sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
106700 sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1);
106701 sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
106702 sqlite3VdbeJumpHere(v, addrTop);
@@ -107049,11 +107235,11 @@
107049 if( pExpr->op==TK_VARIABLE
107050 || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
107051 ){
107052 int iVar = pExpr->iColumn;
107053 sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);
107054 *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff);
107055 return SQLITE_OK;
107056 }
107057 return sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, aff, pp);
107058 }
107059 #endif
@@ -107275,13 +107461,10 @@
107275 **
107276 ** The t2.z='ok' is disabled in the in (2) because it originates
107277 ** in the ON clause. The term is disabled in (3) because it is not part
107278 ** of a LEFT OUTER JOIN. In (1), the term is not disabled.
107279 **
107280 ** IMPLEMENTATION-OF: R-24597-58655 No tests are done for terms that are
107281 ** completely satisfied by indices.
107282 **
107283 ** Disabling a term causes that term to not be tested in the inner loop
107284 ** of the join. Disabling is an optimization. When terms are satisfied
107285 ** by indices, we disable them to prevent redundant tests in the inner
107286 ** loop. We would get the correct results if nothing were ever disabled,
107287 ** but joins might run a little slower. The trick is to disable as much
@@ -107507,11 +107690,11 @@
107507 pTerm = pLoop->aLTerm[j];
107508 assert( pTerm!=0 );
107509 /* The following true for indices with redundant columns.
107510 ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */
107511 testcase( (pTerm->wtFlags & TERM_CODED)!=0 );
107512 testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
107513 r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, regBase+j);
107514 if( r1!=regBase+j ){
107515 if( nReg==1 ){
107516 sqlite3ReleaseTempReg(pParse, regBase);
107517 regBase = r1;
@@ -107707,10 +107890,11 @@
107707 WhereLevel *pLevel; /* The where level to be coded */
107708 WhereLoop *pLoop; /* The WhereLoop object being coded */
107709 WhereClause *pWC; /* Decomposition of the entire WHERE clause */
107710 WhereTerm *pTerm; /* A WHERE clause term */
107711 Parse *pParse; /* Parsing context */
 
107712 Vdbe *v; /* The prepared stmt under constructions */
107713 struct SrcList_item *pTabItem; /* FROM clause term being coded */
107714 int addrBrk; /* Jump here to break out of the loop */
107715 int addrCont; /* Jump here to continue with next cycle */
107716 int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
@@ -107718,10 +107902,11 @@
107718 Bitmask newNotReady; /* Return value */
107719
107720 pParse = pWInfo->pParse;
107721 v = pParse->pVdbe;
107722 pWC = &pWInfo->sWC;
 
107723 pLevel = &pWInfo->a[iLevel];
107724 pLoop = pLevel->pWLoop;
107725 pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
107726 iCur = pTabItem->iCursor;
107727 bRev = (pWInfo->revMask>>iLevel)&1;
@@ -107816,11 +108001,11 @@
107816 iReleaseReg = sqlite3GetTempReg(pParse);
107817 pTerm = pLoop->aLTerm[0];
107818 assert( pTerm!=0 );
107819 assert( pTerm->pExpr!=0 );
107820 assert( omitTable==0 );
107821 testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
107822 iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
107823 addrNxt = pLevel->addrNxt;
107824 sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt);
107825 sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg);
107826 sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1);
@@ -107864,11 +108049,11 @@
107864 assert( TK_LE==TK_GT+1 ); /* Make sure the ordering.. */
107865 assert( TK_LT==TK_GT+2 ); /* ... of the TK_xx values... */
107866 assert( TK_GE==TK_GT+3 ); /* ... is correcct. */
107867
107868 assert( (pStart->wtFlags & TERM_VNULL)==0 );
107869 testcase( pStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
107870 pX = pStart->pExpr;
107871 assert( pX!=0 );
107872 testcase( pStart->leftCursor!=iCur ); /* transitive constraints */
107873 r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);
107874 sqlite3VdbeAddOp3(v, aMoveOp[pX->op-TK_GT], iCur, addrBrk, r1);
@@ -107883,11 +108068,11 @@
107883 Expr *pX;
107884 pX = pEnd->pExpr;
107885 assert( pX!=0 );
107886 assert( (pEnd->wtFlags & TERM_VNULL)==0 );
107887 testcase( pEnd->leftCursor!=iCur ); /* Transitive constraints */
107888 testcase( pEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
107889 memEndValue = ++pParse->nMem;
107890 sqlite3ExprCode(pParse, pX->pRight, memEndValue);
107891 if( pX->op==TK_LT || pX->op==TK_GT ){
107892 testOp = bRev ? OP_Le : OP_Ge;
107893 }else{
@@ -108008,11 +108193,11 @@
108008 /* Generate code to evaluate all constraint terms using == or IN
108009 ** and store the values of those terms in an array of registers
108010 ** starting at regBase.
108011 */
108012 regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
108013 zEndAff = sqlite3DbStrDup(pParse->db, zStartAff);
108014 addrNxt = pLevel->addrNxt;
108015
108016 /* If we are doing a reverse order scan on an ascending index, or
108017 ** a forward order scan on a descending index, interchange the
108018 ** start and end terms (pRangeStart and pRangeEnd).
@@ -108049,11 +108234,11 @@
108049 if( sqlite3ExprNeedsNoAffinityChange(pRight, zStartAff[nEq]) ){
108050 zStartAff[nEq] = SQLITE_AFF_NONE;
108051 }
108052 }
108053 nConstraint++;
108054 testcase( pRangeStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108055 }else if( isMinQuery ){
108056 sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
108057 nConstraint++;
108058 startEq = 0;
108059 start_constraints = 1;
@@ -108091,14 +108276,14 @@
108091 zEndAff[nEq] = SQLITE_AFF_NONE;
108092 }
108093 }
108094 codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
108095 nConstraint++;
108096 testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108097 }
108098 sqlite3DbFree(pParse->db, zStartAff);
108099 sqlite3DbFree(pParse->db, zEndAff);
108100
108101 /* Top of the loop body */
108102 pLevel->p2 = sqlite3VdbeCurrentAddr(v);
108103
108104 /* Check if the index cursor is past the end of the range. */
@@ -108221,11 +108406,11 @@
108221 */
108222 if( pWInfo->nLevel>1 ){
108223 int nNotReady; /* The number of notReady tables */
108224 struct SrcList_item *origSrc; /* Original list of tables */
108225 nNotReady = pWInfo->nLevel - iLevel - 1;
108226 pOrTab = sqlite3StackAllocRaw(pParse->db,
108227 sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
108228 if( pOrTab==0 ) return notReady;
108229 pOrTab->nAlloc = (u8)(nNotReady + 1);
108230 pOrTab->nSrc = pOrTab->nAlloc;
108231 memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
@@ -108275,12 +108460,12 @@
108275 Expr *pExpr = pWC->a[iTerm].pExpr;
108276 if( &pWC->a[iTerm] == pTerm ) continue;
108277 if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
108278 if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue;
108279 if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
108280 pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
108281 pAndExpr = sqlite3ExprAnd(pParse->db, pAndExpr, pExpr);
108282 }
108283 if( pAndExpr ){
108284 pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);
108285 }
108286 }
@@ -108296,11 +108481,11 @@
108296 }
108297 /* Loop through table entries that match term pOrTerm. */
108298 pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
108299 WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
108300 WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);
108301 assert( pSubWInfo || pParse->nErr || pParse->db->mallocFailed );
108302 if( pSubWInfo ){
108303 WhereLoop *pSubLoop;
108304 explainOneScan(
108305 pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
108306 );
@@ -108351,17 +108536,17 @@
108351 }
108352 pLevel->u.pCovidx = pCov;
108353 if( pCov ) pLevel->iIdxCur = iCovCur;
108354 if( pAndExpr ){
108355 pAndExpr->pLeft = 0;
108356 sqlite3ExprDelete(pParse->db, pAndExpr);
108357 }
108358 sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
108359 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
108360 sqlite3VdbeResolveLabel(v, iLoopBody);
108361
108362 if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab);
108363 if( !untestedTerms ) disableTerm(pLevel, pTerm);
108364 }else
108365 #endif /* SQLITE_OMIT_OR_OPTIMIZATION */
108366
108367 {
@@ -108378,18 +108563,14 @@
108378 }
108379 newNotReady = notReady & ~getMask(&pWInfo->sMaskSet, iCur);
108380
108381 /* Insert code to test every subexpression that can be completely
108382 ** computed using the current set of tables.
108383 **
108384 ** IMPLEMENTATION-OF: R-49525-50935 Terms that cannot be satisfied through
108385 ** the use of indices become tests that are evaluated against each row of
108386 ** the relevant input tables.
108387 */
108388 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108389 Expr *pE;
108390 testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */
108391 testcase( pTerm->wtFlags & TERM_CODED );
108392 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108393 if( (pTerm->prereqAll & newNotReady)!=0 ){
108394 testcase( pWInfo->untestedTerms==0
108395 && (pWInfo->wctrlFlags & WHERE_ONETABLE_ONLY)!=0 );
@@ -108412,13 +108593,12 @@
108412 ** and we are coding the t1 loop and the t2 loop has not yet coded,
108413 ** then we cannot use the "t1.a=t2.b" constraint, but we can code
108414 ** the implied "t1.a=123" constraint.
108415 */
108416 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108417 Expr *pE;
108418 WhereTerm *pAlt;
108419 Expr sEq;
108420 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108421 if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108422 if( pTerm->leftCursor!=iCur ) continue;
108423 if( pLevel->iLeftJoin ) continue;
108424 pE = pTerm->pExpr;
@@ -108428,13 +108608,17 @@
108428 if( pAlt==0 ) continue;
108429 if( pAlt->wtFlags & (TERM_CODED) ) continue;
108430 testcase( pAlt->eOperator & WO_EQ );
108431 testcase( pAlt->eOperator & WO_IN );
108432 VdbeNoopComment((v, "begin transitive constraint"));
108433 sEq = *pAlt->pExpr;
108434 sEq.pLeft = pE->pLeft;
108435 sqlite3ExprIfFalse(pParse, &sEq, addrCont, SQLITE_JUMPIFNULL);
 
 
 
 
108436 }
108437
108438 /* For a LEFT OUTER JOIN, generate code that will record the fact that
108439 ** at least one row of the right table has matched the left table.
108440 */
@@ -108442,11 +108626,11 @@
108442 pLevel->addrFirst = sqlite3VdbeCurrentAddr(v);
108443 sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin);
108444 VdbeComment((v, "record LEFT JOIN hit"));
108445 sqlite3ExprCacheClear(pParse);
108446 for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){
108447 testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */
108448 testcase( pTerm->wtFlags & TERM_CODED );
108449 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108450 if( (pTerm->prereqAll & newNotReady)!=0 ){
108451 assert( pWInfo->untestedTerms );
108452 continue;
@@ -108883,11 +109067,12 @@
108883 rc = whereEqualScanEst(pParse, pProbe, pTerm->pExpr->pRight, &nOut);
108884 }else if( (pTerm->eOperator & WO_IN)
108885 && !ExprHasProperty(pTerm->pExpr, EP_xIsSelect) ){
108886 rc = whereInScanEst(pParse, pProbe, pTerm->pExpr->x.pList, &nOut);
108887 }
108888 if( rc==SQLITE_OK ) pNew->nOut = whereCost(nOut);
 
108889 }
108890 #endif
108891 if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
108892 /* Each row involves a step of the index, then a binary search of
108893 ** the main table */
@@ -108955,10 +109140,21 @@
108955 if( x<BMS-1 ) m |= MASKBIT(x);
108956 }
108957 return m;
108958 }
108959
 
 
 
 
 
 
 
 
 
 
 
108960
108961 /*
108962 ** Add all WhereLoop objects for a single table of the join where the table
108963 ** is idenfied by pBuilder->pNew->iTab. That table is guaranteed to be
108964 ** a b-tree table, not a virtual table.
@@ -108978,15 +109174,17 @@
108978 int rc = SQLITE_OK; /* Return code */
108979 int iSortIdx = 1; /* Index number */
108980 int b; /* A boolean value */
108981 WhereCost rSize; /* number of rows in the table */
108982 WhereCost rLogSize; /* Logarithm of the number of rows in the table */
 
108983
108984 pNew = pBuilder->pNew;
108985 pWInfo = pBuilder->pWInfo;
108986 pTabList = pWInfo->pTabList;
108987 pSrc = pTabList->a + pNew->iTab;
 
108988 assert( !IsVirtual(pSrc->pTab) );
108989
108990 if( pSrc->pIndex ){
108991 /* An INDEXED BY clause specifies a particular index to use */
108992 pProbe = pSrc->pIndex;
@@ -109022,11 +109220,10 @@
109022 && !pSrc->viaCoroutine
109023 && !pSrc->notIndexed
109024 && !pSrc->isCorrelated
109025 ){
109026 /* Generate auto-index WhereLoops */
109027 WhereClause *pWC = pBuilder->pWC;
109028 WhereTerm *pTerm;
109029 WhereTerm *pWCEnd = pWC->a + pWC->nTerm;
109030 for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){
109031 if( pTerm->prereqRight & pNew->maskSelf ) continue;
109032 if( termCanDriveIndex(pTerm, pSrc, 0) ){
@@ -109052,10 +109249,14 @@
109052 }
109053
109054 /* Loop over all indices
109055 */
109056 for(; rc==SQLITE_OK && pProbe; pProbe=pProbe->pNext, iSortIdx++){
 
 
 
 
109057 pNew->u.btree.nEq = 0;
109058 pNew->nLTerm = 0;
109059 pNew->iSortIdx = 0;
109060 pNew->rSetup = 0;
109061 pNew->prereq = mExtra;
@@ -109992,11 +110193,11 @@
109992 pLoop->u.btree.nEq = 1;
109993 /* TUNING: Cost of a rowid lookup is 10 */
109994 pLoop->rRun = 33; /* 33==whereCost(10) */
109995 }else{
109996 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
109997 if( pIdx->onError==OE_None ) continue;
109998 for(j=0; j<pIdx->nColumn; j++){
109999 pTerm = findTerm(pWC, iCur, pIdx->aiColumn[j], 0, WO_EQ, pIdx);
110000 if( pTerm==0 ) break;
110001 whereLoopResize(pWInfo->pParse->db, pLoop, j);
110002 pLoop->aLTerm[j] = pTerm;
@@ -110198,11 +110399,11 @@
110198 ** subexpression is separated by an AND operator.
110199 */
110200 initMaskSet(pMaskSet);
110201 whereClauseInit(&pWInfo->sWC, pWInfo);
110202 sqlite3ExprCodeConstants(pParse, pWhere);
110203 whereSplit(&pWInfo->sWC, pWhere, TK_AND); /* IMP: R-15842-53296 */
110204 sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */
110205
110206 /* Special case: a WHERE clause that is constant. Evaluate the
110207 ** expression and either jump over all of the code or fall thru.
110208 */
@@ -110832,11 +111033,11 @@
110832 #endif
110833 #define sqlite3ParserARG_SDECL Parse *pParse;
110834 #define sqlite3ParserARG_PDECL ,Parse *pParse
110835 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
110836 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
110837 #define YYNSTATE 627
110838 #define YYNRULE 327
110839 #define YYFALLBACK 1
110840 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
110841 #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
110842 #define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
@@ -110905,167 +111106,167 @@
110905 ** shifting non-terminals after a reduce.
110906 ** yy_default[] Default action for each state.
110907 */
110908 #define YY_ACTTAB_COUNT (1564)
110909 static const YYACTIONTYPE yy_action[] = {
110910 /* 0 */ 309, 955, 184, 417, 2, 171, 624, 594, 56, 56,
110911 /* 10 */ 56, 56, 49, 54, 54, 54, 54, 53, 53, 52,
110912 /* 20 */ 52, 52, 51, 233, 620, 619, 298, 620, 619, 234,
110913 /* 30 */ 587, 581, 56, 56, 56, 56, 19, 54, 54, 54,
110914 /* 40 */ 54, 53, 53, 52, 52, 52, 51, 233, 605, 57,
110915 /* 50 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56,
110916 /* 60 */ 56, 56, 541, 54, 54, 54, 54, 53, 53, 52,
110917 /* 70 */ 52, 52, 51, 233, 309, 594, 325, 196, 195, 194,
110918 /* 80 */ 33, 54, 54, 54, 54, 53, 53, 52, 52, 52,
110919 /* 90 */ 51, 233, 617, 616, 165, 617, 616, 380, 377, 376,
110920 /* 100 */ 407, 532, 576, 576, 587, 581, 303, 422, 375, 59,
110921 /* 110 */ 53, 53, 52, 52, 52, 51, 233, 50, 47, 146,
110922 /* 120 */ 574, 545, 65, 57, 58, 48, 579, 578, 580, 580,
110923 /* 130 */ 55, 55, 56, 56, 56, 56, 213, 54, 54, 54,
110924 /* 140 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 223,
110925 /* 150 */ 539, 420, 170, 176, 138, 280, 383, 275, 382, 168,
110926 /* 160 */ 489, 551, 409, 668, 620, 619, 271, 438, 409, 438,
110927 /* 170 */ 550, 604, 67, 482, 507, 618, 599, 412, 587, 581,
110928 /* 180 */ 600, 483, 618, 412, 618, 598, 91, 439, 440, 439,
110929 /* 190 */ 335, 598, 73, 669, 222, 266, 480, 57, 58, 48,
110930 /* 200 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56,
110931 /* 210 */ 670, 54, 54, 54, 54, 53, 53, 52, 52, 52,
110932 /* 220 */ 51, 233, 309, 279, 232, 231, 1, 132, 200, 385,
110933 /* 230 */ 620, 619, 617, 616, 278, 435, 289, 563, 175, 262,
110934 /* 240 */ 409, 264, 437, 497, 436, 166, 441, 568, 336, 568,
110935 /* 250 */ 201, 537, 587, 581, 599, 412, 165, 594, 600, 380,
110936 /* 260 */ 377, 376, 597, 598, 92, 523, 618, 569, 569, 592,
110937 /* 270 */ 375, 57, 58, 48, 579, 578, 580, 580, 55, 55,
110938 /* 280 */ 56, 56, 56, 56, 597, 54, 54, 54, 54, 53,
110939 /* 290 */ 53, 52, 52, 52, 51, 233, 309, 463, 617, 616,
110940 /* 300 */ 590, 590, 590, 174, 272, 396, 409, 272, 409, 548,
110941 /* 310 */ 397, 620, 619, 68, 326, 620, 619, 620, 619, 618,
110942 /* 320 */ 546, 412, 618, 412, 471, 594, 587, 581, 472, 598,
110943 /* 330 */ 92, 598, 92, 52, 52, 52, 51, 233, 513, 512,
110944 /* 340 */ 206, 322, 363, 464, 221, 57, 58, 48, 579, 578,
110945 /* 350 */ 580, 580, 55, 55, 56, 56, 56, 56, 529, 54,
110946 /* 360 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
110947 /* 370 */ 309, 396, 409, 396, 597, 372, 386, 530, 347, 617,
110948 /* 380 */ 616, 575, 202, 617, 616, 617, 616, 412, 620, 619,
110949 /* 390 */ 145, 255, 346, 254, 577, 598, 74, 351, 45, 489,
110950 /* 400 */ 587, 581, 235, 189, 464, 544, 167, 296, 187, 469,
110951 /* 410 */ 479, 67, 62, 39, 618, 546, 597, 345, 573, 57,
110952 /* 420 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56,
110953 /* 430 */ 56, 56, 6, 54, 54, 54, 54, 53, 53, 52,
110954 /* 440 */ 52, 52, 51, 233, 309, 562, 558, 407, 528, 576,
110955 /* 450 */ 576, 344, 255, 346, 254, 182, 617, 616, 503, 504,
110956 /* 460 */ 314, 409, 557, 235, 166, 271, 409, 352, 564, 181,
110957 /* 470 */ 407, 546, 576, 576, 587, 581, 412, 537, 556, 561,
110958 /* 480 */ 517, 412, 618, 249, 598, 16, 7, 36, 467, 598,
110959 /* 490 */ 92, 516, 618, 57, 58, 48, 579, 578, 580, 580,
110960 /* 500 */ 55, 55, 56, 56, 56, 56, 541, 54, 54, 54,
110961 /* 510 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 327,
110962 /* 520 */ 572, 571, 525, 558, 560, 394, 871, 246, 409, 248,
110963 /* 530 */ 171, 392, 594, 219, 407, 409, 576, 576, 502, 557,
110964 /* 540 */ 364, 145, 510, 412, 407, 229, 576, 576, 587, 581,
110965 /* 550 */ 412, 598, 92, 381, 269, 556, 166, 400, 598, 69,
110966 /* 560 */ 501, 419, 945, 199, 945, 198, 546, 57, 58, 48,
110967 /* 570 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56,
110968 /* 580 */ 568, 54, 54, 54, 54, 53, 53, 52, 52, 52,
110969 /* 590 */ 51, 233, 309, 317, 419, 944, 508, 944, 308, 597,
110970 /* 600 */ 594, 565, 490, 212, 173, 247, 423, 615, 614, 613,
110971 /* 610 */ 323, 197, 143, 405, 572, 571, 489, 66, 50, 47,
110972 /* 620 */ 146, 594, 587, 581, 232, 231, 559, 427, 67, 555,
110973 /* 630 */ 15, 618, 186, 543, 303, 421, 35, 206, 432, 423,
110974 /* 640 */ 552, 57, 58, 48, 579, 578, 580, 580, 55, 55,
110975 /* 650 */ 56, 56, 56, 56, 205, 54, 54, 54, 54, 53,
110976 /* 660 */ 53, 52, 52, 52, 51, 233, 309, 569, 569, 260,
110977 /* 670 */ 268, 597, 12, 373, 568, 166, 409, 313, 409, 420,
110978 /* 680 */ 409, 473, 473, 365, 618, 50, 47, 146, 597, 594,
110979 /* 690 */ 468, 412, 166, 412, 351, 412, 587, 581, 32, 598,
110980 /* 700 */ 94, 598, 97, 598, 95, 627, 625, 329, 142, 50,
110981 /* 710 */ 47, 146, 333, 349, 358, 57, 58, 48, 579, 578,
110982 /* 720 */ 580, 580, 55, 55, 56, 56, 56, 56, 409, 54,
110983 /* 730 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
110984 /* 740 */ 309, 409, 388, 412, 409, 22, 565, 404, 212, 362,
110985 /* 750 */ 389, 598, 104, 359, 409, 156, 412, 409, 603, 412,
110986 /* 760 */ 537, 331, 569, 569, 598, 103, 493, 598, 105, 412,
110987 /* 770 */ 587, 581, 412, 260, 549, 618, 11, 598, 106, 521,
110988 /* 780 */ 598, 133, 169, 457, 456, 170, 35, 601, 618, 57,
110989 /* 790 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56,
110990 /* 800 */ 56, 56, 409, 54, 54, 54, 54, 53, 53, 52,
110991 /* 810 */ 52, 52, 51, 233, 309, 409, 259, 412, 409, 50,
110992 /* 820 */ 47, 146, 357, 318, 355, 598, 134, 527, 352, 337,
110993 /* 830 */ 412, 409, 356, 412, 357, 409, 357, 618, 598, 98,
110994 /* 840 */ 129, 598, 102, 618, 587, 581, 412, 21, 235, 618,
110995 /* 850 */ 412, 618, 211, 143, 598, 101, 30, 167, 598, 93,
110996 /* 860 */ 350, 535, 203, 57, 58, 48, 579, 578, 580, 580,
110997 /* 870 */ 55, 55, 56, 56, 56, 56, 409, 54, 54, 54,
110998 /* 880 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 409,
110999 /* 890 */ 526, 412, 409, 425, 215, 305, 597, 551, 141, 598,
111000 /* 900 */ 100, 40, 409, 38, 412, 409, 550, 412, 409, 228,
111001 /* 910 */ 220, 314, 598, 77, 500, 598, 96, 412, 587, 581,
111002 /* 920 */ 412, 338, 253, 412, 218, 598, 137, 379, 598, 136,
111003 /* 930 */ 28, 598, 135, 270, 715, 210, 481, 57, 58, 48,
111004 /* 940 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56,
111005 /* 950 */ 409, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111006 /* 960 */ 51, 233, 309, 409, 272, 412, 409, 315, 147, 597,
111007 /* 970 */ 272, 626, 2, 598, 76, 209, 409, 127, 412, 618,
111008 /* 980 */ 126, 412, 409, 621, 235, 618, 598, 90, 374, 598,
111009 /* 990 */ 89, 412, 587, 581, 27, 260, 350, 412, 618, 598,
111010 /* 1000 */ 75, 321, 541, 541, 125, 598, 88, 320, 278, 597,
111011 /* 1010 */ 618, 57, 46, 48, 579, 578, 580, 580, 55, 55,
111012 /* 1020 */ 56, 56, 56, 56, 409, 54, 54, 54, 54, 53,
111013 /* 1030 */ 53, 52, 52, 52, 51, 233, 309, 409, 450, 412,
111014 /* 1040 */ 164, 284, 282, 272, 609, 424, 304, 598, 87, 370,
111015 /* 1050 */ 409, 477, 412, 409, 608, 409, 607, 602, 618, 618,
111016 /* 1060 */ 598, 99, 586, 585, 122, 412, 587, 581, 412, 618,
111017 /* 1070 */ 412, 618, 618, 598, 86, 366, 598, 17, 598, 85,
111018 /* 1080 */ 319, 185, 519, 518, 583, 582, 58, 48, 579, 578,
111019 /* 1090 */ 580, 580, 55, 55, 56, 56, 56, 56, 409, 54,
111020 /* 1100 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
111021 /* 1110 */ 309, 584, 409, 412, 409, 260, 260, 260, 408, 591,
111022 /* 1120 */ 474, 598, 84, 170, 409, 466, 518, 412, 121, 412,
111023 /* 1130 */ 618, 618, 618, 618, 618, 598, 83, 598, 72, 412,
111024 /* 1140 */ 587, 581, 51, 233, 625, 329, 470, 598, 71, 257,
111025 /* 1150 */ 159, 120, 14, 462, 157, 158, 117, 260, 448, 447,
111026 /* 1160 */ 446, 48, 579, 578, 580, 580, 55, 55, 56, 56,
111027 /* 1170 */ 56, 56, 618, 54, 54, 54, 54, 53, 53, 52,
111028 /* 1180 */ 52, 52, 51, 233, 44, 403, 260, 3, 409, 459,
111029 /* 1190 */ 260, 413, 619, 118, 398, 10, 25, 24, 554, 348,
111030 /* 1200 */ 217, 618, 406, 412, 409, 618, 4, 44, 403, 618,
111031 /* 1210 */ 3, 598, 82, 618, 413, 619, 455, 542, 115, 412,
111032 /* 1220 */ 538, 401, 536, 274, 506, 406, 251, 598, 81, 216,
111033 /* 1230 */ 273, 563, 618, 243, 453, 618, 154, 618, 618, 618,
111034 /* 1240 */ 449, 416, 623, 110, 401, 618, 409, 236, 64, 123,
111035 /* 1250 */ 487, 41, 42, 531, 563, 204, 409, 267, 43, 411,
111036 /* 1260 */ 410, 412, 265, 592, 108, 618, 107, 434, 332, 598,
111037 /* 1270 */ 80, 412, 618, 263, 41, 42, 443, 618, 409, 598,
111038 /* 1280 */ 70, 43, 411, 410, 433, 261, 592, 149, 618, 597,
111039 /* 1290 */ 256, 237, 188, 412, 590, 590, 590, 589, 588, 13,
111040 /* 1300 */ 618, 598, 18, 328, 235, 618, 44, 403, 360, 3,
111041 /* 1310 */ 418, 461, 339, 413, 619, 227, 124, 590, 590, 590,
111042 /* 1320 */ 589, 588, 13, 618, 406, 409, 618, 409, 139, 34,
111043 /* 1330 */ 403, 387, 3, 148, 622, 312, 413, 619, 311, 330,
111044 /* 1340 */ 412, 460, 412, 401, 180, 353, 412, 406, 598, 79,
111045 /* 1350 */ 598, 78, 250, 563, 598, 9, 618, 612, 611, 610,
111046 /* 1360 */ 618, 8, 452, 442, 242, 415, 401, 618, 239, 235,
111047 /* 1370 */ 179, 238, 428, 41, 42, 288, 563, 618, 618, 618,
111048 /* 1380 */ 43, 411, 410, 618, 144, 592, 618, 618, 177, 61,
111049 /* 1390 */ 618, 596, 391, 620, 619, 287, 41, 42, 414, 618,
111050 /* 1400 */ 293, 30, 393, 43, 411, 410, 292, 618, 592, 31,
111051 /* 1410 */ 618, 395, 291, 60, 230, 37, 590, 590, 590, 589,
111052 /* 1420 */ 588, 13, 214, 553, 183, 290, 172, 301, 300, 299,
111053 /* 1430 */ 178, 297, 595, 563, 451, 29, 285, 390, 540, 590,
111054 /* 1440 */ 590, 590, 589, 588, 13, 283, 520, 534, 150, 533,
111055 /* 1450 */ 241, 281, 384, 192, 191, 324, 515, 514, 276, 240,
111056 /* 1460 */ 510, 523, 307, 511, 128, 592, 509, 225, 226, 486,
111057 /* 1470 */ 485, 224, 152, 491, 464, 306, 484, 163, 153, 371,
111058 /* 1480 */ 478, 151, 162, 258, 369, 161, 367, 208, 475, 476,
111059 /* 1490 */ 26, 160, 465, 140, 361, 131, 590, 590, 590, 116,
111060 /* 1500 */ 119, 454, 343, 155, 114, 342, 113, 112, 445, 111,
111061 /* 1510 */ 130, 109, 431, 316, 426, 430, 23, 429, 20, 606,
111062 /* 1520 */ 190, 507, 255, 341, 244, 63, 294, 593, 310, 570,
111063 /* 1530 */ 277, 402, 354, 235, 567, 496, 495, 492, 494, 302,
111064 /* 1540 */ 458, 378, 286, 245, 566, 5, 252, 547, 193, 444,
111065 /* 1550 */ 233, 340, 207, 524, 368, 505, 334, 522, 499, 399,
111066 /* 1560 */ 295, 498, 956, 488,
111067 };
111068 static const YYCODETYPE yy_lookahead[] = {
111069 /* 0 */ 19, 142, 143, 144, 145, 24, 1, 26, 77, 78,
111070 /* 10 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
111071 /* 20 */ 89, 90, 91, 92, 26, 27, 15, 26, 27, 197,
@@ -111213,21 +111414,21 @@
111213 /* 1440 */ 130, 131, 132, 133, 134, 210, 175, 211, 31, 211,
111214 /* 1450 */ 33, 210, 104, 86, 87, 47, 175, 183, 175, 42,
111215 /* 1460 */ 103, 94, 178, 177, 22, 98, 175, 92, 228, 175,
111216 /* 1470 */ 175, 228, 55, 183, 57, 178, 175, 156, 61, 18,
111217 /* 1480 */ 157, 64, 156, 235, 157, 156, 45, 157, 236, 157,
111218 /* 1490 */ 135, 156, 189, 68, 157, 218, 129, 130, 131, 22,
111219 /* 1500 */ 189, 199, 157, 156, 192, 18, 192, 192, 199, 192,
111220 /* 1510 */ 218, 189, 40, 157, 38, 157, 240, 157, 240, 153,
111221 /* 1520 */ 196, 181, 105, 106, 107, 243, 198, 166, 111, 230,
111222 /* 1530 */ 176, 226, 239, 116, 230, 176, 166, 166, 176, 148,
111223 /* 1540 */ 199, 177, 209, 209, 166, 196, 239, 208, 185, 199,
111224 /* 1550 */ 92, 209, 233, 173, 234, 182, 139, 173, 182, 191,
111225 /* 1560 */ 195, 182, 250, 186,
111226 };
111227 #define YY_SHIFT_USE_DFLT (-70)
111228 #define YY_SHIFT_COUNT (416)
111229 #define YY_SHIFT_MIN (-69)
111230 #define YY_SHIFT_MAX (1487)
111231 static const short yy_shift_ofst[] = {
111232 /* 0 */ 1143, 1188, 1417, 1188, 1287, 1287, 138, 138, -2, -19,
111233 /* 10 */ 1287, 1287, 1287, 1287, 347, 362, 129, 129, 795, 1165,
@@ -111240,44 +111441,44 @@
111240 /* 80 */ 869, 869, 869, 869, 869, 869, 869, 869, 869, 869,
111241 /* 90 */ 869, 869, 869, 943, 869, 1017, 1091, 1091, -69, -45,
111242 /* 100 */ -45, -45, -45, -45, -1, 24, 245, 362, 362, 362,
111243 /* 110 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111244 /* 120 */ 362, 362, 362, 388, 356, 362, 362, 362, 362, 362,
111245 /* 130 */ 732, 868, 231, 1051, 1458, -70, -70, -70, 1367, 57,
111246 /* 140 */ 434, 434, 289, 291, 285, 1, 204, 572, 539, 362,
111247 /* 150 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111248 /* 160 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111249 /* 170 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111250 /* 180 */ 362, 506, 506, 506, 705, 1253, 1253, 1253, -70, -70,
111251 /* 190 */ -70, 171, 171, 160, 502, 502, 502, 446, 432, 511,
111252 /* 200 */ 422, 358, 335, -12, -12, -12, -12, 576, 294, -12,
111253 /* 210 */ -12, 295, 595, 141, 600, 730, 723, 723, 805, 730,
111254 /* 220 */ 805, 439, 911, 231, 865, 231, 865, 807, 865, 723,
111255 /* 230 */ 766, 633, 633, 231, 284, 63, 608, 1476, 1308, 1308,
111256 /* 240 */ 1472, 1472, 1308, 1477, 1425, 1275, 1487, 1487, 1487, 1487,
111257 /* 250 */ 1308, 1461, 1275, 1477, 1425, 1425, 1308, 1461, 1355, 1441,
111258 /* 260 */ 1308, 1308, 1461, 1308, 1461, 1308, 1461, 1442, 1348, 1348,
111259 /* 270 */ 1348, 1408, 1375, 1375, 1442, 1348, 1357, 1348, 1408, 1348,
111260 /* 280 */ 1348, 1316, 1331, 1316, 1331, 1316, 1331, 1308, 1308, 1280,
111261 /* 290 */ 1288, 1289, 1285, 1279, 1275, 1253, 1336, 1346, 1346, 1338,
111262 /* 300 */ 1338, 1338, 1338, -70, -70, -70, -70, -70, -70, 1013,
111263 /* 310 */ 467, 612, 84, 179, -28, 870, 410, 761, 760, 667,
111264 /* 320 */ 650, 531, 220, 361, 331, 125, 127, 97, 1306, 1300,
111265 /* 330 */ 1270, 1151, 1272, 1203, 1232, 1261, 1244, 1148, 1174, 1139,
111266 /* 340 */ 1156, 1124, 1220, 1115, 1210, 1233, 1099, 1193, 1184, 1174,
111267 /* 350 */ 1173, 1029, 1121, 1120, 1085, 1162, 1119, 1037, 1152, 1147,
111268 /* 360 */ 1129, 1046, 1011, 1093, 1098, 1075, 1061, 1032, 960, 1057,
111269 /* 370 */ 1031, 1030, 899, 938, 982, 936, 972, 958, 910, 955,
111270 /* 380 */ 875, 885, 908, 857, 859, 867, 804, 590, 834, 747,
111271 /* 390 */ 818, 513, 611, 741, 673, 637, 611, 606, 603, 579,
111272 /* 400 */ 501, 541, 468, 386, 445, 395, 376, 281, 185, 120,
111273 /* 410 */ 92, 75, 45, 114, 25, 11, 5,
111274 };
111275 #define YY_REDUCE_USE_DFLT (-169)
111276 #define YY_REDUCE_COUNT (308)
111277 #define YY_REDUCE_MIN (-168)
111278 #define YY_REDUCE_MAX (1391)
111279 static const short yy_reduce_ofst[] = {
111280 /* 0 */ -141, 90, 1095, 222, 158, 156, 19, 17, 10, -104,
111281 /* 10 */ 378, 316, 311, 12, 180, 249, 598, 464, 397, 1181,
111282 /* 20 */ 1177, 1175, 1128, 1106, 1096, 1054, 1038, 974, 964, 962,
111283 /* 30 */ 948, 905, 903, 900, 887, 874, 832, 826, 816, 813,
@@ -111294,87 +111495,87 @@
111294 /* 140 */ 935, 892, 968, 1245, 1242, 1234, 1225, 798, 798, 1222,
111295 /* 150 */ 1221, 1218, 1214, 1213, 1212, 1202, 1195, 1191, 1161, 1158,
111296 /* 160 */ 1140, 1135, 1123, 1112, 1107, 1100, 1080, 1074, 1073, 1072,
111297 /* 170 */ 1070, 1067, 1048, 1044, 969, 968, 907, 906, 904, 894,
111298 /* 180 */ 833, 837, 836, 340, 827, 815, 775, 68, 722, 646,
111299 /* 190 */ -168, 1384, 1380, 1377, 1379, 1376, 1373, 1339, 1365, 1368,
111300 /* 200 */ 1365, 1365, 1365, 1365, 1365, 1365, 1365, 1320, 1319, 1365,
111301 /* 210 */ 1365, 1339, 1378, 1349, 1391, 1350, 1342, 1334, 1307, 1341,
111302 /* 220 */ 1293, 1364, 1363, 1371, 1362, 1370, 1359, 1340, 1354, 1333,
111303 /* 230 */ 1305, 1304, 1299, 1361, 1328, 1324, 1366, 1282, 1360, 1358,
111304 /* 240 */ 1278, 1276, 1356, 1292, 1322, 1309, 1317, 1315, 1314, 1312,
111305 /* 250 */ 1345, 1347, 1302, 1277, 1311, 1303, 1337, 1335, 1252, 1248,
111306 /* 260 */ 1332, 1330, 1329, 1327, 1326, 1323, 1321, 1297, 1301, 1295,
111307 /* 270 */ 1294, 1290, 1243, 1240, 1284, 1291, 1286, 1283, 1274, 1281,
111308 /* 280 */ 1271, 1238, 1241, 1236, 1235, 1227, 1226, 1267, 1266, 1189,
111309 /* 290 */ 1229, 1223, 1211, 1206, 1201, 1197, 1239, 1237, 1219, 1216,
111310 /* 300 */ 1209, 1208, 1185, 1089, 1086, 1087, 1137, 1136, 1164,
111311 };
111312 static const YYACTIONTYPE yy_default[] = {
111313 /* 0 */ 632, 866, 954, 954, 866, 866, 954, 954, 954, 756,
111314 /* 10 */ 954, 954, 954, 864, 954, 954, 784, 784, 928, 954,
111315 /* 20 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111316 /* 30 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111317 /* 40 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111318 /* 50 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111319 /* 60 */ 954, 954, 954, 954, 954, 954, 954, 671, 760, 790,
111320 /* 70 */ 954, 954, 954, 954, 954, 954, 954, 954, 927, 929,
111321 /* 80 */ 798, 797, 907, 771, 795, 788, 792, 867, 860, 861,
111322 /* 90 */ 859, 863, 868, 954, 791, 827, 844, 826, 838, 843,
111323 /* 100 */ 850, 842, 839, 829, 828, 830, 831, 954, 954, 954,
111324 /* 110 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111325 /* 120 */ 954, 954, 954, 658, 725, 954, 954, 954, 954, 954,
111326 /* 130 */ 954, 954, 954, 832, 833, 847, 846, 845, 954, 663,
111327 /* 140 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111328 /* 150 */ 934, 932, 954, 879, 954, 954, 954, 954, 954, 954,
111329 /* 160 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111330 /* 170 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111331 /* 180 */ 638, 756, 756, 756, 632, 954, 954, 954, 946, 760,
111332 /* 190 */ 750, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111333 /* 200 */ 954, 954, 954, 800, 739, 917, 919, 954, 900, 737,
111334 /* 210 */ 660, 758, 673, 748, 640, 794, 773, 773, 912, 794,
111335 /* 220 */ 912, 696, 719, 954, 784, 954, 784, 693, 784, 773,
111336 /* 230 */ 862, 954, 954, 954, 757, 748, 954, 939, 764, 764,
111337 /* 240 */ 931, 931, 764, 806, 729, 794, 736, 736, 736, 736,
111338 /* 250 */ 764, 655, 794, 806, 729, 729, 764, 655, 906, 904,
111339 /* 260 */ 764, 764, 655, 764, 655, 764, 655, 872, 727, 727,
111340 /* 270 */ 727, 711, 876, 876, 872, 727, 696, 727, 711, 727,
111341 /* 280 */ 727, 777, 772, 777, 772, 777, 772, 764, 764, 954,
111342 /* 290 */ 789, 778, 787, 785, 794, 954, 714, 648, 648, 637,
111343 /* 300 */ 637, 637, 637, 951, 951, 946, 698, 698, 681, 954,
111344 /* 310 */ 954, 954, 954, 954, 954, 954, 881, 954, 954, 954,
111345 /* 320 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 633,
111346 /* 330 */ 941, 954, 954, 938, 954, 954, 954, 954, 799, 954,
111347 /* 340 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 916,
111348 /* 350 */ 954, 954, 954, 954, 954, 954, 954, 910, 954, 954,
111349 /* 360 */ 954, 954, 954, 954, 903, 902, 954, 954, 954, 954,
111350 /* 370 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111351 /* 380 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111352 /* 390 */ 954, 954, 786, 954, 779, 954, 865, 954, 954, 954,
111353 /* 400 */ 954, 954, 954, 954, 954, 954, 954, 742, 815, 954,
111354 /* 410 */ 814, 818, 813, 665, 954, 646, 954, 629, 634, 950,
111355 /* 420 */ 953, 952, 949, 948, 947, 942, 940, 937, 936, 935,
111356 /* 430 */ 933, 930, 926, 885, 883, 890, 889, 888, 887, 886,
111357 /* 440 */ 884, 882, 880, 801, 796, 793, 925, 878, 738, 735,
111358 /* 450 */ 734, 654, 943, 909, 918, 805, 804, 807, 915, 914,
111359 /* 460 */ 913, 911, 908, 895, 803, 802, 730, 870, 869, 657,
111360 /* 470 */ 899, 898, 897, 901, 905, 896, 766, 656, 653, 662,
111361 /* 480 */ 717, 718, 726, 724, 723, 722, 721, 720, 716, 664,
111362 /* 490 */ 672, 710, 695, 694, 875, 877, 874, 873, 703, 702,
111363 /* 500 */ 708, 707, 706, 705, 704, 701, 700, 699, 692, 691,
111364 /* 510 */ 697, 690, 713, 712, 709, 689, 733, 732, 731, 728,
111365 /* 520 */ 688, 687, 686, 818, 685, 684, 824, 823, 811, 854,
111366 /* 530 */ 753, 752, 751, 763, 762, 775, 774, 809, 808, 776,
111367 /* 540 */ 761, 755, 754, 770, 769, 768, 767, 759, 749, 781,
111368 /* 550 */ 783, 782, 780, 856, 765, 853, 924, 923, 922, 921,
111369 /* 560 */ 920, 858, 857, 825, 822, 676, 677, 893, 892, 894,
111370 /* 570 */ 891, 679, 678, 675, 674, 855, 744, 743, 851, 848,
111371 /* 580 */ 840, 836, 852, 849, 841, 837, 835, 834, 820, 819,
111372 /* 590 */ 817, 816, 812, 821, 667, 745, 741, 740, 810, 747,
111373 /* 600 */ 746, 683, 682, 680, 661, 659, 652, 650, 649, 651,
111374 /* 610 */ 647, 645, 644, 643, 642, 641, 670, 669, 668, 666,
111375 /* 620 */ 665, 639, 636, 635, 631, 630, 628,
111376 };
111377
111378 /* The next table maps tokens into fallback tokens. If a construct
111379 ** like the following:
111380 **
@@ -111842,11 +112043,11 @@
111842 /* 237 */ "case_operand ::=",
111843 /* 238 */ "exprlist ::= nexprlist",
111844 /* 239 */ "exprlist ::=",
111845 /* 240 */ "nexprlist ::= nexprlist COMMA expr",
111846 /* 241 */ "nexprlist ::= expr",
111847 /* 242 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP",
111848 /* 243 */ "uniqueflag ::= UNIQUE",
111849 /* 244 */ "uniqueflag ::=",
111850 /* 245 */ "idxlist_opt ::=",
111851 /* 246 */ "idxlist_opt ::= LP idxlist RP",
111852 /* 247 */ "idxlist ::= idxlist COMMA nm collate sortorder",
@@ -112561,11 +112762,11 @@
112561 { 224, 0 },
112562 { 220, 1 },
112563 { 220, 0 },
112564 { 215, 3 },
112565 { 215, 1 },
112566 { 147, 11 },
112567 { 227, 1 },
112568 { 227, 0 },
112569 { 178, 0 },
112570 { 178, 3 },
112571 { 187, 5 },
@@ -113565,15 +113766,15 @@
113565 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);}
113566 break;
113567 case 241: /* nexprlist ::= expr */
113568 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr);}
113569 break;
113570 case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
113571 {
113572 sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0,
113573 sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy442, yymsp[-9].minor.yy392,
113574 &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy392);
113575 }
113576 break;
113577 case 243: /* uniqueflag ::= UNIQUE */
113578 case 296: /* raisetype ::= ABORT */ yytestcase(yyruleno==296);
113579 {yygotominor.yy392 = OE_Abort;}
@@ -114495,11 +114696,10 @@
114495 *tokenType = TK_SPACE;
114496 return i;
114497 }
114498 case '-': {
114499 if( z[1]=='-' ){
114500 /* IMP: R-50417-27976 -- syntax diagram for comments */
114501 for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
114502 *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
114503 return i;
114504 }
114505 *tokenType = TK_MINUS;
@@ -114528,11 +114728,10 @@
114528 case '/': {
114529 if( z[1]!='*' || z[2]==0 ){
114530 *tokenType = TK_SLASH;
114531 return 1;
114532 }
114533 /* IMP: R-50417-27976 -- syntax diagram for comments */
114534 for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}
114535 if( c ) i++;
114536 *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
114537 return i;
114538 }
@@ -116373,10 +116572,11 @@
116373 case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break;
116374 case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
116375 case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
116376 case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
116377 case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
 
116378 case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
116379 case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
116380 case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
116381 case SQLITE_FULL: zName = "SQLITE_FULL"; break;
116382 case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
@@ -117728,11 +117928,11 @@
117728 db->autoCommit = 1;
117729 db->nextAutovac = -1;
117730 db->szMmap = sqlite3GlobalConfig.szMmap;
117731 db->nextPagesize = 0;
117732 db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger
117733 #if !defined(SQLITE_DEAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
117734 | SQLITE_AutoIndex
117735 #endif
117736 #if SQLITE_DEFAULT_FILE_FORMAT<4
117737 | SQLITE_LegacyFileFmt
117738 #endif
@@ -128201,11 +128401,11 @@
128201 }
128202
128203
128204 #ifdef SQLITE_TEST
128205
128206 /* #include <tcl.h> */
128207 /* #include <string.h> */
128208
128209 /*
128210 ** Implementation of a special SQL scalar function for testing tokenizers
128211 ** designed to be used in concert with the Tcl testing framework. This
128212
--- 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-05 12:31:41 4b8b426f10f8ae13bf553f7adf5ae09383fa0bd4"
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 */
@@ -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
@@ -10762,10 +10746,11 @@
10746 char *zColAff; /* String defining the affinity of each column */
10747 Index *pNext; /* The next index associated with the same table */
10748 Schema *pSchema; /* Schema containing this index */
10749 u8 *aSortOrder; /* for each column: True==DESC, False==ASC */
10750 char **azColl; /* Array of collation sequence names for index */
10751 Expr *pPartIdxWhere; /* WHERE clause for partial indices */
10752 int tnum; /* DB Page containing root of this index */
10753 u16 nColumn; /* Number of columns in table used by this index */
10754 u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
10755 unsigned autoIndex:2; /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */
10756 unsigned bUnordered:1; /* Use this index for == or IN queries only */
@@ -11242,10 +11227,11 @@
11227 #define NC_HasAgg 0x02 /* One or more aggregate functions seen */
11228 #define NC_IsCheck 0x04 /* True if resolving names in a CHECK constraint */
11229 #define NC_InAggFunc 0x08 /* True if analyzing arguments to an agg func */
11230 #define NC_AsMaybe 0x10 /* Resolve to AS terms of the result set only
11231 ** if no other resolution is available */
11232 #define NC_PartIdx 0x20 /* True if resolving a partial index WHERE */
11233
11234 /*
11235 ** An instance of the following structure contains all information
11236 ** needed to generate code for a single SELECT statement.
11237 **
@@ -11426,10 +11412,11 @@
11412 int nTab; /* Number of previously allocated VDBE cursors */
11413 int nMem; /* Number of memory cells used so far */
11414 int nSet; /* Number of sets used so far */
11415 int nOnce; /* Number of OP_Once instructions so far */
11416 int ckBase; /* Base register of data during check constraints */
11417 int iPartIdxTab; /* Table corresponding to a partial index */
11418 int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
11419 int iCacheCnt; /* Counter used to generate aColCache[].lru values */
11420 struct yColCache {
11421 int iTable; /* Table cursor number */
11422 int iColumn; /* Table column number */
@@ -12007,11 +11994,11 @@
11994 SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*);
11995 SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*);
11996 SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*);
11997 SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*);
11998 SQLITE_PRIVATE Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
11999 Expr*, int, int);
12000 SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int);
12001 SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
12002 SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
12003 Expr*,ExprList*,u16,Expr*,Expr*);
12004 SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
@@ -12055,12 +12042,13 @@
12042 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
12043 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
12044 SQLITE_PRIVATE void sqlite3Vacuum(Parse*);
12045 SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*);
12046 SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);
12047 SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*, int);
12048 SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int);
12049 SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr*, Expr*, int);
12050 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
12051 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
12052 SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
12053 SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);
12054 SQLITE_PRIVATE void sqlite3PrngSaveState(void);
@@ -12083,11 +12071,11 @@
12071 SQLITE_PRIVATE void sqlite3ExprCodeIsNullJump(Vdbe*, const Expr*, int, int);
12072 SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);
12073 SQLITE_PRIVATE int sqlite3IsRowid(const char*);
12074 SQLITE_PRIVATE void sqlite3GenerateRowDelete(Parse*, Table*, int, int, int, Trigger *, int);
12075 SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int*);
12076 SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*);
12077 SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int,
12078 int*,int,int,int,int,int*);
12079 SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int);
12080 SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, int);
12081 SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);
@@ -12286,10 +12274,11 @@
12274 SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *, Expr *, int, int);
12275 SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
12276 SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);
12277 SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*);
12278 SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
12279 SQLITE_PRIVATE void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);
12280 SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
12281 SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
12282 SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);
12283 SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
12284 SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);
@@ -13257,10 +13246,13 @@
13246 typedef struct VdbeSorter VdbeSorter;
13247
13248 /* Opaque type used by the explainer */
13249 typedef struct Explain Explain;
13250
13251 /* Elements of the linked list at Vdbe.pAuxData */
13252 typedef struct AuxData AuxData;
13253
13254 /*
13255 ** A cursor is a pointer into a single BTree within a database file.
13256 ** The cursor can seek to a BTree entry with a particular key, or
13257 ** loop over all entries of the Btree. You can also insert new BTree
13258 ** entries or retrieve the key or data from the entry that the cursor
@@ -13443,27 +13435,23 @@
13435 */
13436 #ifdef SQLITE_DEBUG
13437 #define memIsValid(M) ((M)->flags & MEM_Invalid)==0
13438 #endif
13439
13440 /*
13441 ** Each auxilliary data pointer stored by a user defined function
13442 ** implementation calling sqlite3_set_auxdata() is stored in an instance
13443 ** of this structure. All such structures associated with a single VM
13444 ** are stored in a linked list headed at Vdbe.pAuxData. All are destroyed
13445 ** when the VM is halted (if not before).
 
 
 
13446 */
13447 struct AuxData {
13448 int iOp; /* Instruction number of OP_Function opcode */
13449 int iArg; /* Index of function argument. */
13450 void *pAux; /* Aux data pointer */
13451 void (*xDelete)(void *); /* Destructor for the aux data */
13452 AuxData *pNext; /* Next element in list */
 
13453 };
13454
13455 /*
13456 ** The "context" argument for a installable function. A pointer to an
13457 ** instance of this structure is the first argument to the routines used
@@ -13477,16 +13465,17 @@
13465 ** This structure is defined inside of vdbeInt.h because it uses substructures
13466 ** (Mem) which are only defined there.
13467 */
13468 struct sqlite3_context {
13469 FuncDef *pFunc; /* Pointer to function information. MUST BE FIRST */
 
13470 Mem s; /* The return value is stored here */
13471 Mem *pMem; /* Memory cell used to store aggregate context */
13472 CollSeq *pColl; /* Collating sequence */
13473 int isError; /* Error code returned by the function. */
13474 int skipFlag; /* Skip skip accumulator loading if true */
13475 int iOp; /* Instruction number of OP_Function */
13476 Vdbe *pVdbe; /* The VM that owns this context */
13477 };
13478
13479 /*
13480 ** An Explain object accumulates indented output which is helpful
13481 ** in describing recursive data structures.
@@ -13581,10 +13570,11 @@
13570 int nFrame; /* Number of frames in pFrame list */
13571 u32 expmask; /* Binding to these vars invalidates VM */
13572 SubProgram *pProgram; /* Linked list of all sub-programs used by VM */
13573 int nOnceFlag; /* Size of array aOnceFlag[] */
13574 u8 *aOnceFlag; /* Flags for OP_Once */
13575 AuxData *pAuxData; /* Linked list of auxdata allocations */
13576 };
13577
13578 /*
13579 ** The following are allowed values for Vdbe.magic
13580 */
@@ -13604,11 +13594,11 @@
13594 #endif
13595 SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
13596 SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int);
13597 SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int);
13598 SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
13599 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe*, int, int);
13600
13601 int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
13602 SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int*);
13603 SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3*, BtCursor *, i64 *);
13604 SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
@@ -30499,10 +30489,11 @@
30489 */
30490 #if SQLITE_OS_WIN /* This file is used for Windows only */
30491
30492 #ifdef __CYGWIN__
30493 # include <sys/cygwin.h>
30494 /* # include <errno.h> */
30495 #endif
30496
30497 /*
30498 ** Include code that is common to all os_*.c files
30499 */
@@ -30919,10 +30910,11 @@
30910 * zero for the default behavior.
30911 */
30912 #ifndef SQLITE_WIN32_HEAP_FLAGS
30913 # define SQLITE_WIN32_HEAP_FLAGS (0)
30914 #endif
30915
30916
30917 /*
30918 ** The winMemData structure stores information required by the Win32-specific
30919 ** sqlite3_mem_methods implementation.
30920 */
@@ -34384,14 +34376,14 @@
34376 OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
34377 osGetCurrentProcessId(), pFd));
34378 return SQLITE_OK;
34379 }
34380 assert( (nMap % winSysInfo.dwPageSize)==0 );
 
 
 
34381 assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
34382 #if SQLITE_OS_WINRT
34383 pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, (SIZE_T)nMap);
34384 #else
34385 pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
34386 #endif
34387 if( pNew==NULL ){
34388 osCloseHandle(pFd->hMap);
34389 pFd->hMap = NULL;
@@ -34556,10 +34548,19 @@
34548 #endif
34549 /* caller will handle out of memory */
34550 return zConverted;
34551 }
34552
34553 /*
34554 ** Maximum pathname length (in bytes) for windows. The MAX_PATH macro is
34555 ** in characters, so we allocate 3 bytes per character assuming worst-case
34556 ** 3-bytes-per-character UTF8.
34557 */
34558 #ifndef SQLITE_WIN32_MAX_PATH
34559 # define SQLITE_WIN32_MAX_PATH (MAX_PATH*3)
34560 #endif
34561
34562 /*
34563 ** Create a temporary file name in zBuf. zBuf must be big enough to
34564 ** hold at pVfs->mxPathname characters.
34565 */
34566 static int getTempname(int nBuf, char *zBuf){
@@ -34567,53 +34568,74 @@
34568 "abcdefghijklmnopqrstuvwxyz"
34569 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
34570 "0123456789";
34571 size_t i, j;
34572 int nTempPath;
34573 char zTempPath[SQLITE_WIN32_MAX_PATH+2];
34574
34575 /* It's odd to simulate an io-error here, but really this is just
34576 ** using the io-error infrastructure to test that SQLite handles this
34577 ** function failing.
34578 */
34579 SimulateIOError( return SQLITE_IOERR );
34580
 
 
34581 if( sqlite3_temp_directory ){
34582 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s",
34583 sqlite3_temp_directory);
34584 }
34585 #if !SQLITE_OS_WINRT
34586 else if( isNT() ){
34587 char *zMulti;
34588 WCHAR zWidePath[MAX_PATH];
34589 if( osGetTempPathW(MAX_PATH-30, zWidePath)==0 ){
34590 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34591 return SQLITE_IOERR_GETTEMPPATH;
34592 }
34593 zMulti = unicodeToUtf8(zWidePath);
34594 if( zMulti ){
34595 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zMulti);
34596 sqlite3_free(zMulti);
34597 }else{
34598 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34599 return SQLITE_IOERR_NOMEM;
34600 }
34601 }
34602 #ifdef SQLITE_WIN32_HAS_ANSI
34603 else{
34604 char *zUtf8;
34605 char zMbcsPath[SQLITE_WIN32_MAX_PATH];
34606 if( osGetTempPathA(SQLITE_WIN32_MAX_PATH-30, zMbcsPath)==0 ){
34607 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34608 return SQLITE_IOERR_GETTEMPPATH;
34609 }
34610 zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
34611 if( zUtf8 ){
34612 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zUtf8);
34613 sqlite3_free(zUtf8);
34614 }else{
34615 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34616 return SQLITE_IOERR_NOMEM;
34617 }
34618 }
34619 #else
34620 else{
34621 /*
34622 ** Compiled without ANSI support and the current operating system
34623 ** is not Windows NT; therefore, just zero the temporary buffer.
34624 */
34625 memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34626 }
34627 #endif /* SQLITE_WIN32_HAS_ANSI */
34628 #else
34629 else{
34630 /*
34631 ** Compiled for WinRT and the sqlite3_temp_directory is not set;
34632 ** therefore, just zero the temporary buffer.
34633 */
34634 memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34635 }
34636 #endif /* !SQLITE_OS_WINRT */
34637
34638 /* Check that the output buffer is large enough for the temporary file
34639 ** name. If it is not, return SQLITE_ERROR.
34640 */
34641 nTempPath = sqlite3Strlen30(zTempPath);
@@ -34695,11 +34717,11 @@
34717 int cnt = 0;
34718
34719 /* If argument zPath is a NULL pointer, this function is required to open
34720 ** a temporary file. Use this buffer to store the file name in.
34721 */
34722 char zTmpname[SQLITE_WIN32_MAX_PATH+2]; /* Buffer used to create temp filename */
34723
34724 int rc = SQLITE_OK; /* Function Return Code */
34725 #if !defined(NDEBUG) || SQLITE_OS_WINCE
34726 int eType = flags&0xFFFFFF00; /* Type of file to open */
34727 #endif
@@ -34761,12 +34783,11 @@
34783 /* If the second argument to this function is NULL, generate a
34784 ** temporary file name to use
34785 */
34786 if( !zUtf8Name ){
34787 assert(isDelete && !isOpenJournal);
34788 rc = getTempname(SQLITE_WIN32_MAX_PATH+2, zTmpname);
 
34789 if( rc!=SQLITE_OK ){
34790 OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
34791 return rc;
34792 }
34793 zUtf8Name = zTmpname;
@@ -35193,27 +35214,34 @@
35214 ){
35215
35216 #if defined(__CYGWIN__)
35217 SimulateIOError( return SQLITE_ERROR );
35218 UNUSED_PARAMETER(nFull);
35219 assert( pVfs->mxPathname>=SQLITE_WIN32_MAX_PATH );
35220 assert( nFull>=pVfs->mxPathname );
35221 if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
35222 /*
35223 ** NOTE: We are dealing with a relative path name and the data
35224 ** directory has been set. Therefore, use it as the basis
35225 ** for converting the relative path name to an absolute
35226 ** one by prepending the data directory and a slash.
35227 */
35228 char zOut[SQLITE_WIN32_MAX_PATH+1];
35229 if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35230 SQLITE_WIN32_MAX_PATH+1)<0 ){
35231 winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35232 zRelative);
35233 return SQLITE_CANTOPEN_FULLPATH;
35234 }
35235 sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s",
35236 sqlite3_data_directory, zOut);
35237 }else{
35238 if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){
35239 winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35240 zRelative);
35241 return SQLITE_CANTOPEN_FULLPATH;
35242 }
35243 }
35244 return SQLITE_OK;
35245 #endif
35246
35247 #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
@@ -35551,11 +35579,11 @@
35579 */
35580 SQLITE_API int sqlite3_os_init(void){
35581 static sqlite3_vfs winVfs = {
35582 3, /* iVersion */
35583 sizeof(winFile), /* szOsFile */
35584 SQLITE_WIN32_MAX_PATH, /* mxPathname */
35585 0, /* pNext */
35586 "win32", /* zName */
35587 0, /* pAppData */
35588 winOpen, /* xOpen */
35589 winDelete, /* xDelete */
@@ -60176,12 +60204,12 @@
60204 ** a prior call to sqlite3VdbeMakeLabel().
60205 */
60206 SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *p, int x){
60207 int j = -1-x;
60208 assert( p->magic==VDBE_MAGIC_INIT );
60209 assert( j<p->nLabel );
60210 if( j>=0 && p->aLabel ){
60211 p->aLabel[j] = p->nOp;
60212 }
60213 }
60214
60215 /*
@@ -60501,12 +60529,11 @@
60529 /*
60530 ** Change the P2 operand of instruction addr so that it points to
60531 ** the address of the next instruction to be coded.
60532 */
60533 SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe *p, int addr){
60534 if( ALWAYS(addr>=0) ) sqlite3VdbeChangeP2(p, addr, p->nOp);
 
60535 }
60536
60537
60538 /*
60539 ** If the input FuncDef structure is ephemeral, then free it. If
@@ -60538,17 +60565,10 @@
60565 }
60566 case P4_MPRINTF: {
60567 if( db->pnBytesFreed==0 ) sqlite3_free(p4);
60568 break;
60569 }
 
 
 
 
 
 
 
60570 case P4_FUNCDEF: {
60571 freeEphemeralFunction(db, (FuncDef*)p4);
60572 break;
60573 }
60574 case P4_MEM: {
@@ -61574,10 +61594,14 @@
61594 while( p->pDelFrame ){
61595 VdbeFrame *pDel = p->pDelFrame;
61596 p->pDelFrame = pDel->pParent;
61597 sqlite3VdbeFrameDelete(pDel);
61598 }
61599
61600 /* Delete any auxdata allocations made by the VM */
61601 sqlite3VdbeDeleteAuxData(p, -1, 0);
61602 assert( p->pAuxData==0 );
61603 }
61604
61605 /*
61606 ** Clean up the VM after execution.
61607 **
@@ -62372,24 +62396,39 @@
62396 sqlite3VdbeDelete(p);
62397 return rc;
62398 }
62399
62400 /*
62401 ** If parameter iOp is less than zero, then invoke the destructor for
62402 ** all auxiliary data pointers currently cached by the VM passed as
62403 ** the first argument.
62404 **
62405 ** Or, if iOp is greater than or equal to zero, then the destructor is
62406 ** only invoked for those auxiliary data pointers created by the user
62407 ** function invoked by the OP_Function opcode at instruction iOp of
62408 ** VM pVdbe, and only then if:
62409 **
62410 ** * the associated function parameter is the 32nd or later (counting
62411 ** from left to right), or
62412 **
62413 ** * the corresponding bit in argument mask is clear (where the first
62414 ** function parameter corrsponds to bit 0 etc.).
62415 */
62416 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){
62417 AuxData **pp = &pVdbe->pAuxData;
62418 while( *pp ){
62419 AuxData *pAux = *pp;
62420 if( (iOp<0)
62421 || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & ((u32)1<<pAux->iArg))))
62422 ){
62423 if( pAux->xDelete ){
62424 pAux->xDelete(pAux->pAux);
62425 }
62426 *pp = pAux->pNext;
62427 sqlite3DbFree(pVdbe->db, pAux);
62428 }else{
62429 pp= &pAux->pNext;
62430 }
62431 }
62432 }
62433
62434 /*
@@ -62904,11 +62943,11 @@
62943 */
62944 SQLITE_PRIVATE int sqlite3VdbeRecordCompare(
62945 int nKey1, const void *pKey1, /* Left key */
62946 UnpackedRecord *pPKey2 /* Right key */
62947 ){
62948 u32 d1; /* Offset into aKey[] of next data element */
62949 u32 idx1; /* Offset into aKey[] of next header element */
62950 u32 szHdr1; /* Number of bytes in header */
62951 int i = 0;
62952 int nField;
62953 int rc = 0;
@@ -62938,11 +62977,11 @@
62977 while( idx1<szHdr1 && i<pPKey2->nField ){
62978 u32 serial_type1;
62979
62980 /* Read the serial types for the next element in each key. */
62981 idx1 += getVarint32( aKey1+idx1, serial_type1 );
62982 if( d1+sqlite3VdbeSerialTypeLen(serial_type1)>(u32)nKey1 ) break;
62983
62984 /* Extract the values to be compared.
62985 */
62986 d1 += sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1);
62987
@@ -63167,11 +63206,11 @@
63206 ** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*
63207 ** constants) to the value before returning it.
63208 **
63209 ** The returned value must be freed by the caller using sqlite3ValueFree().
63210 */
63211 SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){
63212 assert( iVar>0 );
63213 if( v ){
63214 Mem *pMem = &v->aVar[iVar-1];
63215 if( 0==(pMem->flags & MEM_Null) ){
63216 sqlite3_value *pRet = sqlite3ValueNew(v->db);
@@ -63784,18 +63823,18 @@
63823 /*
63824 ** Return the auxilary data pointer, if any, for the iArg'th argument to
63825 ** the user-function defined by pCtx.
63826 */
63827 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
63828 AuxData *pAuxData;
63829
63830 assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63831 for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
63832 if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
 
63833 }
63834
63835 return (pAuxData ? pAuxData->pAux : 0);
63836 }
63837
63838 /*
63839 ** Set the auxilary data pointer and delete function, for the iArg'th
63840 ** argument to the user-function defined by pCtx. Any previous value is
@@ -63805,33 +63844,30 @@
63844 sqlite3_context *pCtx,
63845 int iArg,
63846 void *pAux,
63847 void (*xDelete)(void*)
63848 ){
63849 AuxData *pAuxData;
63850 Vdbe *pVdbe = pCtx->pVdbe;
 
63851
63852 assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63853 if( iArg<0 ) goto failed;
63854
63855 for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
63856 if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
63857 }
63858 if( pAuxData==0 ){
63859 pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData));
63860 if( !pAuxData ) goto failed;
63861 pAuxData->iOp = pCtx->iOp;
63862 pAuxData->iArg = iArg;
63863 pAuxData->pNext = pVdbe->pAuxData;
63864 pVdbe->pAuxData = pAuxData;
63865 }else if( pAuxData->xDelete ){
 
 
 
63866 pAuxData->xDelete(pAuxData->pAux);
63867 }
63868
63869 pAuxData->pAux = pAux;
63870 pAuxData->xDelete = xDelete;
63871 return;
63872
63873 failed:
@@ -65439,11 +65475,11 @@
65475 u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
65476 u8 encoding = ENC(db); /* The database encoding */
65477 int iCompare = 0; /* Result of last OP_Compare operation */
65478 unsigned nVmStep = 0; /* Number of virtual machine steps */
65479 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65480 unsigned nProgressLimit; /* Invoke xProgress() when nVmStep reaches this */
65481 #endif
65482 Mem *aMem = p->aMem; /* Copy of p->aMem */
65483 Mem *pIn1 = 0; /* 1st input operand */
65484 Mem *pIn2 = 0; /* 2nd input operand */
65485 Mem *pIn3 = 0; /* 3rd input operand */
@@ -65898,10 +65934,21 @@
65934 assert( p->explain==0 );
65935 p->pResultSet = 0;
65936 db->busyHandler.nBusy = 0;
65937 CHECK_FOR_INTERRUPT;
65938 sqlite3VdbeIOTraceSql(p);
65939 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65940 if( db->xProgress ){
65941 assert( 0 < db->nProgressOps );
65942 nProgressLimit = (unsigned)p->aCounter[SQLITE_STMTSTATUS_VM_STEP-1];
65943 if( nProgressLimit==0 ){
65944 nProgressLimit = db->nProgressOps;
65945 }else{
65946 nProgressLimit %= (unsigned)db->nProgressOps;
65947 }
65948 }
65949 #endif
65950 #ifdef SQLITE_DEBUG
65951 sqlite3BeginBenignMalloc();
65952 if( p->pc==0 && (p->db->flags & SQLITE_VdbeListing)!=0 ){
65953 int i;
65954 printf("VDBE Program Listing:\n");
@@ -66058,18 +66105,20 @@
66105 ** of VDBE ops have been executed (either since this invocation of
66106 ** sqlite3VdbeExec() or since last time the progress callback was called).
66107 ** If the progress callback returns non-zero, exit the virtual machine with
66108 ** a return code SQLITE_ABORT.
66109 */
66110 if( db->xProgress!=0 && nVmStep>=nProgressLimit ){
66111 int prc;
66112 prc = db->xProgress(db->pProgressArg);
66113 if( prc!=0 ){
66114 rc = SQLITE_INTERRUPT;
66115 goto vdbe_error_halt;
66116 }
66117 if( db->xProgress!=0 ){
66118 nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps);
66119 }
66120 }
66121 #endif
66122
66123 break;
66124 }
@@ -66751,23 +66800,18 @@
66800 Deephemeralize(u.ai.pArg);
66801 sqlite3VdbeMemStoreType(u.ai.pArg);
66802 REGISTER_TRACE(pOp->p2+u.ai.i, u.ai.pArg);
66803 }
66804
66805 assert( pOp->p4type==P4_FUNCDEF );
66806 u.ai.ctx.pFunc = pOp->p4.pFunc;
 
 
 
 
 
 
 
66807 u.ai.ctx.s.flags = MEM_Null;
66808 u.ai.ctx.s.db = db;
66809 u.ai.ctx.s.xDel = 0;
66810 u.ai.ctx.s.zMalloc = 0;
66811 u.ai.ctx.iOp = pc;
66812 u.ai.ctx.pVdbe = p;
66813
66814 /* The output cell may already have a buffer allocated. Move
66815 ** the pointer to u.ai.ctx.s so in case the user-function can use
66816 ** the already allocated buffer instead of allocating a new one.
66817 */
@@ -66786,15 +66830,11 @@
66830 lastRowid = db->lastRowid;
66831
66832 /* If any auxiliary data functions have been called by this user function,
66833 ** immediately call the destructor for any non-static values.
66834 */
66835 sqlite3VdbeDeleteAuxData(p, pc, pOp->p1);
 
 
 
 
66836
66837 if( db->mallocFailed ){
66838 /* Even though a malloc() has failed, the implementation of the
66839 ** user function may have called an sqlite3_result_XXX() function
66840 ** to return a value. The following call releases any resources
@@ -74157,15 +74197,24 @@
74197 /* Translate the schema name in zDb into a pointer to the corresponding
74198 ** schema. If not found, pSchema will remain NULL and nothing will match
74199 ** resulting in an appropriate error message toward the end of this routine
74200 */
74201 if( zDb ){
74202 testcase( pNC->ncFlags & NC_PartIdx );
74203 testcase( pNC->ncFlags & NC_IsCheck );
74204 if( (pNC->ncFlags & (NC_PartIdx|NC_IsCheck))!=0 ){
74205 /* Silently ignore database qualifiers inside CHECK constraints and partial
74206 ** indices. Do not raise errors because that might break legacy and
74207 ** because it does not hurt anything to just ignore the database name. */
74208 zDb = 0;
74209 }else{
74210 for(i=0; i<db->nDb; i++){
74211 assert( db->aDb[i].zName );
74212 if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){
74213 pSchema = db->aDb[i].pSchema;
74214 break;
74215 }
74216 }
74217 }
74218 }
74219
74220 /* Start at the inner-most context and move outward until a match is found */
@@ -74438,10 +74487,43 @@
74487 }
74488 ExprSetProperty(p, EP_Resolved);
74489 }
74490 return p;
74491 }
74492
74493 /*
74494 ** Report an error that an expression is not valid for a partial index WHERE
74495 ** clause.
74496 */
74497 static void notValidPartIdxWhere(
74498 Parse *pParse, /* Leave error message here */
74499 NameContext *pNC, /* The name context */
74500 const char *zMsg /* Type of error */
74501 ){
74502 if( (pNC->ncFlags & NC_PartIdx)!=0 ){
74503 sqlite3ErrorMsg(pParse, "%s prohibited in partial index WHERE clauses",
74504 zMsg);
74505 }
74506 }
74507
74508 #ifndef SQLITE_OMIT_CHECK
74509 /*
74510 ** Report an error that an expression is not valid for a CHECK constraint.
74511 */
74512 static void notValidCheckConstraint(
74513 Parse *pParse, /* Leave error message here */
74514 NameContext *pNC, /* The name context */
74515 const char *zMsg /* Type of error */
74516 ){
74517 if( (pNC->ncFlags & NC_IsCheck)!=0 ){
74518 sqlite3ErrorMsg(pParse,"%s prohibited in CHECK constraints", zMsg);
74519 }
74520 }
74521 #else
74522 # define notValidCheckConstraint(P,N,M)
74523 #endif
74524
74525
74526 /*
74527 ** This routine is callback for sqlite3WalkExpr().
74528 **
74529 ** Resolve symbolic names into TK_COLUMN operators for the current
@@ -74538,10 +74620,11 @@
74620 FuncDef *pDef; /* Information about the function */
74621 u8 enc = ENC(pParse->db); /* The database encoding */
74622
74623 testcase( pExpr->op==TK_CONST_FUNC );
74624 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
74625 notValidPartIdxWhere(pParse, pNC, "functions");
74626 zId = pExpr->u.zToken;
74627 nId = sqlite3Strlen30(zId);
74628 pDef = sqlite3FindFunction(pParse->db, zId, nId, n, enc, 0);
74629 if( pDef==0 ){
74630 pDef = sqlite3FindFunction(pParse->db, zId, nId, -2, enc, 0);
@@ -74603,31 +74686,25 @@
74686 #endif
74687 case TK_IN: {
74688 testcase( pExpr->op==TK_IN );
74689 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
74690 int nRef = pNC->nRef;
74691 notValidCheckConstraint(pParse, pNC, "subqueries");
74692 notValidPartIdxWhere(pParse, pNC, "subqueries");
 
 
 
74693 sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
74694 assert( pNC->nRef>=nRef );
74695 if( nRef!=pNC->nRef ){
74696 ExprSetProperty(pExpr, EP_VarSelect);
74697 }
74698 }
74699 break;
74700 }
 
74701 case TK_VARIABLE: {
74702 notValidCheckConstraint(pParse, pNC, "parameters");
74703 notValidPartIdxWhere(pParse, pNC, "parameters");
 
74704 break;
74705 }
 
74706 }
74707 return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue;
74708 }
74709
74710 /*
@@ -74714,11 +74791,11 @@
74791 /* Try to match the ORDER BY expression against an expression
74792 ** in the result set. Return an 1-based index of the matching
74793 ** result-set entry.
74794 */
74795 for(i=0; i<pEList->nExpr; i++){
74796 if( sqlite3ExprCompare(pEList->a[i].pExpr, pE, -1)<2 ){
74797 return i+1;
74798 }
74799 }
74800
74801 /* If no match, return 0. */
@@ -74942,11 +75019,11 @@
75019 pItem->iOrderByCol = 0;
75020 if( sqlite3ResolveExprNames(pNC, pE) ){
75021 return 1;
75022 }
75023 for(j=0; j<pSelect->pEList->nExpr; j++){
75024 if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
75025 pItem->iOrderByCol = j+1;
75026 }
75027 }
75028 }
75029 return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
@@ -75248,10 +75325,52 @@
75325 w.xSelectCallback = resolveSelectStep;
75326 w.pParse = pParse;
75327 w.u.pNC = pOuterNC;
75328 sqlite3WalkSelect(&w, p);
75329 }
75330
75331 /*
75332 ** Resolve names in expressions that can only reference a single table:
75333 **
75334 ** * CHECK constraints
75335 ** * WHERE clauses on partial indices
75336 **
75337 ** The Expr.iTable value for Expr.op==TK_COLUMN nodes of the expression
75338 ** is set to -1 and the Expr.iColumn value is set to the column number.
75339 **
75340 ** Any errors cause an error message to be set in pParse.
75341 */
75342 SQLITE_PRIVATE void sqlite3ResolveSelfReference(
75343 Parse *pParse, /* Parsing context */
75344 Table *pTab, /* The table being referenced */
75345 int type, /* NC_IsCheck or NC_PartIdx */
75346 Expr *pExpr, /* Expression to resolve. May be NULL. */
75347 ExprList *pList /* Expression list to resolve. May be NUL. */
75348 ){
75349 SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
75350 NameContext sNC; /* Name context for pParse->pNewTable */
75351 int i; /* Loop counter */
75352
75353 assert( type==NC_IsCheck || type==NC_PartIdx );
75354 memset(&sNC, 0, sizeof(sNC));
75355 memset(&sSrc, 0, sizeof(sSrc));
75356 sSrc.nSrc = 1;
75357 sSrc.a[0].zName = pTab->zName;
75358 sSrc.a[0].pTab = pTab;
75359 sSrc.a[0].iCursor = -1;
75360 sNC.pParse = pParse;
75361 sNC.pSrcList = &sSrc;
75362 sNC.ncFlags = type;
75363 if( sqlite3ResolveExprNames(&sNC, pExpr) ) return;
75364 if( pList ){
75365 for(i=0; i<pList->nExpr; i++){
75366 if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){
75367 return;
75368 }
75369 }
75370 }
75371 }
75372
75373 /************** End of resolve.c *********************************************/
75374 /************** Begin file expr.c ********************************************/
75375 /*
75376 ** 2001 September 15
@@ -77614,19 +77733,24 @@
77733 break;
77734 }
77735 /* Otherwise, fall thru into the TK_COLUMN case */
77736 }
77737 case TK_COLUMN: {
77738 int iTab = pExpr->iTable;
77739 if( iTab<0 ){
77740 if( pParse->ckBase>0 ){
77741 /* Generating CHECK constraints or inserting into partial index */
77742 inReg = pExpr->iColumn + pParse->ckBase;
77743 break;
77744 }else{
77745 /* Deleting from a partial index */
77746 iTab = pParse->iPartIdxTab;
77747 }
77748 }
77749 inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
77750 pExpr->iColumn, iTab, target,
77751 pExpr->op2);
77752 break;
77753 }
77754 case TK_INTEGER: {
77755 codeInteger(pParse, pExpr, 0, target);
77756 break;
@@ -79045,10 +79169,16 @@
79169 ** Do a deep comparison of two expression trees. Return 0 if the two
79170 ** expressions are completely identical. Return 1 if they differ only
79171 ** by a COLLATE operator at the top level. Return 2 if there are differences
79172 ** other than the top-level COLLATE operator.
79173 **
79174 ** If any subelement of pB has Expr.iTable==(-1) then it is allowed
79175 ** to compare equal to an equivalent element in pA with Expr.iTable==iTab.
79176 **
79177 ** The pA side might be using TK_REGISTER. If that is the case and pB is
79178 ** not using TK_REGISTER but is otherwise equivalent, then still return 0.
79179 **
79180 ** Sometimes this routine will return 2 even if the two expressions
79181 ** really are equivalent. If we cannot prove that the expressions are
79182 ** identical, we return 2 just to be safe. So if this routine
79183 ** returns 2, then you do not really know for certain if the two
79184 ** expressions are the same. But if you get a 0 or 1 return, then you
@@ -79055,33 +79185,36 @@
79185 ** can be sure the expressions are the same. In the places where
79186 ** this routine is used, it does not hurt to get an extra 2 - that
79187 ** just might result in some slightly slower code. But returning
79188 ** an incorrect 0 or 1 could lead to a malfunction.
79189 */
79190 SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB, int iTab){
79191 if( pA==0||pB==0 ){
79192 return pB==pA ? 0 : 2;
79193 }
79194 assert( !ExprHasAnyProperty(pA, EP_TokenOnly|EP_Reduced) );
79195 assert( !ExprHasAnyProperty(pB, EP_TokenOnly|EP_Reduced) );
79196 if( ExprHasProperty(pA, EP_xIsSelect) || ExprHasProperty(pB, EP_xIsSelect) ){
79197 return 2;
79198 }
79199 if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
79200 if( pA->op!=pB->op && (pA->op!=TK_REGISTER || pA->op2!=pB->op) ){
79201 if( pA->op==TK_COLLATE && sqlite3ExprCompare(pA->pLeft, pB, iTab)<2 ){
79202 return 1;
79203 }
79204 if( pB->op==TK_COLLATE && sqlite3ExprCompare(pA, pB->pLeft, iTab)<2 ){
79205 return 1;
79206 }
79207 return 2;
79208 }
79209 if( sqlite3ExprCompare(pA->pLeft, pB->pLeft, iTab) ) return 2;
79210 if( sqlite3ExprCompare(pA->pRight, pB->pRight, iTab) ) return 2;
79211 if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
79212 if( pA->iColumn!=pB->iColumn ) return 2;
79213 if( pA->iTable!=pB->iTable
79214 && pA->op!=TK_REGISTER
79215 && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
79216 if( ExprHasProperty(pA, EP_IntValue) ){
79217 if( !ExprHasProperty(pB, EP_IntValue) || pA->u.iValue!=pB->u.iValue ){
79218 return 2;
79219 }
79220 }else if( pA->op!=TK_COLUMN && ALWAYS(pA->op!=TK_AGG_COLUMN) && pA->u.zToken){
@@ -79095,28 +79228,70 @@
79228
79229 /*
79230 ** Compare two ExprList objects. Return 0 if they are identical and
79231 ** non-zero if they differ in any way.
79232 **
79233 ** If any subelement of pB has Expr.iTable==(-1) then it is allowed
79234 ** to compare equal to an equivalent element in pA with Expr.iTable==iTab.
79235 **
79236 ** This routine might return non-zero for equivalent ExprLists. The
79237 ** only consequence will be disabled optimizations. But this routine
79238 ** must never return 0 if the two ExprList objects are different, or
79239 ** a malfunction will result.
79240 **
79241 ** Two NULL pointers are considered to be the same. But a NULL pointer
79242 ** always differs from a non-NULL pointer.
79243 */
79244 SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB, int iTab){
79245 int i;
79246 if( pA==0 && pB==0 ) return 0;
79247 if( pA==0 || pB==0 ) return 1;
79248 if( pA->nExpr!=pB->nExpr ) return 1;
79249 for(i=0; i<pA->nExpr; i++){
79250 Expr *pExprA = pA->a[i].pExpr;
79251 Expr *pExprB = pB->a[i].pExpr;
79252 if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
79253 if( sqlite3ExprCompare(pExprA, pExprB, iTab) ) return 1;
79254 }
79255 return 0;
79256 }
79257
79258 /*
79259 ** Return true if we can prove the pE2 will always be true if pE1 is
79260 ** true. Return false if we cannot complete the proof or if pE2 might
79261 ** be false. Examples:
79262 **
79263 ** pE1: x==5 pE2: x==5 Result: true
79264 ** pE1: x>0 pE2: x==5 Result: false
79265 ** pE1: x=21 pE2: x=21 OR y=43 Result: true
79266 ** pE1: x!=123 pE2: x IS NOT NULL Result: true
79267 ** pE1: x!=?1 pE2: x IS NOT NULL Result: true
79268 ** pE1: x IS NULL pE2: x IS NOT NULL Result: false
79269 ** pE1: x IS ?2 pE2: x IS NOT NULL Reuslt: false
79270 **
79271 ** When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has
79272 ** Expr.iTable<0 then assume a table number given by iTab.
79273 **
79274 ** When in doubt, return false. Returning true might give a performance
79275 ** improvement. Returning false might cause a performance reduction, but
79276 ** it will always give the correct answer and is hence always safe.
79277 */
79278 SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr *pE1, Expr *pE2, int iTab){
79279 if( sqlite3ExprCompare(pE1, pE2, iTab)==0 ){
79280 return 1;
79281 }
79282 if( pE2->op==TK_OR
79283 && (sqlite3ExprImpliesExpr(pE1, pE2->pLeft, iTab)
79284 || sqlite3ExprImpliesExpr(pE1, pE2->pRight, iTab) )
79285 ){
79286 return 1;
79287 }
79288 if( pE2->op==TK_NOTNULL
79289 && sqlite3ExprCompare(pE1->pLeft, pE2->pLeft, iTab)==0
79290 && (pE1->op!=TK_ISNULL && pE1->op!=TK_IS)
79291 ){
79292 return 1;
79293 }
79294 return 0;
79295 }
79296
79297 /*
@@ -79297,11 +79472,11 @@
79472 /* Check to see if pExpr is a duplicate of another aggregate
79473 ** function that is already in the pAggInfo structure
79474 */
79475 struct AggInfo_func *pItem = pAggInfo->aFunc;
79476 for(i=0; i<pAggInfo->nFunc; i++, pItem++){
79477 if( sqlite3ExprCompare(pItem->pExpr, pExpr, -1)==0 ){
79478 break;
79479 }
79480 }
79481 if( i>=pAggInfo->nFunc ){
79482 /* pExpr is original. Make a new entry in pAggInfo->aFunc[]
@@ -80714,10 +80889,11 @@
80889 int i; /* Loop counter */
80890 int topOfLoop; /* The top of the loop */
80891 int endOfLoop; /* The end of the loop */
80892 int jZeroRows = -1; /* Jump from here if number of rows is zero */
80893 int iDb; /* Index of database containing pTab */
80894 u8 needTableCnt = 1; /* True to count the table */
80895 int regTabname = iMem++; /* Register containing table name */
80896 int regIdxname = iMem++; /* Register containing index name */
80897 int regStat1 = iMem++; /* The stat column of sqlite_stat1 */
80898 #ifdef SQLITE_ENABLE_STAT3
80899 int regNumEq = regStat1; /* Number of instances. Same as regStat1 */
@@ -80773,10 +80949,11 @@
80949 KeyInfo *pKey;
80950 int addrIfNot = 0; /* address of OP_IfNot */
80951 int *aChngAddr; /* Array of jump instruction addresses */
80952
80953 if( pOnlyIdx && pOnlyIdx!=pIdx ) continue;
80954 if( pIdx->pPartIdxWhere==0 ) needTableCnt = 0;
80955 VdbeNoopComment((v, "Begin analysis of %s", pIdx->zName));
80956 nCol = pIdx->nColumn;
80957 aChngAddr = sqlite3DbMallocRaw(db, sizeof(int)*nCol);
80958 if( aChngAddr==0 ) continue;
80959 pKey = sqlite3IndexKeyinfo(pParse, pIdx);
@@ -80932,48 +81109,45 @@
81109 ** If K==0 then no entry is made into the sqlite_stat1 table.
81110 ** If K>0 then it is always the case the D>0 so division by zero
81111 ** is never possible.
81112 */
81113 sqlite3VdbeAddOp2(v, OP_SCopy, iMem, regStat1);
81114 jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem);
 
 
81115 for(i=0; i<nCol; i++){
81116 sqlite3VdbeAddOp4(v, OP_String8, 0, regTemp, 0, " ", 0);
81117 sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1);
81118 sqlite3VdbeAddOp3(v, OP_Add, iMem, iMem+i+1, regTemp);
81119 sqlite3VdbeAddOp2(v, OP_AddImm, regTemp, -1);
81120 sqlite3VdbeAddOp3(v, OP_Divide, iMem+i+1, regTemp, regTemp);
81121 sqlite3VdbeAddOp1(v, OP_ToInt, regTemp);
81122 sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1);
81123 }
81124 if( pIdx->pPartIdxWhere!=0 ) sqlite3VdbeJumpHere(v, jZeroRows);
81125 sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0);
81126 sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
81127 sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);
81128 sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
81129 if( pIdx->pPartIdxWhere==0 ) sqlite3VdbeJumpHere(v, jZeroRows);
81130 }
81131
81132 /* Create a single sqlite_stat1 entry containing NULL as the index
81133 ** name and the row count as the content.
81134 */
81135 if( pOnlyIdx==0 && needTableCnt ){
81136 sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pTab->tnum, iDb);
81137 VdbeComment((v, "%s", pTab->zName));
81138 sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat1);
81139 sqlite3VdbeAddOp1(v, OP_Close, iIdxCur);
81140 jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1);
81141 sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname);
81142 sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0);
81143 sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
81144 sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);
81145 sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
81146 sqlite3VdbeJumpHere(v, jZeroRows);
81147 }
81148 if( pParse->nMem<regRec ) pParse->nMem = regRec;
 
 
 
81149 }
81150
81151
81152 /*
81153 ** Generate code that will cause the most recent index analysis to
@@ -81152,12 +81326,14 @@
81326 v = 0;
81327 while( (c=z[0])>='0' && c<='9' ){
81328 v = v*10 + c - '0';
81329 z++;
81330 }
81331 if( i==0 && (pIndex==0 || pIndex->pPartIdxWhere==0) ){
81332 if( v>0 ) pTable->nRowEst = v;
81333 if( pIndex==0 ) break;
81334 }
81335 pIndex->aiRowEst[i] = v;
81336 if( *z==' ' ) z++;
81337 if( strcmp(z, "unordered")==0 ){
81338 pIndex->bUnordered = 1;
81339 break;
@@ -82593,10 +82769,11 @@
82769 */
82770 static void freeIndex(sqlite3 *db, Index *p){
82771 #ifndef SQLITE_OMIT_ANALYZE
82772 sqlite3DeleteIndexSamples(db, p);
82773 #endif
82774 sqlite3ExprDelete(db, p->pPartIdxWhere);
82775 sqlite3DbFree(db, p->zColAff);
82776 sqlite3DbFree(db, p);
82777 }
82778
82779 /*
@@ -83436,11 +83613,12 @@
83613 sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
83614 "INTEGER PRIMARY KEY");
83615 #endif
83616 }else{
83617 Index *p;
83618 p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0,
83619 0, sortOrder, 0);
83620 if( p ){
83621 p->autoIndex = 2;
83622 }
83623 pList = 0;
83624 }
@@ -83731,30 +83909,11 @@
83909
83910 #ifndef SQLITE_OMIT_CHECK
83911 /* Resolve names in all CHECK constraint expressions.
83912 */
83913 if( p->pCheck ){
83914 sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83915 }
83916 #endif /* !defined(SQLITE_OMIT_CHECK) */
83917
83918 /* If the db->init.busy is 1 it means we are reading the SQL off the
83919 ** "sqlite_master" or "sqlite_temp_master" table on the disk.
@@ -84602,10 +84761,11 @@
84761 int iIdx = pParse->nTab++; /* Btree cursor used for pIndex */
84762 int iSorter; /* Cursor opened by OpenSorter (if in use) */
84763 int addr1; /* Address of top of loop */
84764 int addr2; /* Address to jump to for next iteration */
84765 int tnum; /* Root page of index */
84766 int iPartIdxLabel; /* Jump to this label to skip a row */
84767 Vdbe *v; /* Generate code into this virtual machine */
84768 KeyInfo *pKey; /* KeyInfo for index */
84769 int regRecord; /* Register holding assemblied index record */
84770 sqlite3 *db = pParse->db; /* The database connection */
84771 int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);
@@ -84641,12 +84801,13 @@
84801 ** records into the sorter. */
84802 sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
84803 addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0);
84804 regRecord = sqlite3GetTempReg(pParse);
84805
84806 sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1, &iPartIdxLabel);
84807 sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord);
84808 sqlite3VdbeResolveLabel(v, iPartIdxLabel);
84809 sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1);
84810 sqlite3VdbeJumpHere(v, addr1);
84811 addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0);
84812 if( pIndex->onError!=OE_None ){
84813 int j2 = sqlite3VdbeCurrentAddr(v) + 3;
@@ -84693,11 +84854,11 @@
84854 Token *pName2, /* Second part of index name. May be NULL */
84855 SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */
84856 ExprList *pList, /* A list of columns to be indexed */
84857 int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
84858 Token *pStart, /* The CREATE token that begins this statement */
84859 Expr *pPIWhere, /* WHERE clause for partial indices */
84860 int sortOrder, /* Sort order of primary key when pList==NULL */
84861 int ifNotExist /* Omit error if index already exists */
84862 ){
84863 Index *pRet = 0; /* Pointer to return */
84864 Table *pTab = 0; /* Table to be indexed */
@@ -84715,11 +84876,10 @@
84876 struct ExprList_item *pListItem; /* For looping over pList */
84877 int nCol;
84878 int nExtra = 0;
84879 char *zExtra;
84880
 
84881 assert( pParse->nErr==0 ); /* Never called with prior errors */
84882 if( db->mallocFailed || IN_DECLARE_VTAB ){
84883 goto exit_create_index;
84884 }
84885 if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
@@ -84761,11 +84921,16 @@
84921 assert(0);
84922 }
84923 pTab = sqlite3LocateTableItem(pParse, 0, &pTblName->a[0]);
84924 assert( db->mallocFailed==0 || pTab==0 );
84925 if( pTab==0 ) goto exit_create_index;
84926 if( iDb==1 && db->aDb[iDb].pSchema!=pTab->pSchema ){
84927 sqlite3ErrorMsg(pParse,
84928 "cannot create a TEMP index on non-TEMP table \"%s\"",
84929 pTab->zName);
84930 goto exit_create_index;
84931 }
84932 }else{
84933 assert( pName==0 );
84934 assert( pStart==0 );
84935 pTab = pParse->pNewTable;
84936 if( !pTab ) goto exit_create_index;
@@ -84910,10 +85075,15 @@
85075 pIndex->nColumn = pList->nExpr;
85076 pIndex->onError = (u8)onError;
85077 pIndex->uniqNotNull = onError==OE_Abort;
85078 pIndex->autoIndex = (u8)(pName==0);
85079 pIndex->pSchema = db->aDb[iDb].pSchema;
85080 if( pPIWhere ){
85081 sqlite3ResolveSelfReference(pParse, pTab, NC_PartIdx, pPIWhere, 0);
85082 pIndex->pPartIdxWhere = pPIWhere;
85083 pPIWhere = 0;
85084 }
85085 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
85086
85087 /* Check to see if we should honor DESC requests on index columns
85088 */
85089 if( pDb->pSchema->file_format>=4 ){
@@ -85065,11 +85235,11 @@
85235 ** If pTblName==0 it means this index is generated as a primary key
85236 ** or UNIQUE constraint of a CREATE TABLE statement. Since the table
85237 ** has just been created, it contains no data and the index initialization
85238 ** step can be skipped.
85239 */
85240 else if( pParse->nErr==0 ){
85241 Vdbe *v;
85242 char *zStmt;
85243 int iMem = ++pParse->nMem;
85244
85245 v = sqlite3GetVdbe(pParse);
@@ -85083,16 +85253,15 @@
85253
85254 /* Gather the complete text of the CREATE INDEX statement into
85255 ** the zStmt variable
85256 */
85257 if( pStart ){
85258 int n = (pParse->sLastToken.z - pName->z) + pParse->sLastToken.n;
85259 if( pName->z[n-1]==';' ) n--;
85260 /* A named index with an explicit CREATE INDEX statement */
85261 zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s",
85262 onError==OE_None ? "" : " UNIQUE", n, pName->z);
 
 
85263 }else{
85264 /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */
85265 /* zStmt = sqlite3MPrintf(""); */
85266 zStmt = 0;
85267 }
@@ -85144,14 +85313,12 @@
85313 pIndex = 0;
85314 }
85315
85316 /* Clean up before exiting */
85317 exit_create_index:
85318 if( pIndex ) freeIndex(db, pIndex);
85319 sqlite3ExprDelete(db, pPIWhere);
 
 
85320 sqlite3ExprListDelete(db, pList);
85321 sqlite3SrcListDelete(db, pTblName);
85322 sqlite3DbFree(db, zName);
85323 return pRet;
85324 }
@@ -87123,15 +87290,18 @@
87290 int *aRegIdx /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */
87291 ){
87292 int i;
87293 Index *pIdx;
87294 int r1;
87295 int iPartIdxLabel;
87296 Vdbe *v = pParse->pVdbe;
87297
87298 for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
87299 if( aRegIdx!=0 && aRegIdx[i-1]==0 ) continue;
87300 r1 = sqlite3GenerateIndexKey(pParse, pIdx, iCur, 0, 0, &iPartIdxLabel);
87301 sqlite3VdbeAddOp3(v, OP_IdxDelete, iCur+i, r1, pIdx->nColumn+1);
87302 sqlite3VdbeResolveLabel(v, iPartIdxLabel);
87303 }
87304 }
87305
87306 /*
87307 ** Generate code that will assemble an index key and put it in register
@@ -87141,24 +87311,42 @@
87311 **
87312 ** Return a register number which is the first in a block of
87313 ** registers that holds the elements of the index key. The
87314 ** block of registers has already been deallocated by the time
87315 ** this routine returns.
87316 **
87317 ** If *piPartIdxLabel is not NULL, fill it in with a label and jump
87318 ** to that label if pIdx is a partial index that should be skipped.
87319 ** A partial index should be skipped if its WHERE clause evaluates
87320 ** to false or null. If pIdx is not a partial index, *piPartIdxLabel
87321 ** will be set to zero which is an empty label that is ignored by
87322 ** sqlite3VdbeResolveLabel().
87323 */
87324 SQLITE_PRIVATE int sqlite3GenerateIndexKey(
87325 Parse *pParse, /* Parsing context */
87326 Index *pIdx, /* The index for which to generate a key */
87327 int iCur, /* Cursor number for the pIdx->pTable table */
87328 int regOut, /* Write the new index key to this register */
87329 int doMakeRec, /* Run the OP_MakeRecord instruction if true */
87330 int *piPartIdxLabel /* OUT: Jump to this label to skip partial index */
87331 ){
87332 Vdbe *v = pParse->pVdbe;
87333 int j;
87334 Table *pTab = pIdx->pTable;
87335 int regBase;
87336 int nCol;
87337
87338 if( piPartIdxLabel ){
87339 if( pIdx->pPartIdxWhere ){
87340 *piPartIdxLabel = sqlite3VdbeMakeLabel(v);
87341 pParse->iPartIdxTab = iCur;
87342 sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel,
87343 SQLITE_JUMPIFNULL);
87344 }else{
87345 *piPartIdxLabel = 0;
87346 }
87347 }
87348 nCol = pIdx->nColumn;
87349 regBase = sqlite3GetTempRange(pParse, nCol+1);
87350 sqlite3VdbeAddOp2(v, OP_Rowid, iCur, regBase+nCol);
87351 for(j=0; j<nCol; j++){
87352 int idx = pIdx->aiColumn[j];
@@ -91518,12 +91706,22 @@
91706 ** Add the new records to the indices as we go.
91707 */
91708 for(iCur=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, iCur++){
91709 int regIdx;
91710 int regR;
91711 int addrSkipRow = 0;
91712
91713 if( aRegIdx[iCur]==0 ) continue; /* Skip unused indices */
91714
91715 if( pIdx->pPartIdxWhere ){
91716 sqlite3VdbeAddOp2(v, OP_Null, 0, aRegIdx[iCur]);
91717 addrSkipRow = sqlite3VdbeMakeLabel(v);
91718 pParse->ckBase = regData;
91719 sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, addrSkipRow,
91720 SQLITE_JUMPIFNULL);
91721 pParse->ckBase = 0;
91722 }
91723
91724 /* Create a key for accessing the index entry */
91725 regIdx = sqlite3GetTempRange(pParse, pIdx->nColumn+1);
91726 for(i=0; i<pIdx->nColumn; i++){
91727 int idx = pIdx->aiColumn[i];
@@ -91540,10 +91738,11 @@
91738
91739 /* Find out what action to take in case there is an indexing conflict */
91740 onError = pIdx->onError;
91741 if( onError==OE_None ){
91742 sqlite3ReleaseTempRange(pParse, regIdx, pIdx->nColumn+1);
91743 sqlite3VdbeResolveLabel(v, addrSkipRow);
91744 continue; /* pIdx is not a UNIQUE index */
91745 }
91746 if( overrideError!=OE_Default ){
91747 onError = overrideError;
91748 }else if( onError==OE_Default ){
@@ -91609,10 +91808,11 @@
91808 seenReplace = 1;
91809 break;
91810 }
91811 }
91812 sqlite3VdbeJumpHere(v, j3);
91813 sqlite3VdbeResolveLabel(v, addrSkipRow);
91814 sqlite3ReleaseTempReg(pParse, regR);
91815 }
91816
91817 if( pbMayReplace ){
91818 *pbMayReplace = seenReplace;
@@ -91638,22 +91838,23 @@
91838 int appendBias, /* True if this is likely to be an append */
91839 int useSeekResult /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */
91840 ){
91841 int i;
91842 Vdbe *v;
 
91843 Index *pIdx;
91844 u8 pik_flags;
91845 int regData;
91846 int regRec;
91847
91848 v = sqlite3GetVdbe(pParse);
91849 assert( v!=0 );
91850 assert( pTab->pSelect==0 ); /* This table is not a VIEW */
91851 for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
 
91852 if( aRegIdx[i]==0 ) continue;
91853 if( pIdx->pPartIdxWhere ){
91854 sqlite3VdbeAddOp2(v, OP_IsNull, aRegIdx[i], sqlite3VdbeCurrentAddr(v)+2);
91855 }
91856 sqlite3VdbeAddOp2(v, OP_IdxInsert, baseCur+i+1, aRegIdx[i]);
91857 if( useSeekResult ){
91858 sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
91859 }
91860 }
@@ -91751,10 +91952,11 @@
91952 **
91953 ** * The index is over the same set of columns
91954 ** * The same DESC and ASC markings occurs on all columns
91955 ** * The same onError processing (OE_Abort, OE_Ignore, etc)
91956 ** * The same collating sequence on each column
91957 ** * The index has the exact same WHERE clause
91958 */
91959 static int xferCompatibleIndex(Index *pDest, Index *pSrc){
91960 int i;
91961 assert( pDest && pSrc );
91962 assert( pDest->pTable!=pSrc->pTable );
@@ -91772,10 +91974,13 @@
91974 return 0; /* Different sort orders */
91975 }
91976 if( !xferCompatibleCollation(pSrc->azColl[i],pDest->azColl[i]) ){
91977 return 0; /* Different collating sequences */
91978 }
91979 }
91980 if( sqlite3ExprCompare(pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){
91981 return 0; /* Different WHERE clauses */
91982 }
91983
91984 /* If no test above fails then the indices must be compatible */
91985 return 1;
91986 }
@@ -91928,11 +92133,11 @@
92133 if( pSrcIdx==0 ){
92134 return 0; /* pDestIdx has no corresponding index in pSrc */
92135 }
92136 }
92137 #ifndef SQLITE_OMIT_CHECK
92138 if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) ){
92139 return 0; /* Tables have different CHECK constraints. Ticket #2252 */
92140 }
92141 #endif
92142 #ifndef SQLITE_OMIT_FOREIGN_KEY
92143 /* Disallow the transfer optimization if the destination table constains
@@ -94841,13 +95046,11 @@
95046 cnt++;
95047 }
95048 }
95049
95050 /* Make sure sufficient number of registers have been allocated */
95051 pParse->nMem = MAX( pParse->nMem, cnt+7 );
 
 
95052
95053 /* Do the b-tree integrity checks */
95054 sqlite3VdbeAddOp3(v, OP_IntegrityCk, 2, cnt, 1);
95055 sqlite3VdbeChangeP5(v, (u8)i);
95056 addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2);
@@ -94868,16 +95071,19 @@
95071
95072 if( pTab->pIndex==0 ) continue;
95073 addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Stop if out of errors */
95074 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
95075 sqlite3VdbeJumpHere(v, addr);
95076 sqlite3ExprCacheClear(pParse);
95077 sqlite3OpenTableAndIndices(pParse, pTab, 1, OP_OpenRead);
95078 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
95079 sqlite3VdbeAddOp2(v, OP_Integer, 0, 7+j); /* index entries counter */
95080 }
95081 pParse->nMem = MAX(pParse->nMem, 7+j);
95082 loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0) + 1;
95083 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
95084 int jmp2, jmp3;
95085 int r1;
95086 static const VdbeOpList idxErr[] = {
95087 { OP_AddImm, 1, -1, 0},
95088 { OP_String8, 0, 3, 0}, /* 1 */
95089 { OP_Rowid, 1, 4, 0},
@@ -94888,47 +95094,38 @@
95094 { OP_Concat, 6, 3, 3},
95095 { OP_ResultRow, 3, 1, 0},
95096 { OP_IfPos, 1, 0, 0}, /* 9 */
95097 { OP_Halt, 0, 0, 0},
95098 };
95099 r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 0, &jmp3);
95100 sqlite3VdbeAddOp2(v, OP_AddImm, 7+j, 1); /* increment entry count */
95101 jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, j+2, 0, r1, pIdx->nColumn+1);
95102 addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr);
95103 sqlite3VdbeChangeP4(v, addr+1, "rowid ", P4_STATIC);
95104 sqlite3VdbeChangeP4(v, addr+3, " missing from index ", P4_STATIC);
95105 sqlite3VdbeChangeP4(v, addr+4, pIdx->zName, P4_TRANSIENT);
95106 sqlite3VdbeJumpHere(v, addr+9);
95107 sqlite3VdbeJumpHere(v, jmp2);
95108 sqlite3VdbeResolveLabel(v, jmp3);
95109 }
95110 sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop);
95111 sqlite3VdbeJumpHere(v, loopTop-1);
95112 #ifndef SQLITE_OMIT_BTREECOUNT
95113 sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0,
95114 "wrong # of entries in index ", P4_STATIC);
95115 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
95116 addr = sqlite3VdbeCurrentAddr(v);
95117 sqlite3VdbeAddOp2(v, OP_IfPos, 1, addr+2);
 
 
 
 
 
 
 
 
 
 
 
95118 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
95119 sqlite3VdbeAddOp2(v, OP_Count, j+2, 3);
95120 sqlite3VdbeAddOp3(v, OP_Eq, 7+j, addr+8, 3);
95121 sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1);
95122 sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pIdx->zName, P4_TRANSIENT);
95123 sqlite3VdbeAddOp3(v, OP_Concat, 3, 2, 7);
95124 sqlite3VdbeAddOp2(v, OP_ResultRow, 7, 1);
95125 }
95126 #endif /* SQLITE_OMIT_BTREECOUNT */
 
 
 
95127 }
95128 }
95129 addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode);
95130 sqlite3VdbeChangeP2(v, addr, -mxErr);
95131 sqlite3VdbeJumpHere(v, addr+1);
@@ -100327,11 +100524,11 @@
100524 ** will cause elements to come out in the correct order. This is
100525 ** an optimization - the correct answer should result regardless.
100526 ** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER
100527 ** to disable this optimization for testing purposes.
100528 */
100529 if( sqlite3ExprListCompare(p->pGroupBy, pOrderBy, -1)==0
100530 && OptimizationEnabled(db, SQLITE_GroupByOrder) ){
100531 pOrderBy = 0;
100532 }
100533
100534 /* If the query is DISTINCT with an ORDER BY but is not an aggregate, and
@@ -100348,11 +100545,11 @@
100545 ** used for both the ORDER BY and DISTINCT processing. As originally
100546 ** written the query must use a temp-table for at least one of the ORDER
100547 ** BY and DISTINCT, and an index or separate temp-table for the other.
100548 */
100549 if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct
100550 && sqlite3ExprListCompare(pOrderBy, p->pEList, -1)==0
100551 ){
100552 p->selFlags &= ~SF_Distinct;
100553 p->pGroupBy = sqlite3ExprListDup(db, p->pEList, 0);
100554 pGroupBy = p->pGroupBy;
100555 pOrderBy = 0;
@@ -102575,11 +102772,11 @@
102772 aRegIdx = sqlite3DbMallocRaw(db, sizeof(Index*) * nIdx );
102773 if( aRegIdx==0 ) goto update_cleanup;
102774 }
102775 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
102776 int reg;
102777 if( hasFK || chngRowid || pIdx->pPartIdxWhere ){
102778 reg = ++pParse->nMem;
102779 }else{
102780 reg = 0;
102781 for(i=0; i<pIdx->nColumn; i++){
102782 if( aXRef[pIdx->aiColumn[i]]>=0 ){
@@ -105115,11 +105312,11 @@
105312 ** the pWC->a[] array.
105313 */
105314 static int whereClauseInsert(WhereClause *pWC, Expr *p, u8 wtFlags){
105315 WhereTerm *pTerm;
105316 int idx;
105317 testcase( wtFlags & TERM_VIRTUAL );
105318 if( pWC->nTerm>=pWC->nSlot ){
105319 WhereTerm *pOld = pWC->a;
105320 sqlite3 *db = pWC->pWInfo->pParse->db;
105321 pWC->a = sqlite3DbMallocRaw(db, sizeof(pWC->a[0])*pWC->nSlot*2 );
105322 if( pWC->a==0 ){
@@ -105260,17 +105457,10 @@
105457
105458 /*
105459 ** Return TRUE if the given operator is one of the operators that is
105460 ** allowed for an indexable WHERE clause term. The allowed operators are
105461 ** "=", "<", ">", "<=", ">=", "IN", and "IS NULL"
 
 
 
 
 
 
 
105462 */
105463 static int allowedOp(int op){
105464 assert( TK_GT>TK_EQ && TK_GT<TK_GE );
105465 assert( TK_LT>TK_EQ && TK_LT<TK_GE );
105466 assert( TK_LE>TK_EQ && TK_LE<TK_GE );
@@ -105585,11 +105775,11 @@
105775 op = pRight->op2;
105776 }
105777 if( op==TK_VARIABLE ){
105778 Vdbe *pReprepare = pParse->pReprepare;
105779 int iCol = pRight->iColumn;
105780 pVal = sqlite3VdbeGetBoundValue(pReprepare, iCol, SQLITE_AFF_NONE);
105781 if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
105782 z = (char *)sqlite3_value_text(pVal);
105783 }
105784 sqlite3VdbeSetVarmask(pParse->pVdbe, iCol);
105785 assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );
@@ -105940,12 +106130,10 @@
106130 }
106131
106132 /* At this point, okToChngToIN is true if original pTerm satisfies
106133 ** case 1. In that case, construct a new virtual term that is
106134 ** pTerm converted into an IN operator.
 
 
106135 */
106136 if( okToChngToIN ){
106137 Expr *pDup; /* A transient duplicate expression */
106138 ExprList *pList = 0; /* The RHS of the IN operator */
106139 Expr *pLeft = 0; /* The LHS of the IN operator */
@@ -106183,13 +106371,11 @@
106371 ** wildcard. But if we increment '@', that will push it into the
106372 ** alphabetic range where case conversions will mess up the
106373 ** inequality. To avoid this, make sure to also run the full
106374 ** LIKE on all candidate expressions by clearing the isComplete flag
106375 */
106376 if( c=='A'-1 ) isComplete = 0;
 
 
106377 c = sqlite3UpperToLower[c];
106378 }
106379 *pC = c + 1;
106380 }
106381 sCollSeqName.z = noCase ? "NOCASE" : "BINARY";
@@ -106692,11 +106878,11 @@
106878 VdbeComment((v, "for %s", pTable->zName));
106879
106880 /* Fill the automatic index with content */
106881 addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur);
106882 regRecord = sqlite3GetTempReg(pParse);
106883 sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 1, 0);
106884 sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
106885 sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
106886 sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1);
106887 sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
106888 sqlite3VdbeJumpHere(v, addrTop);
@@ -107049,11 +107235,11 @@
107235 if( pExpr->op==TK_VARIABLE
107236 || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
107237 ){
107238 int iVar = pExpr->iColumn;
107239 sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);
107240 *pp = sqlite3VdbeGetBoundValue(pParse->pReprepare, iVar, aff);
107241 return SQLITE_OK;
107242 }
107243 return sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, aff, pp);
107244 }
107245 #endif
@@ -107275,13 +107461,10 @@
107461 **
107462 ** The t2.z='ok' is disabled in the in (2) because it originates
107463 ** in the ON clause. The term is disabled in (3) because it is not part
107464 ** of a LEFT OUTER JOIN. In (1), the term is not disabled.
107465 **
 
 
 
107466 ** Disabling a term causes that term to not be tested in the inner loop
107467 ** of the join. Disabling is an optimization. When terms are satisfied
107468 ** by indices, we disable them to prevent redundant tests in the inner
107469 ** loop. We would get the correct results if nothing were ever disabled,
107470 ** but joins might run a little slower. The trick is to disable as much
@@ -107507,11 +107690,11 @@
107690 pTerm = pLoop->aLTerm[j];
107691 assert( pTerm!=0 );
107692 /* The following true for indices with redundant columns.
107693 ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */
107694 testcase( (pTerm->wtFlags & TERM_CODED)!=0 );
107695 testcase( pTerm->wtFlags & TERM_VIRTUAL );
107696 r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, regBase+j);
107697 if( r1!=regBase+j ){
107698 if( nReg==1 ){
107699 sqlite3ReleaseTempReg(pParse, regBase);
107700 regBase = r1;
@@ -107707,10 +107890,11 @@
107890 WhereLevel *pLevel; /* The where level to be coded */
107891 WhereLoop *pLoop; /* The WhereLoop object being coded */
107892 WhereClause *pWC; /* Decomposition of the entire WHERE clause */
107893 WhereTerm *pTerm; /* A WHERE clause term */
107894 Parse *pParse; /* Parsing context */
107895 sqlite3 *db; /* Database connection */
107896 Vdbe *v; /* The prepared stmt under constructions */
107897 struct SrcList_item *pTabItem; /* FROM clause term being coded */
107898 int addrBrk; /* Jump here to break out of the loop */
107899 int addrCont; /* Jump here to continue with next cycle */
107900 int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
@@ -107718,10 +107902,11 @@
107902 Bitmask newNotReady; /* Return value */
107903
107904 pParse = pWInfo->pParse;
107905 v = pParse->pVdbe;
107906 pWC = &pWInfo->sWC;
107907 db = pParse->db;
107908 pLevel = &pWInfo->a[iLevel];
107909 pLoop = pLevel->pWLoop;
107910 pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
107911 iCur = pTabItem->iCursor;
107912 bRev = (pWInfo->revMask>>iLevel)&1;
@@ -107816,11 +108001,11 @@
108001 iReleaseReg = sqlite3GetTempReg(pParse);
108002 pTerm = pLoop->aLTerm[0];
108003 assert( pTerm!=0 );
108004 assert( pTerm->pExpr!=0 );
108005 assert( omitTable==0 );
108006 testcase( pTerm->wtFlags & TERM_VIRTUAL );
108007 iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
108008 addrNxt = pLevel->addrNxt;
108009 sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt);
108010 sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg);
108011 sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1);
@@ -107864,11 +108049,11 @@
108049 assert( TK_LE==TK_GT+1 ); /* Make sure the ordering.. */
108050 assert( TK_LT==TK_GT+2 ); /* ... of the TK_xx values... */
108051 assert( TK_GE==TK_GT+3 ); /* ... is correcct. */
108052
108053 assert( (pStart->wtFlags & TERM_VNULL)==0 );
108054 testcase( pStart->wtFlags & TERM_VIRTUAL );
108055 pX = pStart->pExpr;
108056 assert( pX!=0 );
108057 testcase( pStart->leftCursor!=iCur ); /* transitive constraints */
108058 r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);
108059 sqlite3VdbeAddOp3(v, aMoveOp[pX->op-TK_GT], iCur, addrBrk, r1);
@@ -107883,11 +108068,11 @@
108068 Expr *pX;
108069 pX = pEnd->pExpr;
108070 assert( pX!=0 );
108071 assert( (pEnd->wtFlags & TERM_VNULL)==0 );
108072 testcase( pEnd->leftCursor!=iCur ); /* Transitive constraints */
108073 testcase( pEnd->wtFlags & TERM_VIRTUAL );
108074 memEndValue = ++pParse->nMem;
108075 sqlite3ExprCode(pParse, pX->pRight, memEndValue);
108076 if( pX->op==TK_LT || pX->op==TK_GT ){
108077 testOp = bRev ? OP_Le : OP_Ge;
108078 }else{
@@ -108008,11 +108193,11 @@
108193 /* Generate code to evaluate all constraint terms using == or IN
108194 ** and store the values of those terms in an array of registers
108195 ** starting at regBase.
108196 */
108197 regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
108198 zEndAff = sqlite3DbStrDup(db, zStartAff);
108199 addrNxt = pLevel->addrNxt;
108200
108201 /* If we are doing a reverse order scan on an ascending index, or
108202 ** a forward order scan on a descending index, interchange the
108203 ** start and end terms (pRangeStart and pRangeEnd).
@@ -108049,11 +108234,11 @@
108234 if( sqlite3ExprNeedsNoAffinityChange(pRight, zStartAff[nEq]) ){
108235 zStartAff[nEq] = SQLITE_AFF_NONE;
108236 }
108237 }
108238 nConstraint++;
108239 testcase( pRangeStart->wtFlags & TERM_VIRTUAL );
108240 }else if( isMinQuery ){
108241 sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
108242 nConstraint++;
108243 startEq = 0;
108244 start_constraints = 1;
@@ -108091,14 +108276,14 @@
108276 zEndAff[nEq] = SQLITE_AFF_NONE;
108277 }
108278 }
108279 codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
108280 nConstraint++;
108281 testcase( pRangeEnd->wtFlags & TERM_VIRTUAL );
108282 }
108283 sqlite3DbFree(db, zStartAff);
108284 sqlite3DbFree(db, zEndAff);
108285
108286 /* Top of the loop body */
108287 pLevel->p2 = sqlite3VdbeCurrentAddr(v);
108288
108289 /* Check if the index cursor is past the end of the range. */
@@ -108221,11 +108406,11 @@
108406 */
108407 if( pWInfo->nLevel>1 ){
108408 int nNotReady; /* The number of notReady tables */
108409 struct SrcList_item *origSrc; /* Original list of tables */
108410 nNotReady = pWInfo->nLevel - iLevel - 1;
108411 pOrTab = sqlite3StackAllocRaw(db,
108412 sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
108413 if( pOrTab==0 ) return notReady;
108414 pOrTab->nAlloc = (u8)(nNotReady + 1);
108415 pOrTab->nSrc = pOrTab->nAlloc;
108416 memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
@@ -108275,12 +108460,12 @@
108460 Expr *pExpr = pWC->a[iTerm].pExpr;
108461 if( &pWC->a[iTerm] == pTerm ) continue;
108462 if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
108463 if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue;
108464 if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
108465 pExpr = sqlite3ExprDup(db, pExpr, 0);
108466 pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);
108467 }
108468 if( pAndExpr ){
108469 pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);
108470 }
108471 }
@@ -108296,11 +108481,11 @@
108481 }
108482 /* Loop through table entries that match term pOrTerm. */
108483 pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
108484 WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
108485 WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);
108486 assert( pSubWInfo || pParse->nErr || db->mallocFailed );
108487 if( pSubWInfo ){
108488 WhereLoop *pSubLoop;
108489 explainOneScan(
108490 pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
108491 );
@@ -108351,17 +108536,17 @@
108536 }
108537 pLevel->u.pCovidx = pCov;
108538 if( pCov ) pLevel->iIdxCur = iCovCur;
108539 if( pAndExpr ){
108540 pAndExpr->pLeft = 0;
108541 sqlite3ExprDelete(db, pAndExpr);
108542 }
108543 sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
108544 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
108545 sqlite3VdbeResolveLabel(v, iLoopBody);
108546
108547 if( pWInfo->nLevel>1 ) sqlite3StackFree(db, pOrTab);
108548 if( !untestedTerms ) disableTerm(pLevel, pTerm);
108549 }else
108550 #endif /* SQLITE_OMIT_OR_OPTIMIZATION */
108551
108552 {
@@ -108378,18 +108563,14 @@
108563 }
108564 newNotReady = notReady & ~getMask(&pWInfo->sMaskSet, iCur);
108565
108566 /* Insert code to test every subexpression that can be completely
108567 ** computed using the current set of tables.
 
 
 
 
108568 */
108569 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108570 Expr *pE;
108571 testcase( pTerm->wtFlags & TERM_VIRTUAL );
108572 testcase( pTerm->wtFlags & TERM_CODED );
108573 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108574 if( (pTerm->prereqAll & newNotReady)!=0 ){
108575 testcase( pWInfo->untestedTerms==0
108576 && (pWInfo->wctrlFlags & WHERE_ONETABLE_ONLY)!=0 );
@@ -108412,13 +108593,12 @@
108593 ** and we are coding the t1 loop and the t2 loop has not yet coded,
108594 ** then we cannot use the "t1.a=t2.b" constraint, but we can code
108595 ** the implied "t1.a=123" constraint.
108596 */
108597 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108598 Expr *pE, *pEAlt;
108599 WhereTerm *pAlt;
 
108600 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108601 if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108602 if( pTerm->leftCursor!=iCur ) continue;
108603 if( pLevel->iLeftJoin ) continue;
108604 pE = pTerm->pExpr;
@@ -108428,13 +108608,17 @@
108608 if( pAlt==0 ) continue;
108609 if( pAlt->wtFlags & (TERM_CODED) ) continue;
108610 testcase( pAlt->eOperator & WO_EQ );
108611 testcase( pAlt->eOperator & WO_IN );
108612 VdbeNoopComment((v, "begin transitive constraint"));
108613 pEAlt = sqlite3StackAllocRaw(db, sizeof(*pEAlt));
108614 if( pEAlt ){
108615 *pEAlt = *pAlt->pExpr;
108616 pEAlt->pLeft = pE->pLeft;
108617 sqlite3ExprIfFalse(pParse, pEAlt, addrCont, SQLITE_JUMPIFNULL);
108618 sqlite3StackFree(db, pEAlt);
108619 }
108620 }
108621
108622 /* For a LEFT OUTER JOIN, generate code that will record the fact that
108623 ** at least one row of the right table has matched the left table.
108624 */
@@ -108442,11 +108626,11 @@
108626 pLevel->addrFirst = sqlite3VdbeCurrentAddr(v);
108627 sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin);
108628 VdbeComment((v, "record LEFT JOIN hit"));
108629 sqlite3ExprCacheClear(pParse);
108630 for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){
108631 testcase( pTerm->wtFlags & TERM_VIRTUAL );
108632 testcase( pTerm->wtFlags & TERM_CODED );
108633 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108634 if( (pTerm->prereqAll & newNotReady)!=0 ){
108635 assert( pWInfo->untestedTerms );
108636 continue;
@@ -108883,11 +109067,12 @@
109067 rc = whereEqualScanEst(pParse, pProbe, pTerm->pExpr->pRight, &nOut);
109068 }else if( (pTerm->eOperator & WO_IN)
109069 && !ExprHasProperty(pTerm->pExpr, EP_xIsSelect) ){
109070 rc = whereInScanEst(pParse, pProbe, pTerm->pExpr->x.pList, &nOut);
109071 }
109072 assert( nOut==0 || rc==SQLITE_OK );
109073 if( nOut ) pNew->nOut = whereCost(nOut);
109074 }
109075 #endif
109076 if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
109077 /* Each row involves a step of the index, then a binary search of
109078 ** the main table */
@@ -108955,10 +109140,21 @@
109140 if( x<BMS-1 ) m |= MASKBIT(x);
109141 }
109142 return m;
109143 }
109144
109145 /* Check to see if a partial index with pPartIndexWhere can be used
109146 ** in the current query. Return true if it can be and false if not.
109147 */
109148 static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){
109149 int i;
109150 WhereTerm *pTerm;
109151 for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
109152 if( sqlite3ExprImpliesExpr(pTerm->pExpr, pWhere, iTab) ) return 1;
109153 }
109154 return 0;
109155 }
109156
109157 /*
109158 ** Add all WhereLoop objects for a single table of the join where the table
109159 ** is idenfied by pBuilder->pNew->iTab. That table is guaranteed to be
109160 ** a b-tree table, not a virtual table.
@@ -108978,15 +109174,17 @@
109174 int rc = SQLITE_OK; /* Return code */
109175 int iSortIdx = 1; /* Index number */
109176 int b; /* A boolean value */
109177 WhereCost rSize; /* number of rows in the table */
109178 WhereCost rLogSize; /* Logarithm of the number of rows in the table */
109179 WhereClause *pWC; /* The parsed WHERE clause */
109180
109181 pNew = pBuilder->pNew;
109182 pWInfo = pBuilder->pWInfo;
109183 pTabList = pWInfo->pTabList;
109184 pSrc = pTabList->a + pNew->iTab;
109185 pWC = pBuilder->pWC;
109186 assert( !IsVirtual(pSrc->pTab) );
109187
109188 if( pSrc->pIndex ){
109189 /* An INDEXED BY clause specifies a particular index to use */
109190 pProbe = pSrc->pIndex;
@@ -109022,11 +109220,10 @@
109220 && !pSrc->viaCoroutine
109221 && !pSrc->notIndexed
109222 && !pSrc->isCorrelated
109223 ){
109224 /* Generate auto-index WhereLoops */
 
109225 WhereTerm *pTerm;
109226 WhereTerm *pWCEnd = pWC->a + pWC->nTerm;
109227 for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){
109228 if( pTerm->prereqRight & pNew->maskSelf ) continue;
109229 if( termCanDriveIndex(pTerm, pSrc, 0) ){
@@ -109052,10 +109249,14 @@
109249 }
109250
109251 /* Loop over all indices
109252 */
109253 for(; rc==SQLITE_OK && pProbe; pProbe=pProbe->pNext, iSortIdx++){
109254 if( pProbe->pPartIdxWhere!=0
109255 && !whereUsablePartialIndex(pNew->iTab, pWC, pProbe->pPartIdxWhere) ){
109256 continue; /* Partial index inappropriate for this query */
109257 }
109258 pNew->u.btree.nEq = 0;
109259 pNew->nLTerm = 0;
109260 pNew->iSortIdx = 0;
109261 pNew->rSetup = 0;
109262 pNew->prereq = mExtra;
@@ -109992,11 +110193,11 @@
110193 pLoop->u.btree.nEq = 1;
110194 /* TUNING: Cost of a rowid lookup is 10 */
110195 pLoop->rRun = 33; /* 33==whereCost(10) */
110196 }else{
110197 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
110198 if( pIdx->onError==OE_None || pIdx->pPartIdxWhere!=0 ) continue;
110199 for(j=0; j<pIdx->nColumn; j++){
110200 pTerm = findTerm(pWC, iCur, pIdx->aiColumn[j], 0, WO_EQ, pIdx);
110201 if( pTerm==0 ) break;
110202 whereLoopResize(pWInfo->pParse->db, pLoop, j);
110203 pLoop->aLTerm[j] = pTerm;
@@ -110198,11 +110399,11 @@
110399 ** subexpression is separated by an AND operator.
110400 */
110401 initMaskSet(pMaskSet);
110402 whereClauseInit(&pWInfo->sWC, pWInfo);
110403 sqlite3ExprCodeConstants(pParse, pWhere);
110404 whereSplit(&pWInfo->sWC, pWhere, TK_AND);
110405 sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */
110406
110407 /* Special case: a WHERE clause that is constant. Evaluate the
110408 ** expression and either jump over all of the code or fall thru.
110409 */
@@ -110832,11 +111033,11 @@
111033 #endif
111034 #define sqlite3ParserARG_SDECL Parse *pParse;
111035 #define sqlite3ParserARG_PDECL ,Parse *pParse
111036 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
111037 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
111038 #define YYNSTATE 628
111039 #define YYNRULE 327
111040 #define YYFALLBACK 1
111041 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
111042 #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
111043 #define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
@@ -110905,167 +111106,167 @@
111106 ** shifting non-terminals after a reduce.
111107 ** yy_default[] Default action for each state.
111108 */
111109 #define YY_ACTTAB_COUNT (1564)
111110 static const YYACTIONTYPE yy_action[] = {
111111 /* 0 */ 310, 956, 184, 418, 2, 171, 625, 595, 56, 56,
111112 /* 10 */ 56, 56, 49, 54, 54, 54, 54, 53, 53, 52,
111113 /* 20 */ 52, 52, 51, 233, 621, 620, 299, 621, 620, 234,
111114 /* 30 */ 588, 582, 56, 56, 56, 56, 19, 54, 54, 54,
111115 /* 40 */ 54, 53, 53, 52, 52, 52, 51, 233, 606, 57,
111116 /* 50 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
111117 /* 60 */ 56, 56, 542, 54, 54, 54, 54, 53, 53, 52,
111118 /* 70 */ 52, 52, 51, 233, 310, 595, 326, 196, 195, 194,
111119 /* 80 */ 33, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111120 /* 90 */ 51, 233, 618, 617, 165, 618, 617, 381, 378, 377,
111121 /* 100 */ 408, 533, 577, 577, 588, 582, 304, 423, 376, 59,
111122 /* 110 */ 53, 53, 52, 52, 52, 51, 233, 50, 47, 146,
111123 /* 120 */ 575, 546, 65, 57, 58, 48, 580, 579, 581, 581,
111124 /* 130 */ 55, 55, 56, 56, 56, 56, 213, 54, 54, 54,
111125 /* 140 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 223,
111126 /* 150 */ 540, 421, 170, 176, 138, 281, 384, 276, 383, 168,
111127 /* 160 */ 490, 552, 410, 669, 621, 620, 272, 439, 410, 439,
111128 /* 170 */ 551, 605, 67, 483, 508, 619, 600, 413, 588, 582,
111129 /* 180 */ 601, 484, 619, 413, 619, 599, 91, 440, 441, 440,
111130 /* 190 */ 336, 599, 73, 670, 222, 267, 481, 57, 58, 48,
111131 /* 200 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
111132 /* 210 */ 671, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111133 /* 220 */ 51, 233, 310, 280, 232, 231, 1, 132, 200, 386,
111134 /* 230 */ 621, 620, 618, 617, 279, 436, 290, 564, 175, 263,
111135 /* 240 */ 410, 265, 438, 498, 437, 166, 442, 569, 337, 569,
111136 /* 250 */ 201, 538, 588, 582, 600, 413, 165, 595, 601, 381,
111137 /* 260 */ 378, 377, 598, 599, 92, 524, 619, 570, 570, 593,
111138 /* 270 */ 376, 57, 58, 48, 580, 579, 581, 581, 55, 55,
111139 /* 280 */ 56, 56, 56, 56, 598, 54, 54, 54, 54, 53,
111140 /* 290 */ 53, 52, 52, 52, 51, 233, 310, 464, 618, 617,
111141 /* 300 */ 591, 591, 591, 174, 273, 397, 410, 273, 410, 549,
111142 /* 310 */ 398, 621, 620, 68, 327, 621, 620, 621, 620, 619,
111143 /* 320 */ 547, 413, 619, 413, 472, 595, 588, 582, 473, 599,
111144 /* 330 */ 92, 599, 92, 52, 52, 52, 51, 233, 514, 513,
111145 /* 340 */ 206, 323, 364, 465, 221, 57, 58, 48, 580, 579,
111146 /* 350 */ 581, 581, 55, 55, 56, 56, 56, 56, 530, 54,
111147 /* 360 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
111148 /* 370 */ 310, 397, 410, 397, 598, 373, 387, 531, 348, 618,
111149 /* 380 */ 617, 576, 202, 618, 617, 618, 617, 413, 621, 620,
111150 /* 390 */ 145, 255, 347, 254, 578, 599, 74, 352, 45, 490,
111151 /* 400 */ 588, 582, 235, 189, 465, 545, 167, 297, 187, 470,
111152 /* 410 */ 480, 67, 62, 39, 619, 547, 598, 346, 574, 57,
111153 /* 420 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
111154 /* 430 */ 56, 56, 6, 54, 54, 54, 54, 53, 53, 52,
111155 /* 440 */ 52, 52, 51, 233, 310, 563, 559, 408, 529, 577,
111156 /* 450 */ 577, 345, 255, 347, 254, 182, 618, 617, 504, 505,
111157 /* 460 */ 315, 410, 558, 235, 166, 272, 410, 353, 565, 181,
111158 /* 470 */ 408, 547, 577, 577, 588, 582, 413, 538, 557, 562,
111159 /* 480 */ 518, 413, 619, 249, 599, 16, 7, 36, 468, 599,
111160 /* 490 */ 92, 517, 619, 57, 58, 48, 580, 579, 581, 581,
111161 /* 500 */ 55, 55, 56, 56, 56, 56, 542, 54, 54, 54,
111162 /* 510 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 328,
111163 /* 520 */ 573, 572, 526, 559, 561, 395, 872, 246, 410, 248,
111164 /* 530 */ 171, 393, 595, 219, 408, 410, 577, 577, 503, 558,
111165 /* 540 */ 365, 145, 511, 413, 408, 229, 577, 577, 588, 582,
111166 /* 550 */ 413, 599, 92, 382, 270, 557, 166, 401, 599, 69,
111167 /* 560 */ 502, 420, 946, 199, 946, 198, 547, 57, 58, 48,
111168 /* 570 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
111169 /* 580 */ 569, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111170 /* 590 */ 51, 233, 310, 318, 420, 945, 509, 945, 309, 598,
111171 /* 600 */ 595, 566, 491, 212, 173, 247, 424, 616, 615, 614,
111172 /* 610 */ 324, 197, 143, 406, 573, 572, 490, 66, 50, 47,
111173 /* 620 */ 146, 595, 588, 582, 232, 231, 560, 428, 67, 556,
111174 /* 630 */ 15, 619, 186, 544, 304, 422, 35, 206, 433, 424,
111175 /* 640 */ 553, 57, 58, 48, 580, 579, 581, 581, 55, 55,
111176 /* 650 */ 56, 56, 56, 56, 205, 54, 54, 54, 54, 53,
111177 /* 660 */ 53, 52, 52, 52, 51, 233, 310, 570, 570, 261,
111178 /* 670 */ 269, 598, 12, 374, 569, 166, 410, 314, 410, 421,
111179 /* 680 */ 410, 474, 474, 366, 619, 50, 47, 146, 598, 595,
111180 /* 690 */ 256, 413, 166, 413, 352, 413, 588, 582, 32, 599,
111181 /* 700 */ 94, 599, 97, 599, 95, 628, 626, 330, 142, 50,
111182 /* 710 */ 47, 146, 334, 350, 359, 57, 58, 48, 580, 579,
111183 /* 720 */ 581, 581, 55, 55, 56, 56, 56, 56, 410, 54,
111184 /* 730 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
111185 /* 740 */ 310, 410, 389, 413, 410, 22, 566, 405, 212, 363,
111186 /* 750 */ 390, 599, 104, 360, 410, 156, 413, 410, 604, 413,
111187 /* 760 */ 538, 332, 570, 570, 599, 103, 494, 599, 105, 413,
111188 /* 770 */ 588, 582, 413, 261, 550, 619, 11, 599, 106, 522,
111189 /* 780 */ 599, 133, 169, 458, 457, 170, 35, 602, 619, 57,
111190 /* 790 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
111191 /* 800 */ 56, 56, 410, 54, 54, 54, 54, 53, 53, 52,
111192 /* 810 */ 52, 52, 51, 233, 310, 410, 260, 413, 410, 50,
111193 /* 820 */ 47, 146, 358, 319, 356, 599, 134, 528, 353, 338,
111194 /* 830 */ 413, 410, 357, 413, 358, 410, 358, 619, 599, 98,
111195 /* 840 */ 129, 599, 102, 619, 588, 582, 413, 21, 235, 619,
111196 /* 850 */ 413, 619, 211, 143, 599, 101, 30, 167, 599, 93,
111197 /* 860 */ 351, 536, 203, 57, 58, 48, 580, 579, 581, 581,
111198 /* 870 */ 55, 55, 56, 56, 56, 56, 410, 54, 54, 54,
111199 /* 880 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 410,
111200 /* 890 */ 527, 413, 410, 426, 215, 306, 598, 552, 141, 599,
111201 /* 900 */ 100, 40, 410, 38, 413, 410, 551, 413, 410, 228,
111202 /* 910 */ 220, 315, 599, 77, 501, 599, 96, 413, 588, 582,
111203 /* 920 */ 413, 339, 253, 413, 218, 599, 137, 380, 599, 136,
111204 /* 930 */ 28, 599, 135, 271, 716, 210, 482, 57, 58, 48,
111205 /* 940 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
111206 /* 950 */ 410, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111207 /* 960 */ 51, 233, 310, 410, 273, 413, 410, 316, 147, 598,
111208 /* 970 */ 273, 627, 2, 599, 76, 209, 410, 127, 413, 619,
111209 /* 980 */ 126, 413, 410, 622, 235, 619, 599, 90, 375, 599,
111210 /* 990 */ 89, 413, 588, 582, 27, 261, 351, 413, 619, 599,
111211 /* 1000 */ 75, 322, 542, 542, 125, 599, 88, 321, 279, 598,
111212 /* 1010 */ 619, 57, 46, 48, 580, 579, 581, 581, 55, 55,
111213 /* 1020 */ 56, 56, 56, 56, 410, 54, 54, 54, 54, 53,
111214 /* 1030 */ 53, 52, 52, 52, 51, 233, 310, 410, 451, 413,
111215 /* 1040 */ 164, 285, 283, 273, 610, 425, 305, 599, 87, 371,
111216 /* 1050 */ 410, 478, 413, 410, 609, 410, 608, 603, 619, 619,
111217 /* 1060 */ 599, 99, 587, 586, 122, 413, 588, 582, 413, 619,
111218 /* 1070 */ 413, 619, 619, 599, 86, 367, 599, 17, 599, 85,
111219 /* 1080 */ 320, 185, 520, 519, 584, 583, 58, 48, 580, 579,
111220 /* 1090 */ 581, 581, 55, 55, 56, 56, 56, 56, 410, 54,
111221 /* 1100 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
111222 /* 1110 */ 310, 585, 410, 413, 410, 261, 261, 261, 409, 592,
111223 /* 1120 */ 475, 599, 84, 170, 410, 467, 519, 413, 121, 413,
111224 /* 1130 */ 619, 619, 619, 619, 619, 599, 83, 599, 72, 413,
111225 /* 1140 */ 588, 582, 51, 233, 626, 330, 471, 599, 71, 258,
111226 /* 1150 */ 159, 120, 14, 463, 157, 158, 117, 261, 449, 448,
111227 /* 1160 */ 447, 48, 580, 579, 581, 581, 55, 55, 56, 56,
111228 /* 1170 */ 56, 56, 619, 54, 54, 54, 54, 53, 53, 52,
111229 /* 1180 */ 52, 52, 51, 233, 44, 404, 261, 3, 410, 460,
111230 /* 1190 */ 261, 414, 620, 118, 399, 10, 25, 24, 555, 349,
111231 /* 1200 */ 217, 619, 407, 413, 410, 619, 4, 44, 404, 619,
111232 /* 1210 */ 3, 599, 82, 619, 414, 620, 456, 543, 115, 413,
111233 /* 1220 */ 539, 402, 537, 275, 507, 407, 251, 599, 81, 216,
111234 /* 1230 */ 274, 564, 619, 243, 454, 619, 154, 619, 619, 619,
111235 /* 1240 */ 450, 417, 624, 110, 402, 619, 410, 236, 64, 123,
111236 /* 1250 */ 488, 41, 42, 532, 564, 204, 410, 268, 43, 412,
111237 /* 1260 */ 411, 413, 266, 593, 108, 619, 107, 435, 333, 599,
111238 /* 1270 */ 80, 413, 619, 264, 41, 42, 444, 619, 410, 599,
111239 /* 1280 */ 70, 43, 412, 411, 434, 262, 593, 149, 619, 598,
111240 /* 1290 */ 257, 237, 188, 413, 591, 591, 591, 590, 589, 13,
111241 /* 1300 */ 619, 599, 18, 329, 235, 619, 44, 404, 361, 3,
111242 /* 1310 */ 419, 462, 340, 414, 620, 227, 124, 591, 591, 591,
111243 /* 1320 */ 590, 589, 13, 619, 407, 410, 619, 410, 139, 34,
111244 /* 1330 */ 404, 388, 3, 148, 623, 313, 414, 620, 312, 331,
111245 /* 1340 */ 413, 461, 413, 402, 180, 354, 413, 407, 599, 79,
111246 /* 1350 */ 599, 78, 250, 564, 599, 9, 619, 613, 612, 611,
111247 /* 1360 */ 619, 8, 453, 443, 242, 416, 402, 619, 239, 235,
111248 /* 1370 */ 179, 238, 429, 41, 42, 289, 564, 619, 619, 619,
111249 /* 1380 */ 43, 412, 411, 619, 144, 593, 619, 619, 177, 61,
111250 /* 1390 */ 619, 597, 392, 621, 620, 288, 41, 42, 415, 619,
111251 /* 1400 */ 294, 30, 394, 43, 412, 411, 293, 619, 593, 31,
111252 /* 1410 */ 619, 396, 292, 60, 230, 37, 591, 591, 591, 590,
111253 /* 1420 */ 589, 13, 214, 554, 183, 291, 172, 302, 301, 300,
111254 /* 1430 */ 178, 298, 596, 564, 452, 29, 286, 391, 541, 591,
111255 /* 1440 */ 591, 591, 590, 589, 13, 284, 521, 535, 150, 534,
111256 /* 1450 */ 241, 282, 385, 192, 191, 325, 516, 515, 277, 240,
111257 /* 1460 */ 511, 524, 308, 512, 128, 593, 510, 225, 226, 487,
111258 /* 1470 */ 486, 224, 152, 492, 465, 307, 485, 163, 153, 372,
111259 /* 1480 */ 479, 151, 162, 259, 370, 161, 368, 208, 476, 477,
111260 /* 1490 */ 26, 160, 469, 466, 362, 140, 591, 591, 591, 116,
111261 /* 1500 */ 119, 455, 344, 155, 114, 343, 113, 112, 446, 111,
111262 /* 1510 */ 131, 109, 432, 317, 130, 431, 23, 20, 430, 427,
111263 /* 1520 */ 190, 63, 255, 342, 244, 607, 295, 287, 311, 594,
111264 /* 1530 */ 278, 508, 496, 235, 493, 571, 497, 568, 495, 403,
111265 /* 1540 */ 459, 379, 355, 245, 193, 303, 567, 296, 341, 5,
111266 /* 1550 */ 445, 548, 506, 207, 525, 500, 335, 489, 252, 369,
111267 /* 1560 */ 400, 499, 523, 233,
111268 };
111269 static const YYCODETYPE yy_lookahead[] = {
111270 /* 0 */ 19, 142, 143, 144, 145, 24, 1, 26, 77, 78,
111271 /* 10 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
111272 /* 20 */ 89, 90, 91, 92, 26, 27, 15, 26, 27, 197,
@@ -111213,21 +111414,21 @@
111414 /* 1440 */ 130, 131, 132, 133, 134, 210, 175, 211, 31, 211,
111415 /* 1450 */ 33, 210, 104, 86, 87, 47, 175, 183, 175, 42,
111416 /* 1460 */ 103, 94, 178, 177, 22, 98, 175, 92, 228, 175,
111417 /* 1470 */ 175, 228, 55, 183, 57, 178, 175, 156, 61, 18,
111418 /* 1480 */ 157, 64, 156, 235, 157, 156, 45, 157, 236, 157,
111419 /* 1490 */ 135, 156, 199, 189, 157, 68, 129, 130, 131, 22,
111420 /* 1500 */ 189, 199, 157, 156, 192, 18, 192, 192, 199, 192,
111421 /* 1510 */ 218, 189, 40, 157, 218, 157, 240, 240, 157, 38,
111422 /* 1520 */ 196, 243, 105, 106, 107, 153, 198, 209, 111, 166,
111423 /* 1530 */ 176, 181, 166, 116, 166, 230, 176, 230, 176, 226,
111424 /* 1540 */ 199, 177, 239, 209, 185, 148, 166, 195, 209, 196,
111425 /* 1550 */ 199, 208, 182, 233, 173, 182, 139, 186, 239, 234,
111426 /* 1560 */ 191, 182, 173, 92,
111427 };
111428 #define YY_SHIFT_USE_DFLT (-70)
111429 #define YY_SHIFT_COUNT (417)
111430 #define YY_SHIFT_MIN (-69)
111431 #define YY_SHIFT_MAX (1487)
111432 static const short yy_shift_ofst[] = {
111433 /* 0 */ 1143, 1188, 1417, 1188, 1287, 1287, 138, 138, -2, -19,
111434 /* 10 */ 1287, 1287, 1287, 1287, 347, 362, 129, 129, 795, 1165,
@@ -111240,44 +111441,44 @@
111441 /* 80 */ 869, 869, 869, 869, 869, 869, 869, 869, 869, 869,
111442 /* 90 */ 869, 869, 869, 943, 869, 1017, 1091, 1091, -69, -45,
111443 /* 100 */ -45, -45, -45, -45, -1, 24, 245, 362, 362, 362,
111444 /* 110 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111445 /* 120 */ 362, 362, 362, 388, 356, 362, 362, 362, 362, 362,
111446 /* 130 */ 732, 868, 231, 1051, 1471, -70, -70, -70, 1367, 57,
111447 /* 140 */ 434, 434, 289, 291, 285, 1, 204, 572, 539, 362,
111448 /* 150 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111449 /* 160 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111450 /* 170 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111451 /* 180 */ 362, 506, 506, 506, 705, 1253, 1253, 1253, -70, -70,
111452 /* 190 */ -70, 171, 171, 160, 502, 502, 502, 446, 432, 511,
111453 /* 200 */ 422, 358, 335, -12, -12, -12, -12, 576, 294, -12,
111454 /* 210 */ -12, 295, 595, 141, 600, 730, 723, 723, 805, 730,
111455 /* 220 */ 805, 439, 911, 231, 865, 231, 865, 807, 865, 723,
111456 /* 230 */ 766, 633, 633, 231, 284, 63, 608, 1481, 1308, 1308,
111457 /* 240 */ 1472, 1472, 1308, 1477, 1427, 1275, 1487, 1487, 1487, 1487,
111458 /* 250 */ 1308, 1461, 1275, 1477, 1427, 1427, 1275, 1308, 1461, 1355,
111459 /* 260 */ 1441, 1308, 1308, 1461, 1308, 1461, 1308, 1461, 1442, 1348,
111460 /* 270 */ 1348, 1348, 1408, 1375, 1375, 1442, 1348, 1357, 1348, 1408,
111461 /* 280 */ 1348, 1348, 1316, 1331, 1316, 1331, 1316, 1331, 1308, 1308,
111462 /* 290 */ 1280, 1288, 1289, 1285, 1279, 1275, 1253, 1336, 1346, 1346,
111463 /* 300 */ 1338, 1338, 1338, 1338, -70, -70, -70, -70, -70, -70,
111464 /* 310 */ 1013, 467, 612, 84, 179, -28, 870, 410, 761, 760,
111465 /* 320 */ 667, 650, 531, 220, 361, 331, 125, 127, 97, 1306,
111466 /* 330 */ 1300, 1270, 1151, 1272, 1203, 1232, 1261, 1244, 1148, 1174,
111467 /* 340 */ 1139, 1156, 1124, 1220, 1115, 1210, 1233, 1099, 1193, 1184,
111468 /* 350 */ 1174, 1173, 1029, 1121, 1120, 1085, 1162, 1119, 1037, 1152,
111469 /* 360 */ 1147, 1129, 1046, 1011, 1093, 1098, 1075, 1061, 1032, 960,
111470 /* 370 */ 1057, 1031, 1030, 899, 938, 982, 936, 972, 958, 910,
111471 /* 380 */ 955, 875, 885, 908, 857, 859, 867, 804, 590, 834,
111472 /* 390 */ 747, 818, 513, 611, 741, 673, 637, 611, 606, 603,
111473 /* 400 */ 579, 501, 541, 468, 386, 445, 395, 376, 281, 185,
111474 /* 410 */ 120, 92, 75, 45, 114, 25, 11, 5,
111475 };
111476 #define YY_REDUCE_USE_DFLT (-169)
111477 #define YY_REDUCE_COUNT (309)
111478 #define YY_REDUCE_MIN (-168)
111479 #define YY_REDUCE_MAX (1397)
111480 static const short yy_reduce_ofst[] = {
111481 /* 0 */ -141, 90, 1095, 222, 158, 156, 19, 17, 10, -104,
111482 /* 10 */ 378, 316, 311, 12, 180, 249, 598, 464, 397, 1181,
111483 /* 20 */ 1177, 1175, 1128, 1106, 1096, 1054, 1038, 974, 964, 962,
111484 /* 30 */ 948, 905, 903, 900, 887, 874, 832, 826, 816, 813,
@@ -111294,87 +111495,87 @@
111495 /* 140 */ 935, 892, 968, 1245, 1242, 1234, 1225, 798, 798, 1222,
111496 /* 150 */ 1221, 1218, 1214, 1213, 1212, 1202, 1195, 1191, 1161, 1158,
111497 /* 160 */ 1140, 1135, 1123, 1112, 1107, 1100, 1080, 1074, 1073, 1072,
111498 /* 170 */ 1070, 1067, 1048, 1044, 969, 968, 907, 906, 904, 894,
111499 /* 180 */ 833, 837, 836, 340, 827, 815, 775, 68, 722, 646,
111500 /* 190 */ -168, 1389, 1381, 1371, 1379, 1373, 1370, 1343, 1352, 1369,
111501 /* 200 */ 1352, 1352, 1352, 1352, 1352, 1352, 1352, 1325, 1320, 1352,
111502 /* 210 */ 1352, 1343, 1380, 1353, 1397, 1351, 1339, 1334, 1319, 1341,
111503 /* 220 */ 1303, 1364, 1359, 1368, 1362, 1366, 1360, 1350, 1354, 1318,
111504 /* 230 */ 1313, 1307, 1305, 1363, 1328, 1324, 1372, 1278, 1361, 1358,
111505 /* 240 */ 1277, 1276, 1356, 1296, 1322, 1309, 1317, 1315, 1314, 1312,
111506 /* 250 */ 1345, 1347, 1302, 1292, 1311, 1304, 1293, 1337, 1335, 1252,
111507 /* 260 */ 1248, 1332, 1330, 1329, 1327, 1326, 1323, 1321, 1297, 1301,
111508 /* 270 */ 1295, 1294, 1290, 1243, 1240, 1284, 1291, 1286, 1283, 1274,
111509 /* 280 */ 1281, 1271, 1238, 1241, 1236, 1235, 1227, 1226, 1267, 1266,
111510 /* 290 */ 1189, 1229, 1223, 1211, 1206, 1201, 1197, 1239, 1237, 1219,
111511 /* 300 */ 1216, 1209, 1208, 1185, 1089, 1086, 1087, 1137, 1136, 1164,
111512 };
111513 static const YYACTIONTYPE yy_default[] = {
111514 /* 0 */ 633, 867, 955, 955, 867, 867, 955, 955, 955, 757,
111515 /* 10 */ 955, 955, 955, 865, 955, 955, 785, 785, 929, 955,
111516 /* 20 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111517 /* 30 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111518 /* 40 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111519 /* 50 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111520 /* 60 */ 955, 955, 955, 955, 955, 955, 955, 672, 761, 791,
111521 /* 70 */ 955, 955, 955, 955, 955, 955, 955, 955, 928, 930,
111522 /* 80 */ 799, 798, 908, 772, 796, 789, 793, 868, 861, 862,
111523 /* 90 */ 860, 864, 869, 955, 792, 828, 845, 827, 839, 844,
111524 /* 100 */ 851, 843, 840, 830, 829, 831, 832, 955, 955, 955,
111525 /* 110 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111526 /* 120 */ 955, 955, 955, 659, 726, 955, 955, 955, 955, 955,
111527 /* 130 */ 955, 955, 955, 833, 834, 848, 847, 846, 955, 664,
111528 /* 140 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111529 /* 150 */ 935, 933, 955, 880, 955, 955, 955, 955, 955, 955,
111530 /* 160 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111531 /* 170 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111532 /* 180 */ 639, 757, 757, 757, 633, 955, 955, 955, 947, 761,
111533 /* 190 */ 751, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111534 /* 200 */ 955, 955, 955, 801, 740, 918, 920, 955, 901, 738,
111535 /* 210 */ 661, 759, 674, 749, 641, 795, 774, 774, 913, 795,
111536 /* 220 */ 913, 697, 720, 955, 785, 955, 785, 694, 785, 774,
111537 /* 230 */ 863, 955, 955, 955, 758, 749, 955, 940, 765, 765,
111538 /* 240 */ 932, 932, 765, 807, 730, 795, 737, 737, 737, 737,
111539 /* 250 */ 765, 656, 795, 807, 730, 730, 795, 765, 656, 907,
111540 /* 260 */ 905, 765, 765, 656, 765, 656, 765, 656, 873, 728,
111541 /* 270 */ 728, 728, 712, 877, 877, 873, 728, 697, 728, 712,
111542 /* 280 */ 728, 728, 778, 773, 778, 773, 778, 773, 765, 765,
111543 /* 290 */ 955, 790, 779, 788, 786, 795, 955, 715, 649, 649,
111544 /* 300 */ 638, 638, 638, 638, 952, 952, 947, 699, 699, 682,
111545 /* 310 */ 955, 955, 955, 955, 955, 955, 955, 882, 955, 955,
111546 /* 320 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111547 /* 330 */ 634, 942, 955, 955, 939, 955, 955, 955, 955, 800,
111548 /* 340 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111549 /* 350 */ 917, 955, 955, 955, 955, 955, 955, 955, 911, 955,
111550 /* 360 */ 955, 955, 955, 955, 955, 904, 903, 955, 955, 955,
111551 /* 370 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111552 /* 380 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111553 /* 390 */ 955, 955, 955, 787, 955, 780, 955, 866, 955, 955,
111554 /* 400 */ 955, 955, 955, 955, 955, 955, 955, 955, 743, 816,
111555 /* 410 */ 955, 815, 819, 814, 666, 955, 647, 955, 630, 635,
111556 /* 420 */ 951, 954, 953, 950, 949, 948, 943, 941, 938, 937,
111557 /* 430 */ 936, 934, 931, 927, 886, 884, 891, 890, 889, 888,
111558 /* 440 */ 887, 885, 883, 881, 802, 797, 794, 926, 879, 739,
111559 /* 450 */ 736, 735, 655, 944, 910, 919, 806, 805, 808, 916,
111560 /* 460 */ 915, 914, 912, 909, 896, 804, 803, 731, 871, 870,
111561 /* 470 */ 658, 900, 899, 898, 902, 906, 897, 767, 657, 654,
111562 /* 480 */ 663, 718, 719, 727, 725, 724, 723, 722, 721, 717,
111563 /* 490 */ 665, 673, 711, 696, 695, 876, 878, 875, 874, 704,
111564 /* 500 */ 703, 709, 708, 707, 706, 705, 702, 701, 700, 693,
111565 /* 510 */ 692, 698, 691, 714, 713, 710, 690, 734, 733, 732,
111566 /* 520 */ 729, 689, 688, 687, 819, 686, 685, 825, 824, 812,
111567 /* 530 */ 855, 754, 753, 752, 764, 763, 776, 775, 810, 809,
111568 /* 540 */ 777, 762, 756, 755, 771, 770, 769, 768, 760, 750,
111569 /* 550 */ 782, 784, 783, 781, 857, 766, 854, 925, 924, 923,
111570 /* 560 */ 922, 921, 859, 858, 826, 823, 677, 678, 894, 893,
111571 /* 570 */ 895, 892, 680, 679, 676, 675, 856, 745, 744, 852,
111572 /* 580 */ 849, 841, 837, 853, 850, 842, 838, 836, 835, 821,
111573 /* 590 */ 820, 818, 817, 813, 822, 668, 746, 742, 741, 811,
111574 /* 600 */ 748, 747, 684, 683, 681, 662, 660, 653, 651, 650,
111575 /* 610 */ 652, 648, 646, 645, 644, 643, 642, 671, 670, 669,
111576 /* 620 */ 667, 666, 640, 637, 636, 632, 631, 629,
111577 };
111578
111579 /* The next table maps tokens into fallback tokens. If a construct
111580 ** like the following:
111581 **
@@ -111842,11 +112043,11 @@
112043 /* 237 */ "case_operand ::=",
112044 /* 238 */ "exprlist ::= nexprlist",
112045 /* 239 */ "exprlist ::=",
112046 /* 240 */ "nexprlist ::= nexprlist COMMA expr",
112047 /* 241 */ "nexprlist ::= expr",
112048 /* 242 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt",
112049 /* 243 */ "uniqueflag ::= UNIQUE",
112050 /* 244 */ "uniqueflag ::=",
112051 /* 245 */ "idxlist_opt ::=",
112052 /* 246 */ "idxlist_opt ::= LP idxlist RP",
112053 /* 247 */ "idxlist ::= idxlist COMMA nm collate sortorder",
@@ -112561,11 +112762,11 @@
112762 { 224, 0 },
112763 { 220, 1 },
112764 { 220, 0 },
112765 { 215, 3 },
112766 { 215, 1 },
112767 { 147, 12 },
112768 { 227, 1 },
112769 { 227, 0 },
112770 { 178, 0 },
112771 { 178, 3 },
112772 { 187, 5 },
@@ -113565,15 +113766,15 @@
113766 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);}
113767 break;
113768 case 241: /* nexprlist ::= expr */
113769 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr);}
113770 break;
113771 case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt */
113772 {
113773 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
113774 sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy442, yymsp[-10].minor.yy392,
113775 &yymsp[-11].minor.yy0, yymsp[0].minor.yy122, SQLITE_SO_ASC, yymsp[-8].minor.yy392);
113776 }
113777 break;
113778 case 243: /* uniqueflag ::= UNIQUE */
113779 case 296: /* raisetype ::= ABORT */ yytestcase(yyruleno==296);
113780 {yygotominor.yy392 = OE_Abort;}
@@ -114495,11 +114696,10 @@
114696 *tokenType = TK_SPACE;
114697 return i;
114698 }
114699 case '-': {
114700 if( z[1]=='-' ){
 
114701 for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
114702 *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
114703 return i;
114704 }
114705 *tokenType = TK_MINUS;
@@ -114528,11 +114728,10 @@
114728 case '/': {
114729 if( z[1]!='*' || z[2]==0 ){
114730 *tokenType = TK_SLASH;
114731 return 1;
114732 }
 
114733 for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}
114734 if( c ) i++;
114735 *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
114736 return i;
114737 }
@@ -116373,10 +116572,11 @@
116572 case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break;
116573 case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
116574 case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
116575 case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
116576 case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
116577 case SQLITE_IOERR_GETTEMPPATH: zName = "SQLITE_IOERR_GETTEMPPATH"; break;
116578 case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
116579 case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
116580 case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
116581 case SQLITE_FULL: zName = "SQLITE_FULL"; break;
116582 case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
@@ -117728,11 +117928,11 @@
117928 db->autoCommit = 1;
117929 db->nextAutovac = -1;
117930 db->szMmap = sqlite3GlobalConfig.szMmap;
117931 db->nextPagesize = 0;
117932 db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger
117933 #if !defined(SQLITE_DEFAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
117934 | SQLITE_AutoIndex
117935 #endif
117936 #if SQLITE_DEFAULT_FILE_FORMAT<4
117937 | SQLITE_LegacyFileFmt
117938 #endif
@@ -128201,11 +128401,11 @@
128401 }
128402
128403
128404 #ifdef SQLITE_TEST
128405
128406 #include <tcl.h>
128407 /* #include <string.h> */
128408
128409 /*
128410 ** Implementation of a special SQL scalar function for testing tokenizers
128411 ** designed to be used in concert with the Tcl testing framework. This
128412
+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-05 12:31:41 4b8b426f10f8ae13bf553f7adf5ae09383fa0bd4"
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-05 12:31:41 4b8b426f10f8ae13bf553f7adf5ae09383fa0bd4"
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
@@ -99,10 +99,16 @@
9999
if( find_option("private",0,0)!=0 ){
100100
*pSyncFlags |= SYNC_PRIVATE;
101101
}
102102
if( find_option("verbose","v",0)!=0 ){
103103
*pSyncFlags |= SYNC_VERBOSE;
104
+ }
105
+ /* The --verily option to sync, push, and pull forces extra igot cards
106
+ ** to be exchanged. This can overcome malfunctions in the sync protocol.
107
+ */
108
+ if( find_option("verily",0,0)!=0 ){
109
+ *pSyncFlags |= SYNC_RESYNC;
104110
}
105111
url_proxy_options();
106112
clone_ssh_find_options();
107113
db_find_and_open_repository(0, 0);
108114
db_open_config(0);
109115
--- src/sync.c
+++ src/sync.c
@@ -99,10 +99,16 @@
99 if( find_option("private",0,0)!=0 ){
100 *pSyncFlags |= SYNC_PRIVATE;
101 }
102 if( find_option("verbose","v",0)!=0 ){
103 *pSyncFlags |= SYNC_VERBOSE;
 
 
 
 
 
 
104 }
105 url_proxy_options();
106 clone_ssh_find_options();
107 db_find_and_open_repository(0, 0);
108 db_open_config(0);
109
--- src/sync.c
+++ src/sync.c
@@ -99,10 +99,16 @@
99 if( find_option("private",0,0)!=0 ){
100 *pSyncFlags |= SYNC_PRIVATE;
101 }
102 if( find_option("verbose","v",0)!=0 ){
103 *pSyncFlags |= SYNC_VERBOSE;
104 }
105 /* The --verily option to sync, push, and pull forces extra igot cards
106 ** to be exchanged. This can overcome malfunctions in the sync protocol.
107 */
108 if( find_option("verily",0,0)!=0 ){
109 *pSyncFlags |= SYNC_RESYNC;
110 }
111 url_proxy_options();
112 clone_ssh_find_options();
113 db_find_and_open_repository(0, 0);
114 db_open_config(0);
115
+6
--- src/sync.c
+++ src/sync.c
@@ -99,10 +99,16 @@
9999
if( find_option("private",0,0)!=0 ){
100100
*pSyncFlags |= SYNC_PRIVATE;
101101
}
102102
if( find_option("verbose","v",0)!=0 ){
103103
*pSyncFlags |= SYNC_VERBOSE;
104
+ }
105
+ /* The --verily option to sync, push, and pull forces extra igot cards
106
+ ** to be exchanged. This can overcome malfunctions in the sync protocol.
107
+ */
108
+ if( find_option("verily",0,0)!=0 ){
109
+ *pSyncFlags |= SYNC_RESYNC;
104110
}
105111
url_proxy_options();
106112
clone_ssh_find_options();
107113
db_find_and_open_repository(0, 0);
108114
db_open_config(0);
109115
--- src/sync.c
+++ src/sync.c
@@ -99,10 +99,16 @@
99 if( find_option("private",0,0)!=0 ){
100 *pSyncFlags |= SYNC_PRIVATE;
101 }
102 if( find_option("verbose","v",0)!=0 ){
103 *pSyncFlags |= SYNC_VERBOSE;
 
 
 
 
 
 
104 }
105 url_proxy_options();
106 clone_ssh_find_options();
107 db_find_and_open_repository(0, 0);
108 db_open_config(0);
109
--- src/sync.c
+++ src/sync.c
@@ -99,10 +99,16 @@
99 if( find_option("private",0,0)!=0 ){
100 *pSyncFlags |= SYNC_PRIVATE;
101 }
102 if( find_option("verbose","v",0)!=0 ){
103 *pSyncFlags |= SYNC_VERBOSE;
104 }
105 /* The --verily option to sync, push, and pull forces extra igot cards
106 ** to be exchanged. This can overcome malfunctions in the sync protocol.
107 */
108 if( find_option("verily",0,0)!=0 ){
109 *pSyncFlags |= SYNC_RESYNC;
110 }
111 url_proxy_options();
112 clone_ssh_find_options();
113 db_find_and_open_repository(0, 0);
114 db_open_config(0);
115
+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
+13 -5
--- 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 */
@@ -2201,11 +2209,11 @@
22012209
output_table_sorting_javascript("statsTable","tnx");
22022210
}
22032211
}
22042212
22052213
/*
2206
-** WEBPAGE: stats_report
2214
+** WEBPAGE: reports
22072215
**
22082216
** Shows activity reports for the repository.
22092217
**
22102218
** Query Parameters:
22112219
**
22122220
--- 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 */
@@ -2201,11 +2209,11 @@
2201 output_table_sorting_javascript("statsTable","tnx");
2202 }
2203 }
2204
2205 /*
2206 ** WEBPAGE: stats_report
2207 **
2208 ** Shows activity reports for the repository.
2209 **
2210 ** Query Parameters:
2211 **
2212
--- 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 */
@@ -2201,11 +2209,11 @@
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:
2219 **
2220
+2 -2
--- src/vfile.c
+++ src/vfile.c
@@ -213,11 +213,11 @@
213213
blob_zero(&fileCksum);
214214
}
215215
if( blob_compare(&fileCksum, &origCksum)==0 ) chnged = 0;
216216
blob_reset(&origCksum);
217217
blob_reset(&fileCksum);
218
- }else if( (chnged==0 || chnged==2)
218
+ }else if( (chnged==0 || chnged==2 || chnged==4)
219219
&& (useMtime==0 || currentMtime!=oldMtime) ){
220220
/* For files that were formerly believed to be unchanged or that were
221221
** changed by merging, if their mtime changes, or unconditionally
222222
** if --sha1sum is used, check to see if they have been edited by
223223
** looking at their SHA1 sum */
@@ -230,11 +230,11 @@
230230
chnged = 1;
231231
}
232232
blob_reset(&origCksum);
233233
blob_reset(&fileCksum);
234234
}
235
- if( (cksigFlags & CKSIG_SETMTIME) && (chnged==0 || chnged==2) ){
235
+ if( (cksigFlags & CKSIG_SETMTIME) && (chnged==0 || chnged==2 || chnged==4) ){
236236
i64 desiredMtime;
237237
if( mtime_of_manifest_file(vid,rid,&desiredMtime)==0 ){
238238
if( currentMtime!=desiredMtime ){
239239
file_set_mtime(zName, desiredMtime);
240240
currentMtime = file_wd_mtime(zName);
241241
--- src/vfile.c
+++ src/vfile.c
@@ -213,11 +213,11 @@
213 blob_zero(&fileCksum);
214 }
215 if( blob_compare(&fileCksum, &origCksum)==0 ) chnged = 0;
216 blob_reset(&origCksum);
217 blob_reset(&fileCksum);
218 }else if( (chnged==0 || chnged==2)
219 && (useMtime==0 || currentMtime!=oldMtime) ){
220 /* For files that were formerly believed to be unchanged or that were
221 ** changed by merging, if their mtime changes, or unconditionally
222 ** if --sha1sum is used, check to see if they have been edited by
223 ** looking at their SHA1 sum */
@@ -230,11 +230,11 @@
230 chnged = 1;
231 }
232 blob_reset(&origCksum);
233 blob_reset(&fileCksum);
234 }
235 if( (cksigFlags & CKSIG_SETMTIME) && (chnged==0 || chnged==2) ){
236 i64 desiredMtime;
237 if( mtime_of_manifest_file(vid,rid,&desiredMtime)==0 ){
238 if( currentMtime!=desiredMtime ){
239 file_set_mtime(zName, desiredMtime);
240 currentMtime = file_wd_mtime(zName);
241
--- src/vfile.c
+++ src/vfile.c
@@ -213,11 +213,11 @@
213 blob_zero(&fileCksum);
214 }
215 if( blob_compare(&fileCksum, &origCksum)==0 ) chnged = 0;
216 blob_reset(&origCksum);
217 blob_reset(&fileCksum);
218 }else if( (chnged==0 || chnged==2 || chnged==4)
219 && (useMtime==0 || currentMtime!=oldMtime) ){
220 /* For files that were formerly believed to be unchanged or that were
221 ** changed by merging, if their mtime changes, or unconditionally
222 ** if --sha1sum is used, check to see if they have been edited by
223 ** looking at their SHA1 sum */
@@ -230,11 +230,11 @@
230 chnged = 1;
231 }
232 blob_reset(&origCksum);
233 blob_reset(&fileCksum);
234 }
235 if( (cksigFlags & CKSIG_SETMTIME) && (chnged==0 || chnged==2 || chnged==4) ){
236 i64 desiredMtime;
237 if( mtime_of_manifest_file(vid,rid,&desiredMtime)==0 ){
238 if( currentMtime!=desiredMtime ){
239 file_set_mtime(zName, desiredMtime);
240 currentMtime = file_wd_mtime(zName);
241
+7 -1
--- src/wiki.c
+++ src/wiki.c
@@ -178,14 +178,20 @@
178178
if( !g.perm.RdWiki ){ login_needed(); return; }
179179
zPageName = P("name");
180180
if( zPageName==0 ){
181181
style_header("Wiki");
182182
@ <ul>
183
+ { char *zWikiHomePageName = db_get("index-page",0);
184
+ if( zWikiHomePageName ){
185
+ @ <li> %z(href("%R%s",zWikiHomePageName))
186
+ @ %h(zWikiHomePageName)</a> wiki home page.</li>
187
+ }
188
+ }
183189
{ char *zHomePageName = db_get("project-name",0);
184190
if( zHomePageName ){
185191
@ <li> %z(href("%R/wiki?name=%t",zHomePageName))
186
- @ %h(zHomePageName)</a> wiki home page.</li>
192
+ @ %h(zHomePageName)</a> project home page.</li>
187193
}
188194
}
189195
@ <li> %z(href("%R/timeline?y=w"))Recent changes</a> to wiki pages.</li>
190196
@ <li> %z(href("%R/wiki_rules"))Formatting rules</a> for wiki.</li>
191197
@ <li> Use the %z(href("%R/wiki?name=Sandbox"))Sandbox</a>
192198
--- src/wiki.c
+++ src/wiki.c
@@ -178,14 +178,20 @@
178 if( !g.perm.RdWiki ){ login_needed(); return; }
179 zPageName = P("name");
180 if( zPageName==0 ){
181 style_header("Wiki");
182 @ <ul>
 
 
 
 
 
 
183 { char *zHomePageName = db_get("project-name",0);
184 if( zHomePageName ){
185 @ <li> %z(href("%R/wiki?name=%t",zHomePageName))
186 @ %h(zHomePageName)</a> wiki home page.</li>
187 }
188 }
189 @ <li> %z(href("%R/timeline?y=w"))Recent changes</a> to wiki pages.</li>
190 @ <li> %z(href("%R/wiki_rules"))Formatting rules</a> for wiki.</li>
191 @ <li> Use the %z(href("%R/wiki?name=Sandbox"))Sandbox</a>
192
--- src/wiki.c
+++ src/wiki.c
@@ -178,14 +178,20 @@
178 if( !g.perm.RdWiki ){ login_needed(); return; }
179 zPageName = P("name");
180 if( zPageName==0 ){
181 style_header("Wiki");
182 @ <ul>
183 { char *zWikiHomePageName = db_get("index-page",0);
184 if( zWikiHomePageName ){
185 @ <li> %z(href("%R%s",zWikiHomePageName))
186 @ %h(zWikiHomePageName)</a> wiki home page.</li>
187 }
188 }
189 { char *zHomePageName = db_get("project-name",0);
190 if( zHomePageName ){
191 @ <li> %z(href("%R/wiki?name=%t",zHomePageName))
192 @ %h(zHomePageName)</a> project home page.</li>
193 }
194 }
195 @ <li> %z(href("%R/timeline?y=w"))Recent changes</a> to wiki pages.</li>
196 @ <li> %z(href("%R/wiki_rules"))Formatting rules</a> for wiki.</li>
197 @ <li> Use the %z(href("%R/wiki?name=Sandbox"))Sandbox</a>
198
+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
if( syncFlags & SYNC_VERBOSE ){
13931423
fossil_print(zLabelFormat, "", "Bytes", "Cards", "Artifacts", "Deltas");
13941424
}
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 if( syncFlags & SYNC_VERBOSE ){
1393 fossil_print(zLabelFormat, "", "Bytes", "Cards", "Artifacts", "Deltas");
1394 }
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 if( syncFlags & SYNC_VERBOSE ){
1423 fossil_print(zLabelFormat, "", "Bytes", "Cards", "Artifacts", "Deltas");
1424 }
1425
+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
if( syncFlags & SYNC_VERBOSE ){
13931423
fossil_print(zLabelFormat, "", "Bytes", "Cards", "Artifacts", "Deltas");
13941424
}
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 if( syncFlags & SYNC_VERBOSE ){
1393 fossil_print(zLabelFormat, "", "Bytes", "Cards", "Artifacts", "Deltas");
1394 }
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 if( syncFlags & SYNC_VERBOSE ){
1423 fossil_print(zLabelFormat, "", "Bytes", "Cards", "Artifacts", "Deltas");
1424 }
1425
--- www/adding_code.wiki
+++ www/adding_code.wiki
@@ -153,11 +153,11 @@
153153
the output text, if desired. But "fossil_print()" is recommended as
154154
it has extra logic to insert \r characters at the right times on
155155
windows systems.
156156
157157
Once you have the command running, you can then start adding code to
158
-make it do useful things. There are logs of utility functions in
158
+make it do useful things. There are lots of utility functions in
159159
Fossil for parsing command-line options and for
160160
opening and accessing and manipulating the repository and
161161
the working check-out. Study at the implementations of existing commands
162162
to get an idea of how things are done. You can easily find the implementations
163163
of existing commands by searching for "COMMAND: <i>name</i>" in the
164164
--- www/adding_code.wiki
+++ www/adding_code.wiki
@@ -153,11 +153,11 @@
153 the output text, if desired. But "fossil_print()" is recommended as
154 it has extra logic to insert \r characters at the right times on
155 windows systems.
156
157 Once you have the command running, you can then start adding code to
158 make it do useful things. There are logs of utility functions in
159 Fossil for parsing command-line options and for
160 opening and accessing and manipulating the repository and
161 the working check-out. Study at the implementations of existing commands
162 to get an idea of how things are done. You can easily find the implementations
163 of existing commands by searching for "COMMAND: <i>name</i>" in the
164
--- www/adding_code.wiki
+++ www/adding_code.wiki
@@ -153,11 +153,11 @@
153 the output text, if desired. But "fossil_print()" is recommended as
154 it has extra logic to insert \r characters at the right times on
155 windows systems.
156
157 Once you have the command running, you can then start adding code to
158 make it do useful things. There are lots of utility functions in
159 Fossil for parsing command-line options and for
160 opening and accessing and manipulating the repository and
161 the working check-out. Study at the implementations of existing commands
162 to get an idea of how things are done. You can easily find the implementations
163 of existing commands by searching for "COMMAND: <i>name</i>" in the
164
--- www/changes.wiki
+++ www/changes.wiki
@@ -3,10 +3,16 @@
33
<h2>Changes For Version 1.27 (as yet unreleased)</h2>
44
* Enhance the [/help?cmd=changes | fossil changes],
55
[/help?cmd=clean | fossil clean], [/help?cmd=extras | fossil extras],
66
[/help?cmd=ls | fossil ls] and [/help?cmd=status | fossil status] commands
77
to restrict operation to files and directories named on the command-line.
8
+ * New --integrate option to [/help?cmd=merge | fossil merge], which
9
+ automatically closes the merged branch when committing.
10
+ * Renamed <tt>/stats_report</tt> page to [/reports]. Graph width is now
11
+ relative, not absolute.
12
+ * Added <tt>yw=YYYY-WW</tt> (year-week) filter to timeline to limit the results
13
+ to a specific year and calendar week number, e.g. [/timeline?yw=2013-01].
814
915
<h2>Changes For Version 1.26 (2013-06-18)</h2>
1016
* The argument to the --port option for the [/help?cmd=ui | fossil ui] and
1117
[/help?cmd=server | fossil server] commands can take an IP address in addition
1218
to the port number, causing Fossil to bind to just that one IP address.
1319
--- www/changes.wiki
+++ www/changes.wiki
@@ -3,10 +3,16 @@
3 <h2>Changes For Version 1.27 (as yet unreleased)</h2>
4 * Enhance the [/help?cmd=changes | fossil changes],
5 [/help?cmd=clean | fossil clean], [/help?cmd=extras | fossil extras],
6 [/help?cmd=ls | fossil ls] and [/help?cmd=status | fossil status] commands
7 to restrict operation to files and directories named on the command-line.
 
 
 
 
 
 
8
9 <h2>Changes For Version 1.26 (2013-06-18)</h2>
10 * The argument to the --port option for the [/help?cmd=ui | fossil ui] and
11 [/help?cmd=server | fossil server] commands can take an IP address in addition
12 to the port number, causing Fossil to bind to just that one IP address.
13
--- www/changes.wiki
+++ www/changes.wiki
@@ -3,10 +3,16 @@
3 <h2>Changes For Version 1.27 (as yet unreleased)</h2>
4 * Enhance the [/help?cmd=changes | fossil changes],
5 [/help?cmd=clean | fossil clean], [/help?cmd=extras | fossil extras],
6 [/help?cmd=ls | fossil ls] and [/help?cmd=status | fossil status] commands
7 to restrict operation to files and directories named on the command-line.
8 * New --integrate option to [/help?cmd=merge | fossil merge], which
9 automatically closes the merged branch when committing.
10 * Renamed <tt>/stats_report</tt> page to [/reports]. Graph width is now
11 relative, not absolute.
12 * Added <tt>yw=YYYY-WW</tt> (year-week) filter to timeline to limit the results
13 to a specific year and calendar week number, e.g. [/timeline?yw=2013-01].
14
15 <h2>Changes For Version 1.26 (2013-06-18)</h2>
16 * The argument to the --port option for the [/help?cmd=ui | fossil ui] and
17 [/help?cmd=server | fossil server] commands can take an IP address in addition
18 to the port number, causing Fossil to bind to just that one IP address.
19
--- 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