Fossil SCM

Update the built-in SQLite to the latest from upstream that includes the skip-scan optimization and the improved EXPLAIN display in the shell.

drh 2013-11-14 19:36 trunk
Commit 28c508679e0dfc5ff6a586876f54a961fbc63d04
+1 -1
--- src/main.mk
+++ src/main.mk
@@ -1160,11 +1160,11 @@
11601160
$(OBJDIR)/zip.o: $(OBJDIR)/zip_.c $(OBJDIR)/zip.h $(SRCDIR)/config.h
11611161
$(XTCC) -o $(OBJDIR)/zip.o -c $(OBJDIR)/zip_.c
11621162
11631163
$(OBJDIR)/zip.h: $(OBJDIR)/headers
11641164
$(OBJDIR)/sqlite3.o: $(SRCDIR)/sqlite3.c
1165
- $(XTCC) -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_STAT3 -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_WIN32_NO_ANSI -c $(SRCDIR)/sqlite3.c -o $(OBJDIR)/sqlite3.o
1165
+ $(XTCC) -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_WIN32_NO_ANSI -c $(SRCDIR)/sqlite3.c -o $(OBJDIR)/sqlite3.o
11661166
11671167
$(OBJDIR)/shell.o: $(SRCDIR)/shell.c $(SRCDIR)/sqlite3.h
11681168
$(XTCC) -Dmain=sqlite3_shell -DSQLITE_OMIT_LOAD_EXTENSION=1 -Dsqlite3_strglob=strglob -c $(SRCDIR)/shell.c -o $(OBJDIR)/shell.o
11691169
11701170
$(OBJDIR)/th.o: $(SRCDIR)/th.c
11711171
--- src/main.mk
+++ src/main.mk
@@ -1160,11 +1160,11 @@
1160 $(OBJDIR)/zip.o: $(OBJDIR)/zip_.c $(OBJDIR)/zip.h $(SRCDIR)/config.h
1161 $(XTCC) -o $(OBJDIR)/zip.o -c $(OBJDIR)/zip_.c
1162
1163 $(OBJDIR)/zip.h: $(OBJDIR)/headers
1164 $(OBJDIR)/sqlite3.o: $(SRCDIR)/sqlite3.c
1165 $(XTCC) -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_STAT3 -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_WIN32_NO_ANSI -c $(SRCDIR)/sqlite3.c -o $(OBJDIR)/sqlite3.o
1166
1167 $(OBJDIR)/shell.o: $(SRCDIR)/shell.c $(SRCDIR)/sqlite3.h
1168 $(XTCC) -Dmain=sqlite3_shell -DSQLITE_OMIT_LOAD_EXTENSION=1 -Dsqlite3_strglob=strglob -c $(SRCDIR)/shell.c -o $(OBJDIR)/shell.o
1169
1170 $(OBJDIR)/th.o: $(SRCDIR)/th.c
1171
--- src/main.mk
+++ src/main.mk
@@ -1160,11 +1160,11 @@
1160 $(OBJDIR)/zip.o: $(OBJDIR)/zip_.c $(OBJDIR)/zip.h $(SRCDIR)/config.h
1161 $(XTCC) -o $(OBJDIR)/zip.o -c $(OBJDIR)/zip_.c
1162
1163 $(OBJDIR)/zip.h: $(OBJDIR)/headers
1164 $(OBJDIR)/sqlite3.o: $(SRCDIR)/sqlite3.c
1165 $(XTCC) -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_WIN32_NO_ANSI -c $(SRCDIR)/sqlite3.c -o $(OBJDIR)/sqlite3.o
1166
1167 $(OBJDIR)/shell.o: $(SRCDIR)/shell.c $(SRCDIR)/sqlite3.h
1168 $(XTCC) -Dmain=sqlite3_shell -DSQLITE_OMIT_LOAD_EXTENSION=1 -Dsqlite3_strglob=strglob -c $(SRCDIR)/shell.c -o $(OBJDIR)/shell.o
1169
1170 $(OBJDIR)/th.o: $(SRCDIR)/th.c
1171
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -288,11 +288,13 @@
288288
289289
writeln "\$(OBJDIR)/sqlite3.o:\t\$(SRCDIR)/sqlite3.c"
290290
set opt {-DSQLITE_OMIT_LOAD_EXTENSION=1}
291291
append opt " -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4"
292292
#append opt " -DSQLITE_ENABLE_FTS3=1"
293
-append opt " -DSQLITE_ENABLE_STAT3"
293
+#append opt " -DSQLITE_ENABLE_STAT4"
294
+append opt " -DSQLITE_OMIT_DEPRECATED"
295
+append opt " -DSQLITE_ENABLE_EXPLAIN_COMMENTS"
294296
append opt " -Dlocaltime=fossil_localtime"
295297
append opt " -DSQLITE_ENABLE_LOCKING_STYLE=0"
296298
append opt " -DSQLITE_WIN32_NO_ANSI"
297299
set SQLITE_OPTIONS $opt
298300
writeln "\t\$(XTCC) $opt -c \$(SRCDIR)/sqlite3.c -o \$(OBJDIR)/sqlite3.o\n"
299301
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -288,11 +288,13 @@
288
289 writeln "\$(OBJDIR)/sqlite3.o:\t\$(SRCDIR)/sqlite3.c"
290 set opt {-DSQLITE_OMIT_LOAD_EXTENSION=1}
291 append opt " -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4"
292 #append opt " -DSQLITE_ENABLE_FTS3=1"
293 append opt " -DSQLITE_ENABLE_STAT3"
 
 
294 append opt " -Dlocaltime=fossil_localtime"
295 append opt " -DSQLITE_ENABLE_LOCKING_STYLE=0"
296 append opt " -DSQLITE_WIN32_NO_ANSI"
297 set SQLITE_OPTIONS $opt
298 writeln "\t\$(XTCC) $opt -c \$(SRCDIR)/sqlite3.c -o \$(OBJDIR)/sqlite3.o\n"
299
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -288,11 +288,13 @@
288
289 writeln "\$(OBJDIR)/sqlite3.o:\t\$(SRCDIR)/sqlite3.c"
290 set opt {-DSQLITE_OMIT_LOAD_EXTENSION=1}
291 append opt " -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4"
292 #append opt " -DSQLITE_ENABLE_FTS3=1"
293 #append opt " -DSQLITE_ENABLE_STAT4"
294 append opt " -DSQLITE_OMIT_DEPRECATED"
295 append opt " -DSQLITE_ENABLE_EXPLAIN_COMMENTS"
296 append opt " -Dlocaltime=fossil_localtime"
297 append opt " -DSQLITE_ENABLE_LOCKING_STYLE=0"
298 append opt " -DSQLITE_WIN32_NO_ANSI"
299 set SQLITE_OPTIONS $opt
300 writeln "\t\$(XTCC) $opt -c \$(SRCDIR)/sqlite3.c -o \$(OBJDIR)/sqlite3.o\n"
301
+101 -2
--- src/shell.c
+++ src/shell.c
@@ -462,10 +462,12 @@
462462
const char *zDbFilename; /* name of the database file */
463463
char *zFreeOnClose; /* Filename to free when closing */
464464
const char *zVfs; /* Name of VFS to use */
465465
sqlite3_stmt *pStmt; /* Current statement if any. */
466466
FILE *pLog; /* Write log output here */
467
+ int *aiIndent; /* Array of indents used in MODE_Explain */
468
+ int nIndent; /* Size of array aiIndent[] */
467469
};
468470
469471
/*
470472
** These are the allowed modes.
471473
*/
@@ -763,13 +765,18 @@
763765
if( i<ArraySize(p->actualWidth) ){
764766
w = p->actualWidth[i];
765767
}else{
766768
w = 10;
767769
}
768
- if( p->mode==MODE_Explain && azArg[i] &&
769
- strlen30(azArg[i])>w ){
770
+ if( p->mode==MODE_Explain && azArg[i] && strlen30(azArg[i])>w ){
770771
w = strlen30(azArg[i]);
772
+ }
773
+ if( i==1 && p->aiIndent && p->pStmt ){
774
+ int iOp = sqlite3_column_int(p->pStmt, 0);
775
+ if( iOp<p->nIndent ){
776
+ fprintf(p->out, "%*.s", p->aiIndent[iOp], "");
777
+ }
771778
}
772779
if( w<0 ){
773780
fprintf(p->out,"%*.*s%s",-w,-w,
774781
azArg[i] ? azArg[i] : p->nullvalue, i==nArg-1 ? "\n": " ");
775782
}else{
@@ -1138,10 +1145,94 @@
11381145
fprintf(pArg->out, "Virtual Machine Steps: %d\n", iCur);
11391146
}
11401147
11411148
return 0;
11421149
}
1150
+
1151
+/*
1152
+** Parameter azArray points to a zero-terminated array of strings. zStr
1153
+** points to a single nul-terminated string. Return non-zero if zStr
1154
+** is equal, according to strcmp(), to any of the strings in the array.
1155
+** Otherwise, return zero.
1156
+*/
1157
+static int str_in_array(const char *zStr, const char **azArray){
1158
+ int i;
1159
+ for(i=0; azArray[i]; i++){
1160
+ if( 0==strcmp(zStr, azArray[i]) ) return 1;
1161
+ }
1162
+ return 0;
1163
+}
1164
+
1165
+/*
1166
+** If compiled statement pSql appears to be an EXPLAIN statement, allocate
1167
+** and populate the callback_data.aiIndent[] array with the number of
1168
+** spaces each opcode should be indented before it is output.
1169
+**
1170
+** The indenting rules are:
1171
+**
1172
+** * For each "Next", "Prev", "VNext" or "VPrev" instruction, indent
1173
+** all opcodes that occur between the p2 jump destination and the opcode
1174
+** itself by 2 spaces.
1175
+**
1176
+** * For each "Goto", if the jump destination is a "Yield", "SeekGt",
1177
+** or "SeekLt" instruction that occurs earlier in the program than
1178
+** the Goto itself, indent all opcodes between the earlier instruction
1179
+** and "Goto" by 2 spaces.
1180
+*/
1181
+static void explain_data_prepare(struct callback_data *p, sqlite3_stmt *pSql){
1182
+ const char *zSql; /* The text of the SQL statement */
1183
+ const char *z; /* Used to check if this is an EXPLAIN */
1184
+ int *abYield = 0; /* True if op is an OP_Yield */
1185
+ int nAlloc = 0; /* Allocated size of p->aiIndent[], abYield */
1186
+ int iOp;
1187
+
1188
+ const char *azNext[] = { "Next", "Prev", "VPrev", "VNext", 0 };
1189
+ const char *azYield[] = { "Yield", "SeekLt", "SeekGt", 0 };
1190
+ const char *azGoto[] = { "Goto", 0 };
1191
+
1192
+ /* Try to figure out if this is really an EXPLAIN statement. If this
1193
+ ** cannot be verified, return early. */
1194
+ zSql = sqlite3_sql(pSql);
1195
+ if( zSql==0 ) return;
1196
+ for(z=zSql; *z==' ' || *z=='\t' || *z=='\n' || *z=='\f' || *z=='\r'; z++);
1197
+ if( sqlite3_strnicmp(z, "explain", 7) ) return;
1198
+
1199
+ for(iOp=0; SQLITE_ROW==sqlite3_step(pSql); iOp++){
1200
+ int i;
1201
+ const char *zOp = (const char*)sqlite3_column_text(pSql, 1);
1202
+ int p2 = sqlite3_column_int(pSql, 3);
1203
+
1204
+ /* Grow the p->aiIndent array as required */
1205
+ if( iOp>=nAlloc ){
1206
+ nAlloc += 100;
1207
+ p->aiIndent = (int*)sqlite3_realloc(p->aiIndent, nAlloc*sizeof(int));
1208
+ abYield = (int*)sqlite3_realloc(abYield, nAlloc*sizeof(int));
1209
+ }
1210
+ abYield[iOp] = str_in_array(zOp, azYield);
1211
+ p->aiIndent[iOp] = 0;
1212
+ p->nIndent = iOp+1;
1213
+
1214
+ if( str_in_array(zOp, azNext) ){
1215
+ for(i=p2; i<iOp; i++) p->aiIndent[i] += 2;
1216
+ }
1217
+ if( str_in_array(zOp, azGoto) && p2<p->nIndent && abYield[p2] ){
1218
+ for(i=p2+1; i<iOp; i++) p->aiIndent[i] += 2;
1219
+ }
1220
+ }
1221
+
1222
+ sqlite3_free(abYield);
1223
+ sqlite3_reset(pSql);
1224
+}
1225
+
1226
+/*
1227
+** Free the array allocated by explain_data_prepare().
1228
+*/
1229
+static void explain_data_delete(struct callback_data *p){
1230
+ sqlite3_free(p->aiIndent);
1231
+ p->aiIndent = 0;
1232
+ p->nIndent = 0;
1233
+}
11431234
11441235
/*
11451236
** Execute a statement or set of statements. Print
11461237
** any result rows/columns depending on the current mode
11471238
** set via the supplied callback.
@@ -1199,10 +1290,16 @@
11991290
sqlite3_test_control(SQLITE_TESTCTRL_EXPLAIN_STMT, pStmt, &zExplain);
12001291
if( zExplain && zExplain[0] ){
12011292
fprintf(pArg->out, "%s", zExplain);
12021293
}
12031294
}
1295
+
1296
+ /* If the shell is currently in ".explain" mode, gather the extra
1297
+ ** data required to add indents to the output.*/
1298
+ if( pArg->mode==MODE_Explain ){
1299
+ explain_data_prepare(pArg, pStmt);
1300
+ }
12041301
12051302
/* perform the first step. this will tell us if we
12061303
** have a result set or not and how wide it is.
12071304
*/
12081305
rc = sqlite3_step(pStmt);
@@ -1256,10 +1353,12 @@
12561353
do{
12571354
rc = sqlite3_step(pStmt);
12581355
} while( rc == SQLITE_ROW );
12591356
}
12601357
}
1358
+
1359
+ explain_data_delete(pArg);
12611360
12621361
/* print usage stats if stats on */
12631362
if( pArg && pArg->statsOn ){
12641363
display_stats(db, pArg, 0);
12651364
}
12661365
--- src/shell.c
+++ src/shell.c
@@ -462,10 +462,12 @@
462 const char *zDbFilename; /* name of the database file */
463 char *zFreeOnClose; /* Filename to free when closing */
464 const char *zVfs; /* Name of VFS to use */
465 sqlite3_stmt *pStmt; /* Current statement if any. */
466 FILE *pLog; /* Write log output here */
 
 
467 };
468
469 /*
470 ** These are the allowed modes.
471 */
@@ -763,13 +765,18 @@
763 if( i<ArraySize(p->actualWidth) ){
764 w = p->actualWidth[i];
765 }else{
766 w = 10;
767 }
768 if( p->mode==MODE_Explain && azArg[i] &&
769 strlen30(azArg[i])>w ){
770 w = strlen30(azArg[i]);
 
 
 
 
 
 
771 }
772 if( w<0 ){
773 fprintf(p->out,"%*.*s%s",-w,-w,
774 azArg[i] ? azArg[i] : p->nullvalue, i==nArg-1 ? "\n": " ");
775 }else{
@@ -1138,10 +1145,94 @@
1138 fprintf(pArg->out, "Virtual Machine Steps: %d\n", iCur);
1139 }
1140
1141 return 0;
1142 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1143
1144 /*
1145 ** Execute a statement or set of statements. Print
1146 ** any result rows/columns depending on the current mode
1147 ** set via the supplied callback.
@@ -1199,10 +1290,16 @@
1199 sqlite3_test_control(SQLITE_TESTCTRL_EXPLAIN_STMT, pStmt, &zExplain);
1200 if( zExplain && zExplain[0] ){
1201 fprintf(pArg->out, "%s", zExplain);
1202 }
1203 }
 
 
 
 
 
 
1204
1205 /* perform the first step. this will tell us if we
1206 ** have a result set or not and how wide it is.
1207 */
1208 rc = sqlite3_step(pStmt);
@@ -1256,10 +1353,12 @@
1256 do{
1257 rc = sqlite3_step(pStmt);
1258 } while( rc == SQLITE_ROW );
1259 }
1260 }
 
 
1261
1262 /* print usage stats if stats on */
1263 if( pArg && pArg->statsOn ){
1264 display_stats(db, pArg, 0);
1265 }
1266
--- src/shell.c
+++ src/shell.c
@@ -462,10 +462,12 @@
462 const char *zDbFilename; /* name of the database file */
463 char *zFreeOnClose; /* Filename to free when closing */
464 const char *zVfs; /* Name of VFS to use */
465 sqlite3_stmt *pStmt; /* Current statement if any. */
466 FILE *pLog; /* Write log output here */
467 int *aiIndent; /* Array of indents used in MODE_Explain */
468 int nIndent; /* Size of array aiIndent[] */
469 };
470
471 /*
472 ** These are the allowed modes.
473 */
@@ -763,13 +765,18 @@
765 if( i<ArraySize(p->actualWidth) ){
766 w = p->actualWidth[i];
767 }else{
768 w = 10;
769 }
770 if( p->mode==MODE_Explain && azArg[i] && strlen30(azArg[i])>w ){
 
771 w = strlen30(azArg[i]);
772 }
773 if( i==1 && p->aiIndent && p->pStmt ){
774 int iOp = sqlite3_column_int(p->pStmt, 0);
775 if( iOp<p->nIndent ){
776 fprintf(p->out, "%*.s", p->aiIndent[iOp], "");
777 }
778 }
779 if( w<0 ){
780 fprintf(p->out,"%*.*s%s",-w,-w,
781 azArg[i] ? azArg[i] : p->nullvalue, i==nArg-1 ? "\n": " ");
782 }else{
@@ -1138,10 +1145,94 @@
1145 fprintf(pArg->out, "Virtual Machine Steps: %d\n", iCur);
1146 }
1147
1148 return 0;
1149 }
1150
1151 /*
1152 ** Parameter azArray points to a zero-terminated array of strings. zStr
1153 ** points to a single nul-terminated string. Return non-zero if zStr
1154 ** is equal, according to strcmp(), to any of the strings in the array.
1155 ** Otherwise, return zero.
1156 */
1157 static int str_in_array(const char *zStr, const char **azArray){
1158 int i;
1159 for(i=0; azArray[i]; i++){
1160 if( 0==strcmp(zStr, azArray[i]) ) return 1;
1161 }
1162 return 0;
1163 }
1164
1165 /*
1166 ** If compiled statement pSql appears to be an EXPLAIN statement, allocate
1167 ** and populate the callback_data.aiIndent[] array with the number of
1168 ** spaces each opcode should be indented before it is output.
1169 **
1170 ** The indenting rules are:
1171 **
1172 ** * For each "Next", "Prev", "VNext" or "VPrev" instruction, indent
1173 ** all opcodes that occur between the p2 jump destination and the opcode
1174 ** itself by 2 spaces.
1175 **
1176 ** * For each "Goto", if the jump destination is a "Yield", "SeekGt",
1177 ** or "SeekLt" instruction that occurs earlier in the program than
1178 ** the Goto itself, indent all opcodes between the earlier instruction
1179 ** and "Goto" by 2 spaces.
1180 */
1181 static void explain_data_prepare(struct callback_data *p, sqlite3_stmt *pSql){
1182 const char *zSql; /* The text of the SQL statement */
1183 const char *z; /* Used to check if this is an EXPLAIN */
1184 int *abYield = 0; /* True if op is an OP_Yield */
1185 int nAlloc = 0; /* Allocated size of p->aiIndent[], abYield */
1186 int iOp;
1187
1188 const char *azNext[] = { "Next", "Prev", "VPrev", "VNext", 0 };
1189 const char *azYield[] = { "Yield", "SeekLt", "SeekGt", 0 };
1190 const char *azGoto[] = { "Goto", 0 };
1191
1192 /* Try to figure out if this is really an EXPLAIN statement. If this
1193 ** cannot be verified, return early. */
1194 zSql = sqlite3_sql(pSql);
1195 if( zSql==0 ) return;
1196 for(z=zSql; *z==' ' || *z=='\t' || *z=='\n' || *z=='\f' || *z=='\r'; z++);
1197 if( sqlite3_strnicmp(z, "explain", 7) ) return;
1198
1199 for(iOp=0; SQLITE_ROW==sqlite3_step(pSql); iOp++){
1200 int i;
1201 const char *zOp = (const char*)sqlite3_column_text(pSql, 1);
1202 int p2 = sqlite3_column_int(pSql, 3);
1203
1204 /* Grow the p->aiIndent array as required */
1205 if( iOp>=nAlloc ){
1206 nAlloc += 100;
1207 p->aiIndent = (int*)sqlite3_realloc(p->aiIndent, nAlloc*sizeof(int));
1208 abYield = (int*)sqlite3_realloc(abYield, nAlloc*sizeof(int));
1209 }
1210 abYield[iOp] = str_in_array(zOp, azYield);
1211 p->aiIndent[iOp] = 0;
1212 p->nIndent = iOp+1;
1213
1214 if( str_in_array(zOp, azNext) ){
1215 for(i=p2; i<iOp; i++) p->aiIndent[i] += 2;
1216 }
1217 if( str_in_array(zOp, azGoto) && p2<p->nIndent && abYield[p2] ){
1218 for(i=p2+1; i<iOp; i++) p->aiIndent[i] += 2;
1219 }
1220 }
1221
1222 sqlite3_free(abYield);
1223 sqlite3_reset(pSql);
1224 }
1225
1226 /*
1227 ** Free the array allocated by explain_data_prepare().
1228 */
1229 static void explain_data_delete(struct callback_data *p){
1230 sqlite3_free(p->aiIndent);
1231 p->aiIndent = 0;
1232 p->nIndent = 0;
1233 }
1234
1235 /*
1236 ** Execute a statement or set of statements. Print
1237 ** any result rows/columns depending on the current mode
1238 ** set via the supplied callback.
@@ -1199,10 +1290,16 @@
1290 sqlite3_test_control(SQLITE_TESTCTRL_EXPLAIN_STMT, pStmt, &zExplain);
1291 if( zExplain && zExplain[0] ){
1292 fprintf(pArg->out, "%s", zExplain);
1293 }
1294 }
1295
1296 /* If the shell is currently in ".explain" mode, gather the extra
1297 ** data required to add indents to the output.*/
1298 if( pArg->mode==MODE_Explain ){
1299 explain_data_prepare(pArg, pStmt);
1300 }
1301
1302 /* perform the first step. this will tell us if we
1303 ** have a result set or not and how wide it is.
1304 */
1305 rc = sqlite3_step(pStmt);
@@ -1256,10 +1353,12 @@
1353 do{
1354 rc = sqlite3_step(pStmt);
1355 } while( rc == SQLITE_ROW );
1356 }
1357 }
1358
1359 explain_data_delete(pArg);
1360
1361 /* print usage stats if stats on */
1362 if( pArg && pArg->statsOn ){
1363 display_stats(db, pArg, 0);
1364 }
1365
+262 -136
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -135,11 +135,11 @@
135135
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
136136
** [sqlite_version()] and [sqlite_source_id()].
137137
*/
138138
#define SQLITE_VERSION "3.8.2"
139139
#define SQLITE_VERSION_NUMBER 3008002
140
-#define SQLITE_SOURCE_ID "2013-11-12 15:33:40 0f924c6ef6cf2ac5a61aafa8dd8e3309b3970499"
140
+#define SQLITE_SOURCE_ID "2013-11-14 19:34:10 10d59226382adcb8016fc2d927e5a0c0b36f3980"
141141
142142
/*
143143
** CAPI3REF: Run-Time Library Version Numbers
144144
** KEYWORDS: sqlite3_version, sqlite3_sourceid
145145
**
@@ -9237,11 +9237,10 @@
92379237
SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*);
92389238
SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int);
92399239
SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*);
92409240
#ifdef SQLITE_DEBUG
92419241
SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *, int);
9242
-SQLITE_PRIVATE void sqlite3VdbeTrace(Vdbe*,FILE*);
92439242
#endif
92449243
SQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe*);
92459244
SQLITE_PRIVATE void sqlite3VdbeRewind(Vdbe*);
92469245
SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*);
92479246
SQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe*,int);
@@ -10304,10 +10303,11 @@
1030410303
#define SQLITE_PreferBuiltin 0x00200000 /* Preference to built-in funcs */
1030510304
#define SQLITE_LoadExtension 0x00400000 /* Enable load_extension */
1030610305
#define SQLITE_EnableTrigger 0x00800000 /* True to enable triggers */
1030710306
#define SQLITE_DeferFKs 0x01000000 /* Defer all FK constraints */
1030810307
#define SQLITE_QueryOnly 0x02000000 /* Disable database changes */
10308
+#define SQLITE_VdbeEQP 0x04000000 /* Debug EXPLAIN QUERY PLAN */
1030910309
1031010310
1031110311
/*
1031210312
** Bits of the sqlite3.dbOptFlags field that are used by the
1031310313
** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
@@ -13700,13 +13700,10 @@
1370013700
i64 nFkConstraint; /* Number of imm. FK constraints this VM */
1370113701
i64 nStmtDefCons; /* Number of def. constraints when stmt started */
1370213702
i64 nStmtDefImmCons; /* Number of def. imm constraints when stmt started */
1370313703
char *zSql; /* Text of the SQL statement that generated this */
1370413704
void *pFree; /* Free this when deleting the vdbe */
13705
-#ifdef SQLITE_DEBUG
13706
- FILE *trace; /* Write an execution trace here, if not NULL */
13707
-#endif
1370813705
#ifdef SQLITE_ENABLE_TREE_EXPLAIN
1370913706
Explain *pExplain; /* The explainer */
1371013707
char *zExplain; /* Explanation of data structures */
1371113708
#endif
1371213709
VdbeFrame *pFrame; /* Parent frame */
@@ -61013,19 +61010,10 @@
6101361010
pA->zSql = pB->zSql;
6101461011
pB->zSql = zTmp;
6101561012
pB->isPrepareV2 = pA->isPrepareV2;
6101661013
}
6101761014
61018
-#ifdef SQLITE_DEBUG
61019
-/*
61020
-** Turn tracing on or off
61021
-*/
61022
-SQLITE_PRIVATE void sqlite3VdbeTrace(Vdbe *p, FILE *trace){
61023
- p->trace = trace;
61024
-}
61025
-#endif
61026
-
6102761015
/*
6102861016
** Resize the Vdbe.aOp array so that it is at least one op larger than
6102961017
** it was.
6103061018
**
6103161019
** If an out-of-memory error occurs while resizing the array, return
@@ -61917,11 +61905,11 @@
6191761905
assert( i<nTemp );
6191861906
break;
6191961907
}
6192061908
case P4_COLLSEQ: {
6192161909
CollSeq *pColl = pOp->p4.pColl;
61922
- sqlite3_snprintf(nTemp, zTemp, "collseq(%.20s)", pColl->zName);
61910
+ sqlite3_snprintf(nTemp, zTemp, "(%.20s)", pColl->zName);
6192361911
break;
6192461912
}
6192561913
case P4_FUNCDEF: {
6192661914
FuncDef *pDef = pOp->p4.pFunc;
6192761915
sqlite3_snprintf(nTemp, zTemp, "%s(%d)", pDef->zName, pDef->nArg);
@@ -62350,19 +62338,21 @@
6235062338
#ifdef SQLITE_DEBUG
6235162339
/*
6235262340
** Print the SQL that was used to generate a VDBE program.
6235362341
*/
6235462342
SQLITE_PRIVATE void sqlite3VdbePrintSql(Vdbe *p){
62355
- int nOp = p->nOp;
62356
- VdbeOp *pOp;
62357
- if( nOp<1 ) return;
62358
- pOp = &p->aOp[0];
62359
- if( pOp->opcode==OP_Trace && pOp->p4.z!=0 ){
62360
- const char *z = pOp->p4.z;
62361
- while( sqlite3Isspace(*z) ) z++;
62362
- printf("SQL: [%s]\n", z);
62363
- }
62343
+ const char *z = 0;
62344
+ if( p->zSql ){
62345
+ z = p->zSql;
62346
+ }else if( p->nOp>=1 ){
62347
+ const VdbeOp *pOp = &p->aOp[0];
62348
+ if( pOp->opcode==OP_Trace && pOp->p4.z!=0 ){
62349
+ z = pOp->p4.z;
62350
+ while( sqlite3Isspace(*z) ) z++;
62351
+ }
62352
+ }
62353
+ if( z ) printf("SQL: [%s]\n", z);
6236462354
}
6236562355
#endif
6236662356
6236762357
#if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)
6236862358
/*
@@ -66366,41 +66356,40 @@
6636666356
6636766357
#ifdef SQLITE_DEBUG
6636866358
/*
6636966359
** Print the value of a register for tracing purposes:
6637066360
*/
66371
-static void memTracePrint(FILE *out, Mem *p){
66361
+static void memTracePrint(Mem *p){
6637266362
if( p->flags & MEM_Invalid ){
66373
- fprintf(out, " undefined");
66363
+ printf(" undefined");
6637466364
}else if( p->flags & MEM_Null ){
66375
- fprintf(out, " NULL");
66365
+ printf(" NULL");
6637666366
}else if( (p->flags & (MEM_Int|MEM_Str))==(MEM_Int|MEM_Str) ){
66377
- fprintf(out, " si:%lld", p->u.i);
66367
+ printf(" si:%lld", p->u.i);
6637866368
}else if( p->flags & MEM_Int ){
66379
- fprintf(out, " i:%lld", p->u.i);
66369
+ printf(" i:%lld", p->u.i);
6638066370
#ifndef SQLITE_OMIT_FLOATING_POINT
6638166371
}else if( p->flags & MEM_Real ){
66382
- fprintf(out, " r:%g", p->r);
66372
+ printf(" r:%g", p->r);
6638366373
#endif
6638466374
}else if( p->flags & MEM_RowSet ){
66385
- fprintf(out, " (rowset)");
66375
+ printf(" (rowset)");
6638666376
}else{
6638766377
char zBuf[200];
6638866378
sqlite3VdbeMemPrettyPrint(p, zBuf);
66389
- fprintf(out, " ");
66390
- fprintf(out, "%s", zBuf);
66379
+ printf(" %s", zBuf);
6639166380
}
6639266381
}
66393
-static void registerTrace(FILE *out, int iReg, Mem *p){
66394
- fprintf(out, "REG[%d] = ", iReg);
66395
- memTracePrint(out, p);
66396
- fprintf(out, "\n");
66382
+static void registerTrace(int iReg, Mem *p){
66383
+ printf("REG[%d] = ", iReg);
66384
+ memTracePrint(p);
66385
+ printf("\n");
6639766386
}
6639866387
#endif
6639966388
6640066389
#ifdef SQLITE_DEBUG
66401
-# define REGISTER_TRACE(R,M) if(p->trace)registerTrace(p->trace,R,M)
66390
+# define REGISTER_TRACE(R,M) if(db->flags&SQLITE_VdbeTrace)registerTrace(R,M)
6640266391
#else
6640366392
# define REGISTER_TRACE(R,M)
6640466393
#endif
6640566394
6640666395
@@ -67051,17 +67040,32 @@
6705167040
}
6705267041
}
6705367042
#endif
6705467043
#ifdef SQLITE_DEBUG
6705567044
sqlite3BeginBenignMalloc();
67056
- if( p->pc==0 && (p->db->flags & SQLITE_VdbeListing)!=0 ){
67045
+ if( p->pc==0
67046
+ && (p->db->flags & (SQLITE_VdbeListing|SQLITE_VdbeEQP|SQLITE_VdbeTrace))!=0
67047
+ ){
6705767048
int i;
67058
- printf("VDBE Program Listing:\n");
67049
+ int once = 1;
6705967050
sqlite3VdbePrintSql(p);
67060
- for(i=0; i<p->nOp; i++){
67061
- sqlite3VdbePrintOp(stdout, i, &aOp[i]);
67051
+ if( p->db->flags & SQLITE_VdbeListing ){
67052
+ printf("VDBE Program Listing:\n");
67053
+ for(i=0; i<p->nOp; i++){
67054
+ sqlite3VdbePrintOp(stdout, i, &aOp[i]);
67055
+ }
6706267056
}
67057
+ if( p->db->flags & SQLITE_VdbeEQP ){
67058
+ for(i=0; i<p->nOp; i++){
67059
+ if( aOp[i].opcode==OP_Explain ){
67060
+ if( once ) printf("VDBE Query Plan:\n");
67061
+ printf("%s\n", aOp[i].p4.z);
67062
+ once = 0;
67063
+ }
67064
+ }
67065
+ }
67066
+ if( p->db->flags & SQLITE_VdbeTrace ) printf("VDBE Trace:\n");
6706367067
}
6706467068
sqlite3EndBenignMalloc();
6706567069
#endif
6706667070
for(pc=p->pc; rc==SQLITE_OK; pc++){
6706767071
assert( pc>=0 && pc<p->nOp );
@@ -67074,16 +67078,12 @@
6707467078
pOp = &aOp[pc];
6707567079
6707667080
/* Only allow tracing if SQLITE_DEBUG is defined.
6707767081
*/
6707867082
#ifdef SQLITE_DEBUG
67079
- if( p->trace ){
67080
- if( pc==0 ){
67081
- printf("VDBE Execution Trace:\n");
67082
- sqlite3VdbePrintSql(p);
67083
- }
67084
- sqlite3VdbePrintOp(p->trace, pc, pOp);
67083
+ if( db->flags & SQLITE_VdbeTrace ){
67084
+ sqlite3VdbePrintOp(stdout, pc, pOp);
6708567085
}
6708667086
#endif
6708767087
6708867088
6708967089
/* Check to see if we need to simulate an interrupt. This only happens
@@ -67210,19 +67210,16 @@
6721067210
** sqlite3VdbeExec() or since last time the progress callback was called).
6721167211
** If the progress callback returns non-zero, exit the virtual machine with
6721267212
** a return code SQLITE_ABORT.
6721367213
*/
6721467214
if( db->xProgress!=0 && nVmStep>=nProgressLimit ){
67215
- int prc;
67216
- prc = db->xProgress(db->pProgressArg);
67217
- if( prc!=0 ){
67215
+ assert( db->nProgressOps!=0 );
67216
+ nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps);
67217
+ if( db->xProgress(db->pProgressArg) ){
6721867218
rc = SQLITE_INTERRUPT;
6721967219
goto vdbe_error_halt;
6722067220
}
67221
- if( db->xProgress!=0 ){
67222
- nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps);
67223
- }
6722467221
}
6722567222
#endif
6722667223
6722767224
break;
6722867225
}
@@ -67654,10 +67651,22 @@
6765467651
int i;
6765567652
#endif /* local variables moved into u.ag */
6765667653
assert( p->nResColumn==pOp->p2 );
6765767654
assert( pOp->p1>0 );
6765867655
assert( pOp->p1+pOp->p2<=(p->nMem-p->nCursor)+1 );
67656
+
67657
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
67658
+ /* Run the progress counter just before returning.
67659
+ */
67660
+ if( db->xProgress!=0
67661
+ && nVmStep>=nProgressLimit
67662
+ && db->xProgress(db->pProgressArg)!=0
67663
+ ){
67664
+ rc = SQLITE_INTERRUPT;
67665
+ goto vdbe_error_halt;
67666
+ }
67667
+#endif
6765967668
6766067669
/* If this statement has violated immediate foreign key constraints, do
6766167670
** not return the number of rows modified. And do not RELEASE the statement
6766267671
** transaction. It needs to be rolled back. */
6766367672
if( SQLITE_OK!=(rc = sqlite3VdbeCheckFk(p, 0)) ){
@@ -72862,17 +72871,17 @@
7286272871
*/
7286372872
#ifndef NDEBUG
7286472873
assert( pc>=-1 && pc<p->nOp );
7286572874
7286672875
#ifdef SQLITE_DEBUG
72867
- if( p->trace ){
72868
- if( rc!=0 ) fprintf(p->trace,"rc=%d\n",rc);
72876
+ if( db->flags & SQLITE_VdbeTrace ){
72877
+ if( rc!=0 ) printf("rc=%d\n",rc);
7286972878
if( pOp->opflags & (OPFLG_OUT2_PRERELEASE|OPFLG_OUT2) ){
72870
- registerTrace(p->trace, pOp->p2, &aMem[pOp->p2]);
72879
+ registerTrace(pOp->p2, &aMem[pOp->p2]);
7287172880
}
7287272881
if( pOp->opflags & OPFLG_OUT3 ){
72873
- registerTrace(p->trace, pOp->p3, &aMem[pOp->p3]);
72882
+ registerTrace(pOp->p3, &aMem[pOp->p3]);
7287472883
}
7287572884
}
7287672885
#endif /* SQLITE_DEBUG */
7287772886
#endif /* NDEBUG */
7287872887
} /* The end of the for(;;) loop the loops through opcodes */
@@ -83106,14 +83115,16 @@
8310683115
}
8310783116
pTable = sqlite3FindTable(pInfo->db, argv[0], pInfo->zDatabase);
8310883117
if( pTable==0 ){
8310983118
return 0;
8311083119
}
83111
- if( argv[1] ){
83112
- pIndex = sqlite3FindIndex(pInfo->db, argv[1], pInfo->zDatabase);
83113
- }else{
83120
+ if( argv[1]==0 ){
8311483121
pIndex = 0;
83122
+ }else if( sqlite3_stricmp(argv[0],argv[1])==0 ){
83123
+ pIndex = sqlite3PrimaryKeyIndex(pTable);
83124
+ }else{
83125
+ pIndex = sqlite3FindIndex(pInfo->db, argv[1], pInfo->zDatabase);
8311583126
}
8311683127
z = argv[2];
8311783128
8311883129
if( pIndex ){
8311983130
decodeIntArray((char*)z, pIndex->nKeyCol+1, pIndex->aiRowEst, pIndex);
@@ -84467,14 +84478,10 @@
8446784478
8446884479
8446984480
/* Get the VDBE program ready for execution
8447084481
*/
8447184482
if( v && ALWAYS(pParse->nErr==0) && !db->mallocFailed ){
84472
-#ifdef SQLITE_DEBUG
84473
- FILE *trace = (db->flags & SQLITE_VdbeTrace)!=0 ? stdout : 0;
84474
- sqlite3VdbeTrace(v, trace);
84475
-#endif
8447684483
assert( pParse->iCacheLevel==0 ); /* Disables and re-enables match */
8447784484
/* A minimum of one cursor is required if autoincrement is used
8447884485
* See ticket [a696379c1f08866] */
8447984486
if( pParse->pAinc!=0 && pParse->nTab==0 ) pParse->nTab = 1;
8448084487
sqlite3VdbeMakeReady(v, pParse);
@@ -96680,10 +96687,14 @@
9668096687
/* iArg: */ SQLITE_VdbeAddopTrace },
9668196688
{ /* zName: */ "vdbe_debug",
9668296689
/* ePragTyp: */ PragTyp_FLAG,
9668396690
/* ePragFlag: */ 0,
9668496691
/* iArg: */ SQLITE_SqlTrace|SQLITE_VdbeListing|SQLITE_VdbeTrace },
96692
+ { /* zName: */ "vdbe_eqp",
96693
+ /* ePragTyp: */ PragTyp_FLAG,
96694
+ /* ePragFlag: */ 0,
96695
+ /* iArg: */ SQLITE_VdbeEQP },
9668596696
{ /* zName: */ "vdbe_listing",
9668696697
/* ePragTyp: */ PragTyp_FLAG,
9668796698
/* ePragFlag: */ 0,
9668896699
/* iArg: */ SQLITE_VdbeListing },
9668996700
{ /* zName: */ "vdbe_trace",
@@ -96707,11 +96718,11 @@
9670796718
/* ePragTyp: */ PragTyp_FLAG,
9670896719
/* ePragFlag: */ 0,
9670996720
/* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
9671096721
#endif
9671196722
};
96712
-/* Number of pragmas: 56 on by default, 68 total. */
96723
+/* Number of pragmas: 56 on by default, 69 total. */
9671396724
/* End of the automatically generated pragma table.
9671496725
***************************************************************************/
9671596726
9671696727
/*
9671796728
** Interpret the given string as a safety level. Return 0 for OFF,
@@ -107929,11 +107940,28 @@
107929107940
** generating the code that loops through a table looking for applicable
107930107941
** rows. Indices are selected and used to speed the search when doing
107931107942
** so is applicable. Because this module is responsible for selecting
107932107943
** indices, you might also think of this module as the "query optimizer".
107933107944
*/
107934
-
107945
+/************** Include whereInt.h in the middle of where.c ******************/
107946
+/************** Begin file whereInt.h ****************************************/
107947
+/*
107948
+** 2013-11-12
107949
+**
107950
+** The author disclaims copyright to this source code. In place of
107951
+** a legal notice, here is a blessing:
107952
+**
107953
+** May you do good and not evil.
107954
+** May you find forgiveness for yourself and forgive others.
107955
+** May you share freely, never taking more than you give.
107956
+**
107957
+*************************************************************************
107958
+**
107959
+** This file contains structure and macro definitions for the query
107960
+** planner logic in "where.c". These definitions are broken out into
107961
+** a separate source file for easier editing.
107962
+*/
107935107963
107936107964
/*
107937107965
** Trace output macros
107938107966
*/
107939107967
#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
@@ -107981,10 +108009,11 @@
107981108009
int iLeftJoin; /* Memory cell used to implement LEFT OUTER JOIN */
107982108010
int iTabCur; /* The VDBE cursor used to access the table */
107983108011
int iIdxCur; /* The VDBE cursor used to access pIdx */
107984108012
int addrBrk; /* Jump here to break out of the loop */
107985108013
int addrNxt; /* Jump here to start the next IN combination */
108014
+ int addrSkip; /* Jump here for next iteration of skip-scan */
107986108015
int addrCont; /* Jump here to continue with the next loop cycle */
107987108016
int addrFirst; /* First instruction of interior of the loop */
107988108017
int addrBody; /* Beginning of the body of this loop */
107989108018
u8 iFrom; /* Which entry in the FROM clause */
107990108019
u8 op, p5; /* Opcode and P5 of the opcode that ends the loop */
@@ -108030,11 +108059,11 @@
108030108059
LogEst rRun; /* Cost of running each loop */
108031108060
LogEst nOut; /* Estimated number of output rows */
108032108061
union {
108033108062
struct { /* Information for internal btree tables */
108034108063
u16 nEq; /* Number of equality constraints */
108035
- u16 nSkip; /* Number of initial index columns skipped */
108064
+ u16 nSkip; /* Number of initial index columns to skip */
108036108065
Index *pIndex; /* Index used, or NULL */
108037108066
} btree;
108038108067
struct { /* Information for virtual tables */
108039108068
int idxNum; /* Index number */
108040108069
u8 needFree; /* True if sqlite3_free(idxStr) is needed */
@@ -108371,10 +108400,14 @@
108371108400
#define WHERE_VIRTUALTABLE 0x00000400 /* WhereLoop.u.vtab is valid */
108372108401
#define WHERE_IN_ABLE 0x00000800 /* Able to support an IN operator */
108373108402
#define WHERE_ONEROW 0x00001000 /* Selects no more than one row */
108374108403
#define WHERE_MULTI_OR 0x00002000 /* OR using multiple indices */
108375108404
#define WHERE_AUTO_INDEX 0x00004000 /* Uses an ephemeral index */
108405
+#define WHERE_SKIPSCAN 0x00008000 /* Uses the skip-scan algorithm */
108406
+
108407
+/************** End of whereInt.h ********************************************/
108408
+/************** Continuing where we left off in where.c **********************/
108376108409
108377108410
/*
108378108411
** Return the estimated number of output rows from a WHERE clause
108379108412
*/
108380108413
SQLITE_PRIVATE u64 sqlite3WhereOutputRowCount(WhereInfo *pWInfo){
@@ -110775,11 +110808,11 @@
110775110808
return iReg;
110776110809
}
110777110810
110778110811
/*
110779110812
** Generate code that will evaluate all == and IN constraints for an
110780
-** index.
110813
+** index scan.
110781110814
**
110782110815
** For example, consider table t1(a,b,c,d,e,f) with index i1(a,b,c).
110783110816
** Suppose the WHERE clause is this: a==5 AND b IN (1,2,3) AND c>5 AND c<10
110784110817
** The index has as many as three equality constraints, but in this
110785110818
** example, the third "c" value is an inequality. So only two
@@ -110790,13 +110823,19 @@
110790110823
** In the example above nEq==2. But this subroutine works for any value
110791110824
** of nEq including 0. If nEq==0, this routine is nearly a no-op.
110792110825
** The only thing it does is allocate the pLevel->iMem memory cell and
110793110826
** compute the affinity string.
110794110827
**
110795
-** This routine always allocates at least one memory cell and returns
110796
-** the index of that memory cell. The code that
110797
-** calls this routine will use that memory cell to store the termination
110828
+** The nExtraReg parameter is 0 or 1. It is 0 if all WHERE clause constraints
110829
+** are == or IN and are covered by the nEq. nExtraReg is 1 if there is
110830
+** an inequality constraint (such as the "c>=5 AND c<10" in the example) that
110831
+** occurs after the nEq quality constraints.
110832
+**
110833
+** This routine allocates a range of nEq+nExtraReg memory cells and returns
110834
+** the index of the first memory cell in that range. The code that
110835
+** calls this routine will use that memory range to store keys for
110836
+** start and termination conditions of the loop.
110798110837
** key value of the loop. If one or more IN operators appear, then
110799110838
** this routine allocates an additional nEq memory cells for internal
110800110839
** use.
110801110840
**
110802110841
** Before returning, *pzAff is set to point to a buffer containing a
@@ -110819,11 +110858,12 @@
110819110858
WhereLevel *pLevel, /* Which nested loop of the FROM we are coding */
110820110859
int bRev, /* Reverse the order of IN operators */
110821110860
int nExtraReg, /* Number of extra registers to allocate */
110822110861
char **pzAff /* OUT: Set to point to affinity string */
110823110862
){
110824
- int nEq; /* The number of == or IN constraints to code */
110863
+ u16 nEq; /* The number of == or IN constraints to code */
110864
+ u16 nSkip; /* Number of left-most columns to skip */
110825110865
Vdbe *v = pParse->pVdbe; /* The vm under construction */
110826110866
Index *pIdx; /* The index being used for this loop */
110827110867
WhereTerm *pTerm; /* A single constraint term */
110828110868
WhereLoop *pLoop; /* The WhereLoop object */
110829110869
int j; /* Loop counter */
@@ -110833,10 +110873,11 @@
110833110873
110834110874
/* This module is only called on query plans that use an index. */
110835110875
pLoop = pLevel->pWLoop;
110836110876
assert( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 );
110837110877
nEq = pLoop->u.btree.nEq;
110878
+ nSkip = pLoop->u.btree.nSkip;
110838110879
pIdx = pLoop->u.btree.pIndex;
110839110880
assert( pIdx!=0 );
110840110881
110841110882
/* Figure out how many memory cells we will need then allocate them.
110842110883
*/
@@ -110846,19 +110887,34 @@
110846110887
110847110888
zAff = sqlite3DbStrDup(pParse->db, sqlite3IndexAffinityStr(v, pIdx));
110848110889
if( !zAff ){
110849110890
pParse->db->mallocFailed = 1;
110850110891
}
110892
+
110893
+ if( nSkip ){
110894
+ int iIdxCur = pLevel->iIdxCur;
110895
+ sqlite3VdbeAddOp1(v, (bRev?OP_Last:OP_Rewind), iIdxCur);
110896
+ VdbeComment((v, "begin skip-scan on %s", pIdx->zName));
110897
+ j = sqlite3VdbeAddOp0(v, OP_Goto);
110898
+ pLevel->addrSkip = sqlite3VdbeAddOp4Int(v, (bRev?OP_SeekLt:OP_SeekGt),
110899
+ iIdxCur, 0, regBase, nSkip);
110900
+ sqlite3VdbeJumpHere(v, j);
110901
+ for(j=0; j<nSkip; j++){
110902
+ sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, j, regBase+j);
110903
+ assert( pIdx->aiColumn[j]>=0 );
110904
+ VdbeComment((v, "%s", pIdx->pTable->aCol[pIdx->aiColumn[j]].zName));
110905
+ }
110906
+ }
110851110907
110852110908
/* Evaluate the equality constraints
110853110909
*/
110854110910
assert( zAff==0 || (int)strlen(zAff)>=nEq );
110855
- for(j=0; j<nEq; j++){
110911
+ for(j=nSkip; j<nEq; j++){
110856110912
int r1;
110857110913
pTerm = pLoop->aLTerm[j];
110858110914
assert( pTerm!=0 );
110859
- /* The following true for indices with redundant columns.
110915
+ /* The following testcase is true for indices with redundant columns.
110860110916
** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */
110861110917
testcase( (pTerm->wtFlags & TERM_CODED)!=0 );
110862110918
testcase( pTerm->wtFlags & TERM_VIRTUAL );
110863110919
r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, regBase+j);
110864110920
if( r1!=regBase+j ){
@@ -110928,11 +110984,12 @@
110928110984
** It is the responsibility of the caller to free the buffer when it is
110929110985
** no longer required.
110930110986
*/
110931110987
static char *explainIndexRange(sqlite3 *db, WhereLoop *pLoop, Table *pTab){
110932110988
Index *pIndex = pLoop->u.btree.pIndex;
110933
- int nEq = pLoop->u.btree.nEq;
110989
+ u16 nEq = pLoop->u.btree.nEq;
110990
+ u16 nSkip = pLoop->u.btree.nSkip;
110934110991
int i, j;
110935110992
Column *aCol = pTab->aCol;
110936110993
i16 *aiColumn = pIndex->aiColumn;
110937110994
StrAccum txt;
110938110995
@@ -110942,11 +110999,18 @@
110942110999
sqlite3StrAccumInit(&txt, 0, 0, SQLITE_MAX_LENGTH);
110943111000
txt.db = db;
110944111001
sqlite3StrAccumAppend(&txt, " (", 2);
110945111002
for(i=0; i<nEq; i++){
110946111003
char *z = (i==pIndex->nKeyCol ) ? "rowid" : aCol[aiColumn[i]].zName;
110947
- explainAppendTerm(&txt, i, z, "=");
111004
+ if( i>=nSkip ){
111005
+ explainAppendTerm(&txt, i, z, "=");
111006
+ }else{
111007
+ if( i ) sqlite3StrAccumAppend(&txt, " AND ", 5);
111008
+ sqlite3StrAccumAppend(&txt, "ANY(", 4);
111009
+ sqlite3StrAccumAppend(&txt, z, -1);
111010
+ sqlite3StrAccumAppend(&txt, ")", 1);
111011
+ }
110948111012
}
110949111013
110950111014
j = i;
110951111015
if( pLoop->wsFlags&WHERE_BTM_LIMIT ){
110952111016
char *z = (j==pIndex->nKeyCol ) ? "rowid" : aCol[aiColumn[j]].zName;
@@ -110972,11 +111036,14 @@
110972111036
WhereLevel *pLevel, /* Scan to write OP_Explain opcode for */
110973111037
int iLevel, /* Value for "level" column of output */
110974111038
int iFrom, /* Value for "from" column of output */
110975111039
u16 wctrlFlags /* Flags passed to sqlite3WhereBegin() */
110976111040
){
110977
- if( pParse->explain==2 ){
111041
+#ifndef SQLITE_DEBUG
111042
+ if( pParse->explain==2 )
111043
+#endif
111044
+ {
110978111045
struct SrcList_item *pItem = &pTabList->a[pLevel->iFrom];
110979111046
Vdbe *v = pParse->pVdbe; /* VM being constructed */
110980111047
sqlite3 *db = pParse->db; /* Database handle */
110981111048
char *zMsg; /* Text to add to EQP output */
110982111049
int iId = pParse->iSelectId; /* Select id (left-most output column) */
@@ -111078,11 +111145,11 @@
111078111145
iCur = pTabItem->iCursor;
111079111146
pLevel->notReady = notReady & ~getMask(&pWInfo->sMaskSet, iCur);
111080111147
bRev = (pWInfo->revMask>>iLevel)&1;
111081111148
omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0
111082111149
&& (pWInfo->wctrlFlags & WHERE_FORCE_TABLE)==0;
111083
- VdbeNoopComment((v, "Begin WHERE-Loop %d: %s", iLevel,pTabItem->pTab->zName));
111150
+ VdbeNoopComment((v, "Begin WHERE-loop%d: %s",iLevel,pTabItem->pTab->zName));
111084111151
111085111152
/* Create labels for the "break" and "continue" instructions
111086111153
** for the current loop. Jump to addrBrk to break out of a loop.
111087111154
** Jump to cont to go immediately to the next iteration of the
111088111155
** loop.
@@ -111305,12 +111372,12 @@
111305111372
static const u8 aEndOp[] = {
111306111373
OP_Noop, /* 0: (!end_constraints) */
111307111374
OP_IdxGE, /* 1: (end_constraints && !bRev) */
111308111375
OP_IdxLT /* 2: (end_constraints && bRev) */
111309111376
};
111310
- int nEq = pLoop->u.btree.nEq; /* Number of == or IN terms */
111311
- int isMinQuery = 0; /* If this is an optimized SELECT min(x).. */
111377
+ u16 nEq = pLoop->u.btree.nEq; /* Number of == or IN terms */
111378
+ int isMinQuery = 0; /* If this is an optimized SELECT min(x).. */
111312111379
int regBase; /* Base register holding constraint values */
111313111380
int r1; /* Temp register */
111314111381
WhereTerm *pRangeStart = 0; /* Inequality constraint at range start */
111315111382
WhereTerm *pRangeEnd = 0; /* Inequality constraint at range end */
111316111383
int startEq; /* True if range start uses ==, >= or <= */
@@ -111324,10 +111391,11 @@
111324111391
char *zStartAff; /* Affinity for start of range constraint */
111325111392
char *zEndAff; /* Affinity for end of range constraint */
111326111393
111327111394
pIdx = pLoop->u.btree.pIndex;
111328111395
iIdxCur = pLevel->iIdxCur;
111396
+ assert( nEq>=pLoop->u.btree.nSkip );
111329111397
111330111398
/* If this loop satisfies a sort order (pOrderBy) request that
111331111399
** was passed to this function to implement a "SELECT min(x) ..."
111332111400
** query, then the caller will only allow the loop to run for
111333111401
** a single iteration. This means that the first row returned
@@ -111337,12 +111405,11 @@
111337111405
*/
111338111406
if( (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)!=0
111339111407
&& (pWInfo->bOBSat!=0)
111340111408
&& (pIdx->nKeyCol>nEq)
111341111409
){
111342
- /* assert( pOrderBy->nExpr==1 ); */
111343
- /* assert( pOrderBy->a[0].pExpr->iColumn==pIdx->aiColumn[nEq] ); */
111410
+ assert( pLoop->u.btree.nSkip==0 );
111344111411
isMinQuery = 1;
111345111412
nExtraReg = 1;
111346111413
}
111347111414
111348111415
/* Find any inequality constraint terms for the start and end
@@ -111469,12 +111536,16 @@
111469111536
** If it is, jump to the next iteration of the loop.
111470111537
*/
111471111538
r1 = sqlite3GetTempReg(pParse);
111472111539
testcase( pLoop->wsFlags & WHERE_BTM_LIMIT );
111473111540
testcase( pLoop->wsFlags & WHERE_TOP_LIMIT );
111474
- if( (pLoop->wsFlags & (WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0 ){
111541
+ if( (pLoop->wsFlags & (WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0
111542
+ && (j = pIdx->aiColumn[nEq])>=0
111543
+ && pIdx->pTable->aCol[j].notNull==0
111544
+ ){
111475111545
sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, nEq, r1);
111546
+ VdbeComment((v, "%s", pIdx->pTable->aCol[j].zName));
111476111547
sqlite3VdbeAddOp2(v, OP_IsNull, r1, addrCont);
111477111548
}
111478111549
sqlite3ReleaseTempReg(pParse, r1);
111479111550
111480111551
/* Seek the table cursor, if required */
@@ -111858,16 +111929,11 @@
111858111929
if( strncmp(zName, "sqlite_autoindex_", 17)==0 ){
111859111930
int i = sqlite3Strlen30(zName) - 1;
111860111931
while( zName[i]!='_' ) i--;
111861111932
zName += i;
111862111933
}
111863
- if( p->u.btree.nSkip ){
111864
- sqlite3DebugPrintf(".%-15s %d+%d", zName,
111865
- p->u.btree.nSkip, p->u.btree.nEq);
111866
- }else{
111867
- sqlite3DebugPrintf(".%-16s %2d", zName, p->u.btree.nEq);
111868
- }
111934
+ sqlite3DebugPrintf(".%-16s %2d", zName, p->u.btree.nEq);
111869111935
}else{
111870111936
sqlite3DebugPrintf("%20s","");
111871111937
}
111872111938
}else{
111873111939
char *z;
@@ -111890,10 +111956,11 @@
111890111956
int i;
111891111957
Vdbe *v = pWInfo->pParse->pVdbe;
111892111958
sqlite3ExplainBegin(v);
111893111959
for(i=0; i<p->nLTerm; i++){
111894111960
WhereTerm *pTerm = p->aLTerm[i];
111961
+ if( pTerm==0 ) continue;
111895111962
sqlite3ExplainPrintf(v, " (%d) #%-2d ", i+1, (int)(pTerm-pWC->a));
111896111963
sqlite3ExplainPush(v);
111897111964
whereExplainTerm(v, pTerm);
111898111965
sqlite3ExplainPop(v);
111899111966
sqlite3ExplainNL(v);
@@ -112173,10 +112240,11 @@
112173112240
if( (pTerm->wtFlags & TERM_VIRTUAL)!=0 ) break;
112174112241
if( (pTerm->prereqAll & pLoop->maskSelf)==0 ) continue;
112175112242
if( (pTerm->prereqAll & notAllowed)!=0 ) continue;
112176112243
for(j=pLoop->nLTerm-1; j>=0; j--){
112177112244
pX = pLoop->aLTerm[j];
112245
+ if( pX==0 ) continue;
112178112246
if( pX==pTerm ) break;
112179112247
if( pX->iParent>=0 && (&pWC->a[pX->iParent])==pTerm ) break;
112180112248
}
112181112249
if( j<0 ) pLoop->nOut += pTerm->truthProb;
112182112250
}
@@ -112202,11 +112270,12 @@
112202112270
WhereTerm *pTerm; /* A WhereTerm under consideration */
112203112271
int opMask; /* Valid operators for constraints */
112204112272
WhereScan scan; /* Iterator for WHERE terms */
112205112273
Bitmask saved_prereq; /* Original value of pNew->prereq */
112206112274
u16 saved_nLTerm; /* Original value of pNew->nLTerm */
112207
- int saved_nEq; /* Original value of pNew->u.btree.nEq */
112275
+ u16 saved_nEq; /* Original value of pNew->u.btree.nEq */
112276
+ u16 saved_nSkip; /* Original value of pNew->u.btree.nSkip */
112208112277
u32 saved_wsFlags; /* Original value of pNew->wsFlags */
112209112278
LogEst saved_nOut; /* Original value of pNew->nOut */
112210112279
int iCol; /* Index of the column in the table */
112211112280
int rc = SQLITE_OK; /* Return code */
112212112281
LogEst nRowEst; /* Estimated index selectivity */
@@ -112237,16 +112306,30 @@
112237112306
nRowEst = 0;
112238112307
}
112239112308
pTerm = whereScanInit(&scan, pBuilder->pWC, pSrc->iCursor, iCol,
112240112309
opMask, pProbe);
112241112310
saved_nEq = pNew->u.btree.nEq;
112311
+ saved_nSkip = pNew->u.btree.nSkip;
112242112312
saved_nLTerm = pNew->nLTerm;
112243112313
saved_wsFlags = pNew->wsFlags;
112244112314
saved_prereq = pNew->prereq;
112245112315
saved_nOut = pNew->nOut;
112246112316
pNew->rSetup = 0;
112247112317
rLogSize = estLog(sqlite3LogEst(pProbe->aiRowEst[0]));
112318
+ if( pTerm==0
112319
+ && saved_nEq==saved_nSkip
112320
+ && saved_nEq+1<pProbe->nKeyCol
112321
+ && pProbe->aiRowEst[saved_nEq+1]>50
112322
+ ){
112323
+ LogEst nIter;
112324
+ pNew->u.btree.nEq++;
112325
+ pNew->u.btree.nSkip++;
112326
+ pNew->aLTerm[pNew->nLTerm++] = 0;
112327
+ pNew->wsFlags |= WHERE_SKIPSCAN;
112328
+ nIter = sqlite3LogEst(pProbe->aiRowEst[0]/pProbe->aiRowEst[saved_nEq+1]);
112329
+ whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nIter);
112330
+ }
112248112331
for(; rc==SQLITE_OK && pTerm!=0; pTerm = whereScanNext(&scan)){
112249112332
int nIn = 0;
112250112333
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
112251112334
int nRecValid = pBuilder->nRecValid;
112252112335
#endif
@@ -112278,12 +112361,14 @@
112278112361
}
112279112362
pNew->rRun += nIn;
112280112363
pNew->u.btree.nEq++;
112281112364
pNew->nOut = nRowEst + nInMul + nIn;
112282112365
}else if( pTerm->eOperator & (WO_EQ) ){
112283
- assert( (pNew->wsFlags & (WHERE_COLUMN_NULL|WHERE_COLUMN_IN))!=0
112284
- || nInMul==0 );
112366
+ assert(
112367
+ (pNew->wsFlags & (WHERE_COLUMN_NULL|WHERE_COLUMN_IN|WHERE_SKIPSCAN))!=0
112368
+ || nInMul==0
112369
+ );
112285112370
pNew->wsFlags |= WHERE_COLUMN_EQ;
112286112371
if( iCol<0
112287112372
|| (pProbe->onError!=OE_None && nInMul==0
112288112373
&& pNew->u.btree.nEq==pProbe->nKeyCol-1)
112289112374
){
@@ -112360,10 +112445,11 @@
112360112445
pBuilder->nRecValid = nRecValid;
112361112446
#endif
112362112447
}
112363112448
pNew->prereq = saved_prereq;
112364112449
pNew->u.btree.nEq = saved_nEq;
112450
+ pNew->u.btree.nSkip = saved_nSkip;
112365112451
pNew->wsFlags = saved_wsFlags;
112366112452
pNew->nOut = saved_nOut;
112367112453
pNew->nLTerm = saved_nLTerm;
112368112454
return rc;
112369112455
}
@@ -112506,10 +112592,11 @@
112506112592
WhereTerm *pWCEnd = pWC->a + pWC->nTerm;
112507112593
for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){
112508112594
if( pTerm->prereqRight & pNew->maskSelf ) continue;
112509112595
if( termCanDriveIndex(pTerm, pSrc, 0) ){
112510112596
pNew->u.btree.nEq = 1;
112597
+ pNew->u.btree.nSkip = 0;
112511112598
pNew->u.btree.pIndex = 0;
112512112599
pNew->nLTerm = 1;
112513112600
pNew->aLTerm[0] = pTerm;
112514112601
/* TUNING: One-time cost for computing the automatic index is
112515112602
** approximately 7*N*log2(N) where N is the number of rows in
@@ -112535,10 +112622,11 @@
112535112622
if( pProbe->pPartIdxWhere!=0
112536112623
&& !whereUsablePartialIndex(pNew->iTab, pWC, pProbe->pPartIdxWhere) ){
112537112624
continue; /* Partial index inappropriate for this query */
112538112625
}
112539112626
pNew->u.btree.nEq = 0;
112627
+ pNew->u.btree.nSkip = 0;
112540112628
pNew->nLTerm = 0;
112541112629
pNew->iSortIdx = 0;
112542112630
pNew->rSetup = 0;
112543112631
pNew->prereq = mExtra;
112544112632
pNew->nOut = rSize;
@@ -112620,11 +112708,12 @@
112620112708
/*
112621112709
** Add all WhereLoop objects for a table of the join identified by
112622112710
** pBuilder->pNew->iTab. That table is guaranteed to be a virtual table.
112623112711
*/
112624112712
static int whereLoopAddVirtual(
112625
- WhereLoopBuilder *pBuilder /* WHERE clause information */
112713
+ WhereLoopBuilder *pBuilder, /* WHERE clause information */
112714
+ Bitmask mExtra
112626112715
){
112627112716
WhereInfo *pWInfo; /* WHERE analysis context */
112628112717
Parse *pParse; /* The parsing context */
112629112718
WhereClause *pWC; /* The WHERE clause */
112630112719
struct SrcList_item *pSrc; /* The FROM clause term to search */
@@ -112710,11 +112799,11 @@
112710112799
pIdxInfo->estimatedCost = SQLITE_BIG_DBL / (double)2;
112711112800
pIdxInfo->estimatedRows = 25;
112712112801
rc = vtabBestIndex(pParse, pTab, pIdxInfo);
112713112802
if( rc ) goto whereLoopAddVtab_exit;
112714112803
pIdxCons = *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint;
112715
- pNew->prereq = 0;
112804
+ pNew->prereq = mExtra;
112716112805
mxTerm = -1;
112717112806
assert( pNew->nLSlot>=nConstraint );
112718112807
for(i=0; i<nConstraint; i++) pNew->aLTerm[i] = 0;
112719112808
pNew->u.vtab.omitMask = 0;
112720112809
for(i=0; i<nConstraint; i++, pIdxCons++){
@@ -112837,12 +112926,11 @@
112837112926
continue;
112838112927
}
112839112928
sCur.n = 0;
112840112929
#ifndef SQLITE_OMIT_VIRTUALTABLE
112841112930
if( IsVirtual(pItem->pTab) ){
112842
- rc = whereLoopAddVirtual(&sSubBuild);
112843
- for(i=0; i<sCur.n; i++) sCur.a[i].prereq |= mExtra;
112931
+ rc = whereLoopAddVirtual(&sSubBuild, mExtra);
112844112932
}else
112845112933
#endif
112846112934
{
112847112935
rc = whereLoopAddBtree(&sSubBuild, mExtra);
112848112936
}
@@ -112908,11 +112996,11 @@
112908112996
if( ((pItem->jointype|priorJoinType) & (JT_LEFT|JT_CROSS))!=0 ){
112909112997
mExtra = mPrior;
112910112998
}
112911112999
priorJoinType = pItem->jointype;
112912113000
if( IsVirtual(pItem->pTab) ){
112913
- rc = whereLoopAddVirtual(pBuilder);
113001
+ rc = whereLoopAddVirtual(pBuilder, mExtra);
112914113002
}else{
112915113003
rc = whereLoopAddBtree(pBuilder, mExtra);
112916113004
}
112917113005
if( rc==SQLITE_OK ){
112918113006
rc = whereLoopAddOr(pBuilder, mExtra);
@@ -113069,10 +113157,11 @@
113069113157
for(j=0; j<nColumn; j++){
113070113158
u8 bOnce; /* True to run the ORDER BY search loop */
113071113159
113072113160
/* Skip over == and IS NULL terms */
113073113161
if( j<pLoop->u.btree.nEq
113162
+ && pLoop->u.btree.nSkip==0
113074113163
&& ((i = pLoop->aLTerm[j]->eOperator) & (WO_EQ|WO_ISNULL))!=0
113075113164
){
113076113165
if( i & WO_ISNULL ){
113077113166
testcase( isOrderDistinct );
113078113167
isOrderDistinct = 0;
@@ -113494,10 +113583,11 @@
113494113583
if( pItem->zIndex ) return 0;
113495113584
iCur = pItem->iCursor;
113496113585
pWC = &pWInfo->sWC;
113497113586
pLoop = pBuilder->pNew;
113498113587
pLoop->wsFlags = 0;
113588
+ pLoop->u.btree.nSkip = 0;
113499113589
pTerm = findTerm(pWC, iCur, -1, 0, WO_EQ, 0);
113500113590
if( pTerm ){
113501113591
pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_IPK|WHERE_ONEROW;
113502113592
pLoop->aLTerm[0] = pTerm;
113503113593
pLoop->nLTerm = 1;
@@ -114037,10 +114127,11 @@
114037114127
notReady = codeOneLoopStart(pWInfo, ii, notReady);
114038114128
pWInfo->iContinue = pLevel->addrCont;
114039114129
}
114040114130
114041114131
/* Done. */
114132
+ VdbeNoopComment((v, "Begin WHERE-core"));
114042114133
return pWInfo;
114043114134
114044114135
/* Jump here if malloc fails */
114045114136
whereBeginError:
114046114137
if( pWInfo ){
@@ -114063,12 +114154,14 @@
114063114154
SrcList *pTabList = pWInfo->pTabList;
114064114155
sqlite3 *db = pParse->db;
114065114156
114066114157
/* Generate loop termination code.
114067114158
*/
114159
+ VdbeNoopComment((v, "End WHERE-core"));
114068114160
sqlite3ExprCacheClear(pParse);
114069114161
for(i=pWInfo->nLevel-1; i>=0; i--){
114162
+ int addr;
114070114163
pLevel = &pWInfo->a[i];
114071114164
pLoop = pLevel->pWLoop;
114072114165
sqlite3VdbeResolveLabel(v, pLevel->addrCont);
114073114166
if( pLevel->op!=OP_Noop ){
114074114167
sqlite3VdbeAddOp2(v, pLevel->op, pLevel->p1, pLevel->p2);
@@ -114084,12 +114177,17 @@
114084114177
sqlite3VdbeJumpHere(v, pIn->addrInTop-1);
114085114178
}
114086114179
sqlite3DbFree(db, pLevel->u.in.aInLoop);
114087114180
}
114088114181
sqlite3VdbeResolveLabel(v, pLevel->addrBrk);
114182
+ if( pLevel->addrSkip ){
114183
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrSkip);
114184
+ VdbeComment((v, "next skip-scan on %s", pLoop->u.btree.pIndex->zName));
114185
+ sqlite3VdbeJumpHere(v, pLevel->addrSkip);
114186
+ sqlite3VdbeJumpHere(v, pLevel->addrSkip-2);
114187
+ }
114089114188
if( pLevel->iLeftJoin ){
114090
- int addr;
114091114189
addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin);
114092114190
assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
114093114191
|| (pLoop->wsFlags & WHERE_INDEXED)!=0 );
114094114192
if( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 ){
114095114193
sqlite3VdbeAddOp1(v, OP_NullRow, pTabList->a[i].iCursor);
@@ -114102,11 +114200,11 @@
114102114200
}else{
114103114201
sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrFirst);
114104114202
}
114105114203
sqlite3VdbeJumpHere(v, addr);
114106114204
}
114107
- VdbeNoopComment((v, "End WHERE-Loop %d: %s", i,
114205
+ VdbeNoopComment((v, "End WHERE-loop%d: %s", i,
114108114206
pWInfo->pTabList->a[pLevel->iFrom].pTab->zName));
114109114207
}
114110114208
114111114209
/* The "break" point is here, just past the end of the outer loop.
114112114210
** Set it.
@@ -123687,10 +123785,14 @@
123687123785
char *aDoclist; /* Pointer to doclist buffer */
123688123786
int nDoclist; /* Size of aDoclist[] in bytes */
123689123787
};
123690123788
123691123789
SQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table*,int,int);
123790
+
123791
+#define fts3GetVarint32(p, piVal) ( \
123792
+ (*(u8*)(p)&0x80) ? sqlite3Fts3GetVarint32(p, piVal) : (*piVal=*(u8*)(p), 1) \
123793
+)
123692123794
123693123795
/* fts3.c */
123694123796
SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64);
123695123797
SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
123696123798
SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);
@@ -123795,36 +123897,60 @@
123795123897
q[-1] &= 0x7f; /* turn off high bit in final byte */
123796123898
assert( q - (unsigned char *)p <= FTS3_VARINT_MAX );
123797123899
return (int) (q - (unsigned char *)p);
123798123900
}
123799123901
123902
+#define GETVARINT_STEP(v, ptr, shift, mask1, mask2, var, ret) \
123903
+ v = (v & mask1) | ( (*ptr++) << shift ); \
123904
+ if( (v & mask2)==0 ){ var = v; return ret; }
123905
+
123800123906
/*
123801123907
** Read a 64-bit variable-length integer from memory starting at p[0].
123802123908
** Return the number of bytes read, or 0 on error.
123803123909
** The value is stored in *v.
123804123910
*/
123805123911
SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *p, sqlite_int64 *v){
123806
- const unsigned char *q = (const unsigned char *) p;
123807
- sqlite_uint64 x = 0, y = 1;
123808
- while( (*q&0x80)==0x80 && q-(unsigned char *)p<FTS3_VARINT_MAX ){
123809
- x += y * (*q++ & 0x7f);
123810
- y <<= 7;
123811
- }
123812
- x += y * (*q++);
123813
- *v = (sqlite_int64) x;
123814
- return (int) (q - (unsigned char *)p);
123912
+ const char *pStart = p;
123913
+ u32 a;
123914
+ u64 b;
123915
+ int shift;
123916
+
123917
+ GETVARINT_STEP(a, p, 0, 0x00, 0x80, *v, 1);
123918
+ GETVARINT_STEP(a, p, 7, 0x7F, 0x4000, *v, 2);
123919
+ GETVARINT_STEP(a, p, 14, 0x3FFF, 0x200000, *v, 3);
123920
+ GETVARINT_STEP(a, p, 21, 0x1FFFFF, 0x10000000, *v, 4);
123921
+ b = (a & 0x0FFFFFFF );
123922
+
123923
+ for(shift=28; shift<=63; shift+=7){
123924
+ u64 c = *p++;
123925
+ b += (c&0x7F) << shift;
123926
+ if( (c & 0x80)==0 ) break;
123927
+ }
123928
+ *v = b;
123929
+ return p - pStart;
123815123930
}
123816123931
123817123932
/*
123818123933
** Similar to sqlite3Fts3GetVarint(), except that the output is truncated to a
123819123934
** 32-bit integer before it is returned.
123820123935
*/
123821123936
SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *p, int *pi){
123822
- sqlite_int64 i;
123823
- int ret = sqlite3Fts3GetVarint(p, &i);
123824
- *pi = (int) i;
123825
- return ret;
123937
+ u32 a;
123938
+
123939
+#ifndef fts3GetVarint32
123940
+ GETVARINT_STEP(a, p, 0, 0x00, 0x80, *pi, 1);
123941
+#else
123942
+ a = (*p++);
123943
+ assert( a & 0x80 );
123944
+#endif
123945
+
123946
+ GETVARINT_STEP(a, p, 7, 0x7F, 0x4000, *pi, 2);
123947
+ GETVARINT_STEP(a, p, 14, 0x3FFF, 0x200000, *pi, 3);
123948
+ GETVARINT_STEP(a, p, 21, 0x1FFFFF, 0x10000000, *pi, 4);
123949
+ a = (a & 0x0FFFFFFF );
123950
+ *pi = (int)(a | ((u32)(*p & 0x0F) << 28));
123951
+ return 5;
123826123952
}
123827123953
123828123954
/*
123829123955
** Return the number of bytes required to encode v as a varint
123830123956
*/
@@ -125180,14 +125306,14 @@
125180125306
int nBuffer; /* Total term size */
125181125307
125182125308
/* Load the next term on the node into zBuffer. Use realloc() to expand
125183125309
** the size of zBuffer if required. */
125184125310
if( !isFirstTerm ){
125185
- zCsr += sqlite3Fts3GetVarint32(zCsr, &nPrefix);
125311
+ zCsr += fts3GetVarint32(zCsr, &nPrefix);
125186125312
}
125187125313
isFirstTerm = 0;
125188
- zCsr += sqlite3Fts3GetVarint32(zCsr, &nSuffix);
125314
+ zCsr += fts3GetVarint32(zCsr, &nSuffix);
125189125315
125190125316
if( nPrefix<0 || nSuffix<0 || &zCsr[nSuffix]>zEnd ){
125191125317
rc = FTS_CORRUPT_VTAB;
125192125318
goto finish_scan;
125193125319
}
@@ -125271,11 +125397,11 @@
125271125397
int rc; /* Return code */
125272125398
int iHeight; /* Height of this node in tree */
125273125399
125274125400
assert( piLeaf || piLeaf2 );
125275125401
125276
- sqlite3Fts3GetVarint32(zNode, &iHeight);
125402
+ fts3GetVarint32(zNode, &iHeight);
125277125403
rc = fts3ScanInteriorNode(zTerm, nTerm, zNode, nNode, piLeaf, piLeaf2);
125278125404
assert( !piLeaf2 || !piLeaf || rc!=SQLITE_OK || (*piLeaf<=*piLeaf2) );
125279125405
125280125406
if( rc==SQLITE_OK && iHeight>1 ){
125281125407
char *zBlob = 0; /* Blob read from %_segments table */
@@ -125473,15 +125599,15 @@
125473125599
125474125600
while( *p1 || *p2 ){
125475125601
int iCol1; /* The current column index in pp1 */
125476125602
int iCol2; /* The current column index in pp2 */
125477125603
125478
- if( *p1==POS_COLUMN ) sqlite3Fts3GetVarint32(&p1[1], &iCol1);
125604
+ if( *p1==POS_COLUMN ) fts3GetVarint32(&p1[1], &iCol1);
125479125605
else if( *p1==POS_END ) iCol1 = POSITION_LIST_END;
125480125606
else iCol1 = 0;
125481125607
125482
- if( *p2==POS_COLUMN ) sqlite3Fts3GetVarint32(&p2[1], &iCol2);
125608
+ if( *p2==POS_COLUMN ) fts3GetVarint32(&p2[1], &iCol2);
125483125609
else if( *p2==POS_END ) iCol2 = POSITION_LIST_END;
125484125610
else iCol2 = 0;
125485125611
125486125612
if( iCol1==iCol2 ){
125487125613
sqlite3_int64 i1 = 0; /* Last position from pp1 */
@@ -125570,15 +125696,15 @@
125570125696
assert( isSaveLeft==0 || isExact==0 );
125571125697
125572125698
assert( p!=0 && *p1!=0 && *p2!=0 );
125573125699
if( *p1==POS_COLUMN ){
125574125700
p1++;
125575
- p1 += sqlite3Fts3GetVarint32(p1, &iCol1);
125701
+ p1 += fts3GetVarint32(p1, &iCol1);
125576125702
}
125577125703
if( *p2==POS_COLUMN ){
125578125704
p2++;
125579
- p2 += sqlite3Fts3GetVarint32(p2, &iCol2);
125705
+ p2 += fts3GetVarint32(p2, &iCol2);
125580125706
}
125581125707
125582125708
while( 1 ){
125583125709
if( iCol1==iCol2 ){
125584125710
char *pSave = p;
@@ -125624,13 +125750,13 @@
125624125750
fts3ColumnlistCopy(0, &p2);
125625125751
assert( (*p1&0xFE)==0 && (*p2&0xFE)==0 );
125626125752
if( 0==*p1 || 0==*p2 ) break;
125627125753
125628125754
p1++;
125629
- p1 += sqlite3Fts3GetVarint32(p1, &iCol1);
125755
+ p1 += fts3GetVarint32(p1, &iCol1);
125630125756
p2++;
125631
- p2 += sqlite3Fts3GetVarint32(p2, &iCol2);
125757
+ p2 += fts3GetVarint32(p2, &iCol2);
125632125758
}
125633125759
125634125760
/* Advance pointer p1 or p2 (whichever corresponds to the smaller of
125635125761
** iCol1 and iCol2) so that it points to either the 0x00 that marks the
125636125762
** end of the position list, or the 0x01 that precedes the next
@@ -125638,16 +125764,16 @@
125638125764
*/
125639125765
else if( iCol1<iCol2 ){
125640125766
fts3ColumnlistCopy(0, &p1);
125641125767
if( 0==*p1 ) break;
125642125768
p1++;
125643
- p1 += sqlite3Fts3GetVarint32(p1, &iCol1);
125769
+ p1 += fts3GetVarint32(p1, &iCol1);
125644125770
}else{
125645125771
fts3ColumnlistCopy(0, &p2);
125646125772
if( 0==*p2 ) break;
125647125773
p2++;
125648
- p2 += sqlite3Fts3GetVarint32(p2, &iCol2);
125774
+ p2 += fts3GetVarint32(p2, &iCol2);
125649125775
}
125650125776
}
125651125777
125652125778
fts3PoslistCopy(0, &p2);
125653125779
fts3PoslistCopy(0, &p1);
@@ -128810,11 +128936,11 @@
128810128936
*/
128811128937
pExpr->aMI[iCol*3 + 1] += iCnt;
128812128938
pExpr->aMI[iCol*3 + 2] += (iCnt>0);
128813128939
if( *p==0x00 ) break;
128814128940
p++;
128815
- p += sqlite3Fts3GetVarint32(p, &iCol);
128941
+ p += fts3GetVarint32(p, &iCol);
128816128942
}
128817128943
}
128818128944
128819128945
fts3EvalUpdateCounts(pExpr->pLeft);
128820128946
fts3EvalUpdateCounts(pExpr->pRight);
@@ -129111,19 +129237,19 @@
129111129237
}
129112129238
if( pIter==0 ) return SQLITE_OK;
129113129239
129114129240
if( *pIter==0x01 ){
129115129241
pIter++;
129116
- pIter += sqlite3Fts3GetVarint32(pIter, &iThis);
129242
+ pIter += fts3GetVarint32(pIter, &iThis);
129117129243
}else{
129118129244
iThis = 0;
129119129245
}
129120129246
while( iThis<iCol ){
129121129247
fts3ColumnlistCopy(0, &pIter);
129122129248
if( *pIter==0x00 ) return 0;
129123129249
pIter++;
129124
- pIter += sqlite3Fts3GetVarint32(pIter, &iThis);
129250
+ pIter += fts3GetVarint32(pIter, &iThis);
129125129251
}
129126129252
129127129253
*ppOut = ((iCol==iThis)?pIter:0);
129128129254
return SQLITE_OK;
129129129255
}
@@ -134568,12 +134694,12 @@
134568134694
rc = fts3SegReaderRequire(pReader, pNext, FTS3_VARINT_MAX*2);
134569134695
if( rc!=SQLITE_OK ) return rc;
134570134696
134571134697
/* Because of the FTS3_NODE_PADDING bytes of padding, the following is
134572134698
** safe (no risk of overread) even if the node data is corrupted. */
134573
- pNext += sqlite3Fts3GetVarint32(pNext, &nPrefix);
134574
- pNext += sqlite3Fts3GetVarint32(pNext, &nSuffix);
134699
+ pNext += fts3GetVarint32(pNext, &nPrefix);
134700
+ pNext += fts3GetVarint32(pNext, &nSuffix);
134575134701
if( nPrefix<0 || nSuffix<=0
134576134702
|| &pNext[nSuffix]>&pReader->aNode[pReader->nNode]
134577134703
){
134578134704
return FTS_CORRUPT_VTAB;
134579134705
}
@@ -134592,11 +134718,11 @@
134592134718
if( rc!=SQLITE_OK ) return rc;
134593134719
134594134720
memcpy(&pReader->zTerm[nPrefix], pNext, nSuffix);
134595134721
pReader->nTerm = nPrefix+nSuffix;
134596134722
pNext += nSuffix;
134597
- pNext += sqlite3Fts3GetVarint32(pNext, &pReader->nDoclist);
134723
+ pNext += fts3GetVarint32(pNext, &pReader->nDoclist);
134598134724
pReader->aDoclist = pNext;
134599134725
pReader->pOffsetList = 0;
134600134726
134601134727
/* Check that the doclist does not appear to extend past the end of the
134602134728
** b-tree node. And that the final byte of the doclist is 0x00. If either
@@ -135753,11 +135879,11 @@
135753135879
pList = p;
135754135880
if( nList==0 ){
135755135881
break;
135756135882
}
135757135883
p = &pList[1];
135758
- p += sqlite3Fts3GetVarint32(p, &iCurrent);
135884
+ p += fts3GetVarint32(p, &iCurrent);
135759135885
}
135760135886
135761135887
if( bZero && &pList[nList]!=pEnd ){
135762135888
memset(&pList[nList], 0, pEnd - &pList[nList]);
135763135889
}
@@ -136718,21 +136844,21 @@
136718136844
if( p->iOff>=p->nNode ){
136719136845
/* EOF */
136720136846
p->aNode = 0;
136721136847
}else{
136722136848
if( bFirst==0 ){
136723
- p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &nPrefix);
136849
+ p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nPrefix);
136724136850
}
136725
- p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &nSuffix);
136851
+ p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nSuffix);
136726136852
136727136853
blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);
136728136854
if( rc==SQLITE_OK ){
136729136855
memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix);
136730136856
p->term.n = nPrefix+nSuffix;
136731136857
p->iOff += nSuffix;
136732136858
if( p->iChild==0 ){
136733
- p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist);
136859
+ p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist);
136734136860
p->aDoclist = &p->aNode[p->iOff];
136735136861
p->iOff += p->nDoclist;
136736136862
}
136737136863
}
136738136864
}
@@ -137780,11 +137906,11 @@
137780137906
while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
137781137907
while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
137782137908
137783137909
pHint->n = i;
137784137910
i += sqlite3Fts3GetVarint(&pHint->a[i], piAbsLevel);
137785
- i += sqlite3Fts3GetVarint32(&pHint->a[i], pnInput);
137911
+ i += fts3GetVarint32(&pHint->a[i], pnInput);
137786137912
if( i!=nHint ) return SQLITE_CORRUPT_VTAB;
137787137913
137788137914
return SQLITE_OK;
137789137915
}
137790137916
@@ -138773,11 +138899,11 @@
138773138899
** After it returns, *piPos contains the value of the next element of the
138774138900
** list and *pp is advanced to the following varint.
138775138901
*/
138776138902
static void fts3GetDeltaPosition(char **pp, int *piPos){
138777138903
int iVal;
138778
- *pp += sqlite3Fts3GetVarint32(*pp, &iVal);
138904
+ *pp += fts3GetVarint32(*pp, &iVal);
138779138905
*piPos += (iVal-2);
138780138906
}
138781138907
138782138908
/*
138783138909
** Helper function for fts3ExprIterate() (see below).
138784138910
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -135,11 +135,11 @@
135 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
136 ** [sqlite_version()] and [sqlite_source_id()].
137 */
138 #define SQLITE_VERSION "3.8.2"
139 #define SQLITE_VERSION_NUMBER 3008002
140 #define SQLITE_SOURCE_ID "2013-11-12 15:33:40 0f924c6ef6cf2ac5a61aafa8dd8e3309b3970499"
141
142 /*
143 ** CAPI3REF: Run-Time Library Version Numbers
144 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
145 **
@@ -9237,11 +9237,10 @@
9237 SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*);
9238 SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int);
9239 SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*);
9240 #ifdef SQLITE_DEBUG
9241 SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *, int);
9242 SQLITE_PRIVATE void sqlite3VdbeTrace(Vdbe*,FILE*);
9243 #endif
9244 SQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe*);
9245 SQLITE_PRIVATE void sqlite3VdbeRewind(Vdbe*);
9246 SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*);
9247 SQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe*,int);
@@ -10304,10 +10303,11 @@
10304 #define SQLITE_PreferBuiltin 0x00200000 /* Preference to built-in funcs */
10305 #define SQLITE_LoadExtension 0x00400000 /* Enable load_extension */
10306 #define SQLITE_EnableTrigger 0x00800000 /* True to enable triggers */
10307 #define SQLITE_DeferFKs 0x01000000 /* Defer all FK constraints */
10308 #define SQLITE_QueryOnly 0x02000000 /* Disable database changes */
 
10309
10310
10311 /*
10312 ** Bits of the sqlite3.dbOptFlags field that are used by the
10313 ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
@@ -13700,13 +13700,10 @@
13700 i64 nFkConstraint; /* Number of imm. FK constraints this VM */
13701 i64 nStmtDefCons; /* Number of def. constraints when stmt started */
13702 i64 nStmtDefImmCons; /* Number of def. imm constraints when stmt started */
13703 char *zSql; /* Text of the SQL statement that generated this */
13704 void *pFree; /* Free this when deleting the vdbe */
13705 #ifdef SQLITE_DEBUG
13706 FILE *trace; /* Write an execution trace here, if not NULL */
13707 #endif
13708 #ifdef SQLITE_ENABLE_TREE_EXPLAIN
13709 Explain *pExplain; /* The explainer */
13710 char *zExplain; /* Explanation of data structures */
13711 #endif
13712 VdbeFrame *pFrame; /* Parent frame */
@@ -61013,19 +61010,10 @@
61013 pA->zSql = pB->zSql;
61014 pB->zSql = zTmp;
61015 pB->isPrepareV2 = pA->isPrepareV2;
61016 }
61017
61018 #ifdef SQLITE_DEBUG
61019 /*
61020 ** Turn tracing on or off
61021 */
61022 SQLITE_PRIVATE void sqlite3VdbeTrace(Vdbe *p, FILE *trace){
61023 p->trace = trace;
61024 }
61025 #endif
61026
61027 /*
61028 ** Resize the Vdbe.aOp array so that it is at least one op larger than
61029 ** it was.
61030 **
61031 ** If an out-of-memory error occurs while resizing the array, return
@@ -61917,11 +61905,11 @@
61917 assert( i<nTemp );
61918 break;
61919 }
61920 case P4_COLLSEQ: {
61921 CollSeq *pColl = pOp->p4.pColl;
61922 sqlite3_snprintf(nTemp, zTemp, "collseq(%.20s)", pColl->zName);
61923 break;
61924 }
61925 case P4_FUNCDEF: {
61926 FuncDef *pDef = pOp->p4.pFunc;
61927 sqlite3_snprintf(nTemp, zTemp, "%s(%d)", pDef->zName, pDef->nArg);
@@ -62350,19 +62338,21 @@
62350 #ifdef SQLITE_DEBUG
62351 /*
62352 ** Print the SQL that was used to generate a VDBE program.
62353 */
62354 SQLITE_PRIVATE void sqlite3VdbePrintSql(Vdbe *p){
62355 int nOp = p->nOp;
62356 VdbeOp *pOp;
62357 if( nOp<1 ) return;
62358 pOp = &p->aOp[0];
62359 if( pOp->opcode==OP_Trace && pOp->p4.z!=0 ){
62360 const char *z = pOp->p4.z;
62361 while( sqlite3Isspace(*z) ) z++;
62362 printf("SQL: [%s]\n", z);
62363 }
 
 
62364 }
62365 #endif
62366
62367 #if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)
62368 /*
@@ -66366,41 +66356,40 @@
66366
66367 #ifdef SQLITE_DEBUG
66368 /*
66369 ** Print the value of a register for tracing purposes:
66370 */
66371 static void memTracePrint(FILE *out, Mem *p){
66372 if( p->flags & MEM_Invalid ){
66373 fprintf(out, " undefined");
66374 }else if( p->flags & MEM_Null ){
66375 fprintf(out, " NULL");
66376 }else if( (p->flags & (MEM_Int|MEM_Str))==(MEM_Int|MEM_Str) ){
66377 fprintf(out, " si:%lld", p->u.i);
66378 }else if( p->flags & MEM_Int ){
66379 fprintf(out, " i:%lld", p->u.i);
66380 #ifndef SQLITE_OMIT_FLOATING_POINT
66381 }else if( p->flags & MEM_Real ){
66382 fprintf(out, " r:%g", p->r);
66383 #endif
66384 }else if( p->flags & MEM_RowSet ){
66385 fprintf(out, " (rowset)");
66386 }else{
66387 char zBuf[200];
66388 sqlite3VdbeMemPrettyPrint(p, zBuf);
66389 fprintf(out, " ");
66390 fprintf(out, "%s", zBuf);
66391 }
66392 }
66393 static void registerTrace(FILE *out, int iReg, Mem *p){
66394 fprintf(out, "REG[%d] = ", iReg);
66395 memTracePrint(out, p);
66396 fprintf(out, "\n");
66397 }
66398 #endif
66399
66400 #ifdef SQLITE_DEBUG
66401 # define REGISTER_TRACE(R,M) if(p->trace)registerTrace(p->trace,R,M)
66402 #else
66403 # define REGISTER_TRACE(R,M)
66404 #endif
66405
66406
@@ -67051,17 +67040,32 @@
67051 }
67052 }
67053 #endif
67054 #ifdef SQLITE_DEBUG
67055 sqlite3BeginBenignMalloc();
67056 if( p->pc==0 && (p->db->flags & SQLITE_VdbeListing)!=0 ){
 
 
67057 int i;
67058 printf("VDBE Program Listing:\n");
67059 sqlite3VdbePrintSql(p);
67060 for(i=0; i<p->nOp; i++){
67061 sqlite3VdbePrintOp(stdout, i, &aOp[i]);
 
 
 
67062 }
 
 
 
 
 
 
 
 
 
 
67063 }
67064 sqlite3EndBenignMalloc();
67065 #endif
67066 for(pc=p->pc; rc==SQLITE_OK; pc++){
67067 assert( pc>=0 && pc<p->nOp );
@@ -67074,16 +67078,12 @@
67074 pOp = &aOp[pc];
67075
67076 /* Only allow tracing if SQLITE_DEBUG is defined.
67077 */
67078 #ifdef SQLITE_DEBUG
67079 if( p->trace ){
67080 if( pc==0 ){
67081 printf("VDBE Execution Trace:\n");
67082 sqlite3VdbePrintSql(p);
67083 }
67084 sqlite3VdbePrintOp(p->trace, pc, pOp);
67085 }
67086 #endif
67087
67088
67089 /* Check to see if we need to simulate an interrupt. This only happens
@@ -67210,19 +67210,16 @@
67210 ** sqlite3VdbeExec() or since last time the progress callback was called).
67211 ** If the progress callback returns non-zero, exit the virtual machine with
67212 ** a return code SQLITE_ABORT.
67213 */
67214 if( db->xProgress!=0 && nVmStep>=nProgressLimit ){
67215 int prc;
67216 prc = db->xProgress(db->pProgressArg);
67217 if( prc!=0 ){
67218 rc = SQLITE_INTERRUPT;
67219 goto vdbe_error_halt;
67220 }
67221 if( db->xProgress!=0 ){
67222 nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps);
67223 }
67224 }
67225 #endif
67226
67227 break;
67228 }
@@ -67654,10 +67651,22 @@
67654 int i;
67655 #endif /* local variables moved into u.ag */
67656 assert( p->nResColumn==pOp->p2 );
67657 assert( pOp->p1>0 );
67658 assert( pOp->p1+pOp->p2<=(p->nMem-p->nCursor)+1 );
 
 
 
 
 
 
 
 
 
 
 
 
67659
67660 /* If this statement has violated immediate foreign key constraints, do
67661 ** not return the number of rows modified. And do not RELEASE the statement
67662 ** transaction. It needs to be rolled back. */
67663 if( SQLITE_OK!=(rc = sqlite3VdbeCheckFk(p, 0)) ){
@@ -72862,17 +72871,17 @@
72862 */
72863 #ifndef NDEBUG
72864 assert( pc>=-1 && pc<p->nOp );
72865
72866 #ifdef SQLITE_DEBUG
72867 if( p->trace ){
72868 if( rc!=0 ) fprintf(p->trace,"rc=%d\n",rc);
72869 if( pOp->opflags & (OPFLG_OUT2_PRERELEASE|OPFLG_OUT2) ){
72870 registerTrace(p->trace, pOp->p2, &aMem[pOp->p2]);
72871 }
72872 if( pOp->opflags & OPFLG_OUT3 ){
72873 registerTrace(p->trace, pOp->p3, &aMem[pOp->p3]);
72874 }
72875 }
72876 #endif /* SQLITE_DEBUG */
72877 #endif /* NDEBUG */
72878 } /* The end of the for(;;) loop the loops through opcodes */
@@ -83106,14 +83115,16 @@
83106 }
83107 pTable = sqlite3FindTable(pInfo->db, argv[0], pInfo->zDatabase);
83108 if( pTable==0 ){
83109 return 0;
83110 }
83111 if( argv[1] ){
83112 pIndex = sqlite3FindIndex(pInfo->db, argv[1], pInfo->zDatabase);
83113 }else{
83114 pIndex = 0;
 
 
 
 
83115 }
83116 z = argv[2];
83117
83118 if( pIndex ){
83119 decodeIntArray((char*)z, pIndex->nKeyCol+1, pIndex->aiRowEst, pIndex);
@@ -84467,14 +84478,10 @@
84467
84468
84469 /* Get the VDBE program ready for execution
84470 */
84471 if( v && ALWAYS(pParse->nErr==0) && !db->mallocFailed ){
84472 #ifdef SQLITE_DEBUG
84473 FILE *trace = (db->flags & SQLITE_VdbeTrace)!=0 ? stdout : 0;
84474 sqlite3VdbeTrace(v, trace);
84475 #endif
84476 assert( pParse->iCacheLevel==0 ); /* Disables and re-enables match */
84477 /* A minimum of one cursor is required if autoincrement is used
84478 * See ticket [a696379c1f08866] */
84479 if( pParse->pAinc!=0 && pParse->nTab==0 ) pParse->nTab = 1;
84480 sqlite3VdbeMakeReady(v, pParse);
@@ -96680,10 +96687,14 @@
96680 /* iArg: */ SQLITE_VdbeAddopTrace },
96681 { /* zName: */ "vdbe_debug",
96682 /* ePragTyp: */ PragTyp_FLAG,
96683 /* ePragFlag: */ 0,
96684 /* iArg: */ SQLITE_SqlTrace|SQLITE_VdbeListing|SQLITE_VdbeTrace },
 
 
 
 
96685 { /* zName: */ "vdbe_listing",
96686 /* ePragTyp: */ PragTyp_FLAG,
96687 /* ePragFlag: */ 0,
96688 /* iArg: */ SQLITE_VdbeListing },
96689 { /* zName: */ "vdbe_trace",
@@ -96707,11 +96718,11 @@
96707 /* ePragTyp: */ PragTyp_FLAG,
96708 /* ePragFlag: */ 0,
96709 /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
96710 #endif
96711 };
96712 /* Number of pragmas: 56 on by default, 68 total. */
96713 /* End of the automatically generated pragma table.
96714 ***************************************************************************/
96715
96716 /*
96717 ** Interpret the given string as a safety level. Return 0 for OFF,
@@ -107929,11 +107940,28 @@
107929 ** generating the code that loops through a table looking for applicable
107930 ** rows. Indices are selected and used to speed the search when doing
107931 ** so is applicable. Because this module is responsible for selecting
107932 ** indices, you might also think of this module as the "query optimizer".
107933 */
107934
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107935
107936 /*
107937 ** Trace output macros
107938 */
107939 #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
@@ -107981,10 +108009,11 @@
107981 int iLeftJoin; /* Memory cell used to implement LEFT OUTER JOIN */
107982 int iTabCur; /* The VDBE cursor used to access the table */
107983 int iIdxCur; /* The VDBE cursor used to access pIdx */
107984 int addrBrk; /* Jump here to break out of the loop */
107985 int addrNxt; /* Jump here to start the next IN combination */
 
107986 int addrCont; /* Jump here to continue with the next loop cycle */
107987 int addrFirst; /* First instruction of interior of the loop */
107988 int addrBody; /* Beginning of the body of this loop */
107989 u8 iFrom; /* Which entry in the FROM clause */
107990 u8 op, p5; /* Opcode and P5 of the opcode that ends the loop */
@@ -108030,11 +108059,11 @@
108030 LogEst rRun; /* Cost of running each loop */
108031 LogEst nOut; /* Estimated number of output rows */
108032 union {
108033 struct { /* Information for internal btree tables */
108034 u16 nEq; /* Number of equality constraints */
108035 u16 nSkip; /* Number of initial index columns skipped */
108036 Index *pIndex; /* Index used, or NULL */
108037 } btree;
108038 struct { /* Information for virtual tables */
108039 int idxNum; /* Index number */
108040 u8 needFree; /* True if sqlite3_free(idxStr) is needed */
@@ -108371,10 +108400,14 @@
108371 #define WHERE_VIRTUALTABLE 0x00000400 /* WhereLoop.u.vtab is valid */
108372 #define WHERE_IN_ABLE 0x00000800 /* Able to support an IN operator */
108373 #define WHERE_ONEROW 0x00001000 /* Selects no more than one row */
108374 #define WHERE_MULTI_OR 0x00002000 /* OR using multiple indices */
108375 #define WHERE_AUTO_INDEX 0x00004000 /* Uses an ephemeral index */
 
 
 
 
108376
108377 /*
108378 ** Return the estimated number of output rows from a WHERE clause
108379 */
108380 SQLITE_PRIVATE u64 sqlite3WhereOutputRowCount(WhereInfo *pWInfo){
@@ -110775,11 +110808,11 @@
110775 return iReg;
110776 }
110777
110778 /*
110779 ** Generate code that will evaluate all == and IN constraints for an
110780 ** index.
110781 **
110782 ** For example, consider table t1(a,b,c,d,e,f) with index i1(a,b,c).
110783 ** Suppose the WHERE clause is this: a==5 AND b IN (1,2,3) AND c>5 AND c<10
110784 ** The index has as many as three equality constraints, but in this
110785 ** example, the third "c" value is an inequality. So only two
@@ -110790,13 +110823,19 @@
110790 ** In the example above nEq==2. But this subroutine works for any value
110791 ** of nEq including 0. If nEq==0, this routine is nearly a no-op.
110792 ** The only thing it does is allocate the pLevel->iMem memory cell and
110793 ** compute the affinity string.
110794 **
110795 ** This routine always allocates at least one memory cell and returns
110796 ** the index of that memory cell. The code that
110797 ** calls this routine will use that memory cell to store the termination
 
 
 
 
 
 
110798 ** key value of the loop. If one or more IN operators appear, then
110799 ** this routine allocates an additional nEq memory cells for internal
110800 ** use.
110801 **
110802 ** Before returning, *pzAff is set to point to a buffer containing a
@@ -110819,11 +110858,12 @@
110819 WhereLevel *pLevel, /* Which nested loop of the FROM we are coding */
110820 int bRev, /* Reverse the order of IN operators */
110821 int nExtraReg, /* Number of extra registers to allocate */
110822 char **pzAff /* OUT: Set to point to affinity string */
110823 ){
110824 int nEq; /* The number of == or IN constraints to code */
 
110825 Vdbe *v = pParse->pVdbe; /* The vm under construction */
110826 Index *pIdx; /* The index being used for this loop */
110827 WhereTerm *pTerm; /* A single constraint term */
110828 WhereLoop *pLoop; /* The WhereLoop object */
110829 int j; /* Loop counter */
@@ -110833,10 +110873,11 @@
110833
110834 /* This module is only called on query plans that use an index. */
110835 pLoop = pLevel->pWLoop;
110836 assert( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 );
110837 nEq = pLoop->u.btree.nEq;
 
110838 pIdx = pLoop->u.btree.pIndex;
110839 assert( pIdx!=0 );
110840
110841 /* Figure out how many memory cells we will need then allocate them.
110842 */
@@ -110846,19 +110887,34 @@
110846
110847 zAff = sqlite3DbStrDup(pParse->db, sqlite3IndexAffinityStr(v, pIdx));
110848 if( !zAff ){
110849 pParse->db->mallocFailed = 1;
110850 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110851
110852 /* Evaluate the equality constraints
110853 */
110854 assert( zAff==0 || (int)strlen(zAff)>=nEq );
110855 for(j=0; j<nEq; j++){
110856 int r1;
110857 pTerm = pLoop->aLTerm[j];
110858 assert( pTerm!=0 );
110859 /* The following true for indices with redundant columns.
110860 ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */
110861 testcase( (pTerm->wtFlags & TERM_CODED)!=0 );
110862 testcase( pTerm->wtFlags & TERM_VIRTUAL );
110863 r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, regBase+j);
110864 if( r1!=regBase+j ){
@@ -110928,11 +110984,12 @@
110928 ** It is the responsibility of the caller to free the buffer when it is
110929 ** no longer required.
110930 */
110931 static char *explainIndexRange(sqlite3 *db, WhereLoop *pLoop, Table *pTab){
110932 Index *pIndex = pLoop->u.btree.pIndex;
110933 int nEq = pLoop->u.btree.nEq;
 
110934 int i, j;
110935 Column *aCol = pTab->aCol;
110936 i16 *aiColumn = pIndex->aiColumn;
110937 StrAccum txt;
110938
@@ -110942,11 +110999,18 @@
110942 sqlite3StrAccumInit(&txt, 0, 0, SQLITE_MAX_LENGTH);
110943 txt.db = db;
110944 sqlite3StrAccumAppend(&txt, " (", 2);
110945 for(i=0; i<nEq; i++){
110946 char *z = (i==pIndex->nKeyCol ) ? "rowid" : aCol[aiColumn[i]].zName;
110947 explainAppendTerm(&txt, i, z, "=");
 
 
 
 
 
 
 
110948 }
110949
110950 j = i;
110951 if( pLoop->wsFlags&WHERE_BTM_LIMIT ){
110952 char *z = (j==pIndex->nKeyCol ) ? "rowid" : aCol[aiColumn[j]].zName;
@@ -110972,11 +111036,14 @@
110972 WhereLevel *pLevel, /* Scan to write OP_Explain opcode for */
110973 int iLevel, /* Value for "level" column of output */
110974 int iFrom, /* Value for "from" column of output */
110975 u16 wctrlFlags /* Flags passed to sqlite3WhereBegin() */
110976 ){
110977 if( pParse->explain==2 ){
 
 
 
110978 struct SrcList_item *pItem = &pTabList->a[pLevel->iFrom];
110979 Vdbe *v = pParse->pVdbe; /* VM being constructed */
110980 sqlite3 *db = pParse->db; /* Database handle */
110981 char *zMsg; /* Text to add to EQP output */
110982 int iId = pParse->iSelectId; /* Select id (left-most output column) */
@@ -111078,11 +111145,11 @@
111078 iCur = pTabItem->iCursor;
111079 pLevel->notReady = notReady & ~getMask(&pWInfo->sMaskSet, iCur);
111080 bRev = (pWInfo->revMask>>iLevel)&1;
111081 omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0
111082 && (pWInfo->wctrlFlags & WHERE_FORCE_TABLE)==0;
111083 VdbeNoopComment((v, "Begin WHERE-Loop %d: %s", iLevel,pTabItem->pTab->zName));
111084
111085 /* Create labels for the "break" and "continue" instructions
111086 ** for the current loop. Jump to addrBrk to break out of a loop.
111087 ** Jump to cont to go immediately to the next iteration of the
111088 ** loop.
@@ -111305,12 +111372,12 @@
111305 static const u8 aEndOp[] = {
111306 OP_Noop, /* 0: (!end_constraints) */
111307 OP_IdxGE, /* 1: (end_constraints && !bRev) */
111308 OP_IdxLT /* 2: (end_constraints && bRev) */
111309 };
111310 int nEq = pLoop->u.btree.nEq; /* Number of == or IN terms */
111311 int isMinQuery = 0; /* If this is an optimized SELECT min(x).. */
111312 int regBase; /* Base register holding constraint values */
111313 int r1; /* Temp register */
111314 WhereTerm *pRangeStart = 0; /* Inequality constraint at range start */
111315 WhereTerm *pRangeEnd = 0; /* Inequality constraint at range end */
111316 int startEq; /* True if range start uses ==, >= or <= */
@@ -111324,10 +111391,11 @@
111324 char *zStartAff; /* Affinity for start of range constraint */
111325 char *zEndAff; /* Affinity for end of range constraint */
111326
111327 pIdx = pLoop->u.btree.pIndex;
111328 iIdxCur = pLevel->iIdxCur;
 
111329
111330 /* If this loop satisfies a sort order (pOrderBy) request that
111331 ** was passed to this function to implement a "SELECT min(x) ..."
111332 ** query, then the caller will only allow the loop to run for
111333 ** a single iteration. This means that the first row returned
@@ -111337,12 +111405,11 @@
111337 */
111338 if( (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)!=0
111339 && (pWInfo->bOBSat!=0)
111340 && (pIdx->nKeyCol>nEq)
111341 ){
111342 /* assert( pOrderBy->nExpr==1 ); */
111343 /* assert( pOrderBy->a[0].pExpr->iColumn==pIdx->aiColumn[nEq] ); */
111344 isMinQuery = 1;
111345 nExtraReg = 1;
111346 }
111347
111348 /* Find any inequality constraint terms for the start and end
@@ -111469,12 +111536,16 @@
111469 ** If it is, jump to the next iteration of the loop.
111470 */
111471 r1 = sqlite3GetTempReg(pParse);
111472 testcase( pLoop->wsFlags & WHERE_BTM_LIMIT );
111473 testcase( pLoop->wsFlags & WHERE_TOP_LIMIT );
111474 if( (pLoop->wsFlags & (WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0 ){
 
 
 
111475 sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, nEq, r1);
 
111476 sqlite3VdbeAddOp2(v, OP_IsNull, r1, addrCont);
111477 }
111478 sqlite3ReleaseTempReg(pParse, r1);
111479
111480 /* Seek the table cursor, if required */
@@ -111858,16 +111929,11 @@
111858 if( strncmp(zName, "sqlite_autoindex_", 17)==0 ){
111859 int i = sqlite3Strlen30(zName) - 1;
111860 while( zName[i]!='_' ) i--;
111861 zName += i;
111862 }
111863 if( p->u.btree.nSkip ){
111864 sqlite3DebugPrintf(".%-15s %d+%d", zName,
111865 p->u.btree.nSkip, p->u.btree.nEq);
111866 }else{
111867 sqlite3DebugPrintf(".%-16s %2d", zName, p->u.btree.nEq);
111868 }
111869 }else{
111870 sqlite3DebugPrintf("%20s","");
111871 }
111872 }else{
111873 char *z;
@@ -111890,10 +111956,11 @@
111890 int i;
111891 Vdbe *v = pWInfo->pParse->pVdbe;
111892 sqlite3ExplainBegin(v);
111893 for(i=0; i<p->nLTerm; i++){
111894 WhereTerm *pTerm = p->aLTerm[i];
 
111895 sqlite3ExplainPrintf(v, " (%d) #%-2d ", i+1, (int)(pTerm-pWC->a));
111896 sqlite3ExplainPush(v);
111897 whereExplainTerm(v, pTerm);
111898 sqlite3ExplainPop(v);
111899 sqlite3ExplainNL(v);
@@ -112173,10 +112240,11 @@
112173 if( (pTerm->wtFlags & TERM_VIRTUAL)!=0 ) break;
112174 if( (pTerm->prereqAll & pLoop->maskSelf)==0 ) continue;
112175 if( (pTerm->prereqAll & notAllowed)!=0 ) continue;
112176 for(j=pLoop->nLTerm-1; j>=0; j--){
112177 pX = pLoop->aLTerm[j];
 
112178 if( pX==pTerm ) break;
112179 if( pX->iParent>=0 && (&pWC->a[pX->iParent])==pTerm ) break;
112180 }
112181 if( j<0 ) pLoop->nOut += pTerm->truthProb;
112182 }
@@ -112202,11 +112270,12 @@
112202 WhereTerm *pTerm; /* A WhereTerm under consideration */
112203 int opMask; /* Valid operators for constraints */
112204 WhereScan scan; /* Iterator for WHERE terms */
112205 Bitmask saved_prereq; /* Original value of pNew->prereq */
112206 u16 saved_nLTerm; /* Original value of pNew->nLTerm */
112207 int saved_nEq; /* Original value of pNew->u.btree.nEq */
 
112208 u32 saved_wsFlags; /* Original value of pNew->wsFlags */
112209 LogEst saved_nOut; /* Original value of pNew->nOut */
112210 int iCol; /* Index of the column in the table */
112211 int rc = SQLITE_OK; /* Return code */
112212 LogEst nRowEst; /* Estimated index selectivity */
@@ -112237,16 +112306,30 @@
112237 nRowEst = 0;
112238 }
112239 pTerm = whereScanInit(&scan, pBuilder->pWC, pSrc->iCursor, iCol,
112240 opMask, pProbe);
112241 saved_nEq = pNew->u.btree.nEq;
 
112242 saved_nLTerm = pNew->nLTerm;
112243 saved_wsFlags = pNew->wsFlags;
112244 saved_prereq = pNew->prereq;
112245 saved_nOut = pNew->nOut;
112246 pNew->rSetup = 0;
112247 rLogSize = estLog(sqlite3LogEst(pProbe->aiRowEst[0]));
 
 
 
 
 
 
 
 
 
 
 
 
 
112248 for(; rc==SQLITE_OK && pTerm!=0; pTerm = whereScanNext(&scan)){
112249 int nIn = 0;
112250 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
112251 int nRecValid = pBuilder->nRecValid;
112252 #endif
@@ -112278,12 +112361,14 @@
112278 }
112279 pNew->rRun += nIn;
112280 pNew->u.btree.nEq++;
112281 pNew->nOut = nRowEst + nInMul + nIn;
112282 }else if( pTerm->eOperator & (WO_EQ) ){
112283 assert( (pNew->wsFlags & (WHERE_COLUMN_NULL|WHERE_COLUMN_IN))!=0
112284 || nInMul==0 );
 
 
112285 pNew->wsFlags |= WHERE_COLUMN_EQ;
112286 if( iCol<0
112287 || (pProbe->onError!=OE_None && nInMul==0
112288 && pNew->u.btree.nEq==pProbe->nKeyCol-1)
112289 ){
@@ -112360,10 +112445,11 @@
112360 pBuilder->nRecValid = nRecValid;
112361 #endif
112362 }
112363 pNew->prereq = saved_prereq;
112364 pNew->u.btree.nEq = saved_nEq;
 
112365 pNew->wsFlags = saved_wsFlags;
112366 pNew->nOut = saved_nOut;
112367 pNew->nLTerm = saved_nLTerm;
112368 return rc;
112369 }
@@ -112506,10 +112592,11 @@
112506 WhereTerm *pWCEnd = pWC->a + pWC->nTerm;
112507 for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){
112508 if( pTerm->prereqRight & pNew->maskSelf ) continue;
112509 if( termCanDriveIndex(pTerm, pSrc, 0) ){
112510 pNew->u.btree.nEq = 1;
 
112511 pNew->u.btree.pIndex = 0;
112512 pNew->nLTerm = 1;
112513 pNew->aLTerm[0] = pTerm;
112514 /* TUNING: One-time cost for computing the automatic index is
112515 ** approximately 7*N*log2(N) where N is the number of rows in
@@ -112535,10 +112622,11 @@
112535 if( pProbe->pPartIdxWhere!=0
112536 && !whereUsablePartialIndex(pNew->iTab, pWC, pProbe->pPartIdxWhere) ){
112537 continue; /* Partial index inappropriate for this query */
112538 }
112539 pNew->u.btree.nEq = 0;
 
112540 pNew->nLTerm = 0;
112541 pNew->iSortIdx = 0;
112542 pNew->rSetup = 0;
112543 pNew->prereq = mExtra;
112544 pNew->nOut = rSize;
@@ -112620,11 +112708,12 @@
112620 /*
112621 ** Add all WhereLoop objects for a table of the join identified by
112622 ** pBuilder->pNew->iTab. That table is guaranteed to be a virtual table.
112623 */
112624 static int whereLoopAddVirtual(
112625 WhereLoopBuilder *pBuilder /* WHERE clause information */
 
112626 ){
112627 WhereInfo *pWInfo; /* WHERE analysis context */
112628 Parse *pParse; /* The parsing context */
112629 WhereClause *pWC; /* The WHERE clause */
112630 struct SrcList_item *pSrc; /* The FROM clause term to search */
@@ -112710,11 +112799,11 @@
112710 pIdxInfo->estimatedCost = SQLITE_BIG_DBL / (double)2;
112711 pIdxInfo->estimatedRows = 25;
112712 rc = vtabBestIndex(pParse, pTab, pIdxInfo);
112713 if( rc ) goto whereLoopAddVtab_exit;
112714 pIdxCons = *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint;
112715 pNew->prereq = 0;
112716 mxTerm = -1;
112717 assert( pNew->nLSlot>=nConstraint );
112718 for(i=0; i<nConstraint; i++) pNew->aLTerm[i] = 0;
112719 pNew->u.vtab.omitMask = 0;
112720 for(i=0; i<nConstraint; i++, pIdxCons++){
@@ -112837,12 +112926,11 @@
112837 continue;
112838 }
112839 sCur.n = 0;
112840 #ifndef SQLITE_OMIT_VIRTUALTABLE
112841 if( IsVirtual(pItem->pTab) ){
112842 rc = whereLoopAddVirtual(&sSubBuild);
112843 for(i=0; i<sCur.n; i++) sCur.a[i].prereq |= mExtra;
112844 }else
112845 #endif
112846 {
112847 rc = whereLoopAddBtree(&sSubBuild, mExtra);
112848 }
@@ -112908,11 +112996,11 @@
112908 if( ((pItem->jointype|priorJoinType) & (JT_LEFT|JT_CROSS))!=0 ){
112909 mExtra = mPrior;
112910 }
112911 priorJoinType = pItem->jointype;
112912 if( IsVirtual(pItem->pTab) ){
112913 rc = whereLoopAddVirtual(pBuilder);
112914 }else{
112915 rc = whereLoopAddBtree(pBuilder, mExtra);
112916 }
112917 if( rc==SQLITE_OK ){
112918 rc = whereLoopAddOr(pBuilder, mExtra);
@@ -113069,10 +113157,11 @@
113069 for(j=0; j<nColumn; j++){
113070 u8 bOnce; /* True to run the ORDER BY search loop */
113071
113072 /* Skip over == and IS NULL terms */
113073 if( j<pLoop->u.btree.nEq
 
113074 && ((i = pLoop->aLTerm[j]->eOperator) & (WO_EQ|WO_ISNULL))!=0
113075 ){
113076 if( i & WO_ISNULL ){
113077 testcase( isOrderDistinct );
113078 isOrderDistinct = 0;
@@ -113494,10 +113583,11 @@
113494 if( pItem->zIndex ) return 0;
113495 iCur = pItem->iCursor;
113496 pWC = &pWInfo->sWC;
113497 pLoop = pBuilder->pNew;
113498 pLoop->wsFlags = 0;
 
113499 pTerm = findTerm(pWC, iCur, -1, 0, WO_EQ, 0);
113500 if( pTerm ){
113501 pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_IPK|WHERE_ONEROW;
113502 pLoop->aLTerm[0] = pTerm;
113503 pLoop->nLTerm = 1;
@@ -114037,10 +114127,11 @@
114037 notReady = codeOneLoopStart(pWInfo, ii, notReady);
114038 pWInfo->iContinue = pLevel->addrCont;
114039 }
114040
114041 /* Done. */
 
114042 return pWInfo;
114043
114044 /* Jump here if malloc fails */
114045 whereBeginError:
114046 if( pWInfo ){
@@ -114063,12 +114154,14 @@
114063 SrcList *pTabList = pWInfo->pTabList;
114064 sqlite3 *db = pParse->db;
114065
114066 /* Generate loop termination code.
114067 */
 
114068 sqlite3ExprCacheClear(pParse);
114069 for(i=pWInfo->nLevel-1; i>=0; i--){
 
114070 pLevel = &pWInfo->a[i];
114071 pLoop = pLevel->pWLoop;
114072 sqlite3VdbeResolveLabel(v, pLevel->addrCont);
114073 if( pLevel->op!=OP_Noop ){
114074 sqlite3VdbeAddOp2(v, pLevel->op, pLevel->p1, pLevel->p2);
@@ -114084,12 +114177,17 @@
114084 sqlite3VdbeJumpHere(v, pIn->addrInTop-1);
114085 }
114086 sqlite3DbFree(db, pLevel->u.in.aInLoop);
114087 }
114088 sqlite3VdbeResolveLabel(v, pLevel->addrBrk);
 
 
 
 
 
 
114089 if( pLevel->iLeftJoin ){
114090 int addr;
114091 addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin);
114092 assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
114093 || (pLoop->wsFlags & WHERE_INDEXED)!=0 );
114094 if( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 ){
114095 sqlite3VdbeAddOp1(v, OP_NullRow, pTabList->a[i].iCursor);
@@ -114102,11 +114200,11 @@
114102 }else{
114103 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrFirst);
114104 }
114105 sqlite3VdbeJumpHere(v, addr);
114106 }
114107 VdbeNoopComment((v, "End WHERE-Loop %d: %s", i,
114108 pWInfo->pTabList->a[pLevel->iFrom].pTab->zName));
114109 }
114110
114111 /* The "break" point is here, just past the end of the outer loop.
114112 ** Set it.
@@ -123687,10 +123785,14 @@
123687 char *aDoclist; /* Pointer to doclist buffer */
123688 int nDoclist; /* Size of aDoclist[] in bytes */
123689 };
123690
123691 SQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table*,int,int);
 
 
 
 
123692
123693 /* fts3.c */
123694 SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64);
123695 SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
123696 SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);
@@ -123795,36 +123897,60 @@
123795 q[-1] &= 0x7f; /* turn off high bit in final byte */
123796 assert( q - (unsigned char *)p <= FTS3_VARINT_MAX );
123797 return (int) (q - (unsigned char *)p);
123798 }
123799
 
 
 
 
123800 /*
123801 ** Read a 64-bit variable-length integer from memory starting at p[0].
123802 ** Return the number of bytes read, or 0 on error.
123803 ** The value is stored in *v.
123804 */
123805 SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *p, sqlite_int64 *v){
123806 const unsigned char *q = (const unsigned char *) p;
123807 sqlite_uint64 x = 0, y = 1;
123808 while( (*q&0x80)==0x80 && q-(unsigned char *)p<FTS3_VARINT_MAX ){
123809 x += y * (*q++ & 0x7f);
123810 y <<= 7;
123811 }
123812 x += y * (*q++);
123813 *v = (sqlite_int64) x;
123814 return (int) (q - (unsigned char *)p);
 
 
 
 
 
 
 
 
 
123815 }
123816
123817 /*
123818 ** Similar to sqlite3Fts3GetVarint(), except that the output is truncated to a
123819 ** 32-bit integer before it is returned.
123820 */
123821 SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *p, int *pi){
123822 sqlite_int64 i;
123823 int ret = sqlite3Fts3GetVarint(p, &i);
123824 *pi = (int) i;
123825 return ret;
 
 
 
 
 
 
 
 
 
 
 
123826 }
123827
123828 /*
123829 ** Return the number of bytes required to encode v as a varint
123830 */
@@ -125180,14 +125306,14 @@
125180 int nBuffer; /* Total term size */
125181
125182 /* Load the next term on the node into zBuffer. Use realloc() to expand
125183 ** the size of zBuffer if required. */
125184 if( !isFirstTerm ){
125185 zCsr += sqlite3Fts3GetVarint32(zCsr, &nPrefix);
125186 }
125187 isFirstTerm = 0;
125188 zCsr += sqlite3Fts3GetVarint32(zCsr, &nSuffix);
125189
125190 if( nPrefix<0 || nSuffix<0 || &zCsr[nSuffix]>zEnd ){
125191 rc = FTS_CORRUPT_VTAB;
125192 goto finish_scan;
125193 }
@@ -125271,11 +125397,11 @@
125271 int rc; /* Return code */
125272 int iHeight; /* Height of this node in tree */
125273
125274 assert( piLeaf || piLeaf2 );
125275
125276 sqlite3Fts3GetVarint32(zNode, &iHeight);
125277 rc = fts3ScanInteriorNode(zTerm, nTerm, zNode, nNode, piLeaf, piLeaf2);
125278 assert( !piLeaf2 || !piLeaf || rc!=SQLITE_OK || (*piLeaf<=*piLeaf2) );
125279
125280 if( rc==SQLITE_OK && iHeight>1 ){
125281 char *zBlob = 0; /* Blob read from %_segments table */
@@ -125473,15 +125599,15 @@
125473
125474 while( *p1 || *p2 ){
125475 int iCol1; /* The current column index in pp1 */
125476 int iCol2; /* The current column index in pp2 */
125477
125478 if( *p1==POS_COLUMN ) sqlite3Fts3GetVarint32(&p1[1], &iCol1);
125479 else if( *p1==POS_END ) iCol1 = POSITION_LIST_END;
125480 else iCol1 = 0;
125481
125482 if( *p2==POS_COLUMN ) sqlite3Fts3GetVarint32(&p2[1], &iCol2);
125483 else if( *p2==POS_END ) iCol2 = POSITION_LIST_END;
125484 else iCol2 = 0;
125485
125486 if( iCol1==iCol2 ){
125487 sqlite3_int64 i1 = 0; /* Last position from pp1 */
@@ -125570,15 +125696,15 @@
125570 assert( isSaveLeft==0 || isExact==0 );
125571
125572 assert( p!=0 && *p1!=0 && *p2!=0 );
125573 if( *p1==POS_COLUMN ){
125574 p1++;
125575 p1 += sqlite3Fts3GetVarint32(p1, &iCol1);
125576 }
125577 if( *p2==POS_COLUMN ){
125578 p2++;
125579 p2 += sqlite3Fts3GetVarint32(p2, &iCol2);
125580 }
125581
125582 while( 1 ){
125583 if( iCol1==iCol2 ){
125584 char *pSave = p;
@@ -125624,13 +125750,13 @@
125624 fts3ColumnlistCopy(0, &p2);
125625 assert( (*p1&0xFE)==0 && (*p2&0xFE)==0 );
125626 if( 0==*p1 || 0==*p2 ) break;
125627
125628 p1++;
125629 p1 += sqlite3Fts3GetVarint32(p1, &iCol1);
125630 p2++;
125631 p2 += sqlite3Fts3GetVarint32(p2, &iCol2);
125632 }
125633
125634 /* Advance pointer p1 or p2 (whichever corresponds to the smaller of
125635 ** iCol1 and iCol2) so that it points to either the 0x00 that marks the
125636 ** end of the position list, or the 0x01 that precedes the next
@@ -125638,16 +125764,16 @@
125638 */
125639 else if( iCol1<iCol2 ){
125640 fts3ColumnlistCopy(0, &p1);
125641 if( 0==*p1 ) break;
125642 p1++;
125643 p1 += sqlite3Fts3GetVarint32(p1, &iCol1);
125644 }else{
125645 fts3ColumnlistCopy(0, &p2);
125646 if( 0==*p2 ) break;
125647 p2++;
125648 p2 += sqlite3Fts3GetVarint32(p2, &iCol2);
125649 }
125650 }
125651
125652 fts3PoslistCopy(0, &p2);
125653 fts3PoslistCopy(0, &p1);
@@ -128810,11 +128936,11 @@
128810 */
128811 pExpr->aMI[iCol*3 + 1] += iCnt;
128812 pExpr->aMI[iCol*3 + 2] += (iCnt>0);
128813 if( *p==0x00 ) break;
128814 p++;
128815 p += sqlite3Fts3GetVarint32(p, &iCol);
128816 }
128817 }
128818
128819 fts3EvalUpdateCounts(pExpr->pLeft);
128820 fts3EvalUpdateCounts(pExpr->pRight);
@@ -129111,19 +129237,19 @@
129111 }
129112 if( pIter==0 ) return SQLITE_OK;
129113
129114 if( *pIter==0x01 ){
129115 pIter++;
129116 pIter += sqlite3Fts3GetVarint32(pIter, &iThis);
129117 }else{
129118 iThis = 0;
129119 }
129120 while( iThis<iCol ){
129121 fts3ColumnlistCopy(0, &pIter);
129122 if( *pIter==0x00 ) return 0;
129123 pIter++;
129124 pIter += sqlite3Fts3GetVarint32(pIter, &iThis);
129125 }
129126
129127 *ppOut = ((iCol==iThis)?pIter:0);
129128 return SQLITE_OK;
129129 }
@@ -134568,12 +134694,12 @@
134568 rc = fts3SegReaderRequire(pReader, pNext, FTS3_VARINT_MAX*2);
134569 if( rc!=SQLITE_OK ) return rc;
134570
134571 /* Because of the FTS3_NODE_PADDING bytes of padding, the following is
134572 ** safe (no risk of overread) even if the node data is corrupted. */
134573 pNext += sqlite3Fts3GetVarint32(pNext, &nPrefix);
134574 pNext += sqlite3Fts3GetVarint32(pNext, &nSuffix);
134575 if( nPrefix<0 || nSuffix<=0
134576 || &pNext[nSuffix]>&pReader->aNode[pReader->nNode]
134577 ){
134578 return FTS_CORRUPT_VTAB;
134579 }
@@ -134592,11 +134718,11 @@
134592 if( rc!=SQLITE_OK ) return rc;
134593
134594 memcpy(&pReader->zTerm[nPrefix], pNext, nSuffix);
134595 pReader->nTerm = nPrefix+nSuffix;
134596 pNext += nSuffix;
134597 pNext += sqlite3Fts3GetVarint32(pNext, &pReader->nDoclist);
134598 pReader->aDoclist = pNext;
134599 pReader->pOffsetList = 0;
134600
134601 /* Check that the doclist does not appear to extend past the end of the
134602 ** b-tree node. And that the final byte of the doclist is 0x00. If either
@@ -135753,11 +135879,11 @@
135753 pList = p;
135754 if( nList==0 ){
135755 break;
135756 }
135757 p = &pList[1];
135758 p += sqlite3Fts3GetVarint32(p, &iCurrent);
135759 }
135760
135761 if( bZero && &pList[nList]!=pEnd ){
135762 memset(&pList[nList], 0, pEnd - &pList[nList]);
135763 }
@@ -136718,21 +136844,21 @@
136718 if( p->iOff>=p->nNode ){
136719 /* EOF */
136720 p->aNode = 0;
136721 }else{
136722 if( bFirst==0 ){
136723 p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &nPrefix);
136724 }
136725 p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &nSuffix);
136726
136727 blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);
136728 if( rc==SQLITE_OK ){
136729 memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix);
136730 p->term.n = nPrefix+nSuffix;
136731 p->iOff += nSuffix;
136732 if( p->iChild==0 ){
136733 p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist);
136734 p->aDoclist = &p->aNode[p->iOff];
136735 p->iOff += p->nDoclist;
136736 }
136737 }
136738 }
@@ -137780,11 +137906,11 @@
137780 while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
137781 while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
137782
137783 pHint->n = i;
137784 i += sqlite3Fts3GetVarint(&pHint->a[i], piAbsLevel);
137785 i += sqlite3Fts3GetVarint32(&pHint->a[i], pnInput);
137786 if( i!=nHint ) return SQLITE_CORRUPT_VTAB;
137787
137788 return SQLITE_OK;
137789 }
137790
@@ -138773,11 +138899,11 @@
138773 ** After it returns, *piPos contains the value of the next element of the
138774 ** list and *pp is advanced to the following varint.
138775 */
138776 static void fts3GetDeltaPosition(char **pp, int *piPos){
138777 int iVal;
138778 *pp += sqlite3Fts3GetVarint32(*pp, &iVal);
138779 *piPos += (iVal-2);
138780 }
138781
138782 /*
138783 ** Helper function for fts3ExprIterate() (see below).
138784
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -135,11 +135,11 @@
135 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
136 ** [sqlite_version()] and [sqlite_source_id()].
137 */
138 #define SQLITE_VERSION "3.8.2"
139 #define SQLITE_VERSION_NUMBER 3008002
140 #define SQLITE_SOURCE_ID "2013-11-14 19:34:10 10d59226382adcb8016fc2d927e5a0c0b36f3980"
141
142 /*
143 ** CAPI3REF: Run-Time Library Version Numbers
144 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
145 **
@@ -9237,11 +9237,10 @@
9237 SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*);
9238 SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int);
9239 SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*);
9240 #ifdef SQLITE_DEBUG
9241 SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *, int);
 
9242 #endif
9243 SQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe*);
9244 SQLITE_PRIVATE void sqlite3VdbeRewind(Vdbe*);
9245 SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*);
9246 SQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe*,int);
@@ -10304,10 +10303,11 @@
10303 #define SQLITE_PreferBuiltin 0x00200000 /* Preference to built-in funcs */
10304 #define SQLITE_LoadExtension 0x00400000 /* Enable load_extension */
10305 #define SQLITE_EnableTrigger 0x00800000 /* True to enable triggers */
10306 #define SQLITE_DeferFKs 0x01000000 /* Defer all FK constraints */
10307 #define SQLITE_QueryOnly 0x02000000 /* Disable database changes */
10308 #define SQLITE_VdbeEQP 0x04000000 /* Debug EXPLAIN QUERY PLAN */
10309
10310
10311 /*
10312 ** Bits of the sqlite3.dbOptFlags field that are used by the
10313 ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
@@ -13700,13 +13700,10 @@
13700 i64 nFkConstraint; /* Number of imm. FK constraints this VM */
13701 i64 nStmtDefCons; /* Number of def. constraints when stmt started */
13702 i64 nStmtDefImmCons; /* Number of def. imm constraints when stmt started */
13703 char *zSql; /* Text of the SQL statement that generated this */
13704 void *pFree; /* Free this when deleting the vdbe */
 
 
 
13705 #ifdef SQLITE_ENABLE_TREE_EXPLAIN
13706 Explain *pExplain; /* The explainer */
13707 char *zExplain; /* Explanation of data structures */
13708 #endif
13709 VdbeFrame *pFrame; /* Parent frame */
@@ -61013,19 +61010,10 @@
61010 pA->zSql = pB->zSql;
61011 pB->zSql = zTmp;
61012 pB->isPrepareV2 = pA->isPrepareV2;
61013 }
61014
 
 
 
 
 
 
 
 
 
61015 /*
61016 ** Resize the Vdbe.aOp array so that it is at least one op larger than
61017 ** it was.
61018 **
61019 ** If an out-of-memory error occurs while resizing the array, return
@@ -61917,11 +61905,11 @@
61905 assert( i<nTemp );
61906 break;
61907 }
61908 case P4_COLLSEQ: {
61909 CollSeq *pColl = pOp->p4.pColl;
61910 sqlite3_snprintf(nTemp, zTemp, "(%.20s)", pColl->zName);
61911 break;
61912 }
61913 case P4_FUNCDEF: {
61914 FuncDef *pDef = pOp->p4.pFunc;
61915 sqlite3_snprintf(nTemp, zTemp, "%s(%d)", pDef->zName, pDef->nArg);
@@ -62350,19 +62338,21 @@
62338 #ifdef SQLITE_DEBUG
62339 /*
62340 ** Print the SQL that was used to generate a VDBE program.
62341 */
62342 SQLITE_PRIVATE void sqlite3VdbePrintSql(Vdbe *p){
62343 const char *z = 0;
62344 if( p->zSql ){
62345 z = p->zSql;
62346 }else if( p->nOp>=1 ){
62347 const VdbeOp *pOp = &p->aOp[0];
62348 if( pOp->opcode==OP_Trace && pOp->p4.z!=0 ){
62349 z = pOp->p4.z;
62350 while( sqlite3Isspace(*z) ) z++;
62351 }
62352 }
62353 if( z ) printf("SQL: [%s]\n", z);
62354 }
62355 #endif
62356
62357 #if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)
62358 /*
@@ -66366,41 +66356,40 @@
66356
66357 #ifdef SQLITE_DEBUG
66358 /*
66359 ** Print the value of a register for tracing purposes:
66360 */
66361 static void memTracePrint(Mem *p){
66362 if( p->flags & MEM_Invalid ){
66363 printf(" undefined");
66364 }else if( p->flags & MEM_Null ){
66365 printf(" NULL");
66366 }else if( (p->flags & (MEM_Int|MEM_Str))==(MEM_Int|MEM_Str) ){
66367 printf(" si:%lld", p->u.i);
66368 }else if( p->flags & MEM_Int ){
66369 printf(" i:%lld", p->u.i);
66370 #ifndef SQLITE_OMIT_FLOATING_POINT
66371 }else if( p->flags & MEM_Real ){
66372 printf(" r:%g", p->r);
66373 #endif
66374 }else if( p->flags & MEM_RowSet ){
66375 printf(" (rowset)");
66376 }else{
66377 char zBuf[200];
66378 sqlite3VdbeMemPrettyPrint(p, zBuf);
66379 printf(" %s", zBuf);
 
66380 }
66381 }
66382 static void registerTrace(int iReg, Mem *p){
66383 printf("REG[%d] = ", iReg);
66384 memTracePrint(p);
66385 printf("\n");
66386 }
66387 #endif
66388
66389 #ifdef SQLITE_DEBUG
66390 # define REGISTER_TRACE(R,M) if(db->flags&SQLITE_VdbeTrace)registerTrace(R,M)
66391 #else
66392 # define REGISTER_TRACE(R,M)
66393 #endif
66394
66395
@@ -67051,17 +67040,32 @@
67040 }
67041 }
67042 #endif
67043 #ifdef SQLITE_DEBUG
67044 sqlite3BeginBenignMalloc();
67045 if( p->pc==0
67046 && (p->db->flags & (SQLITE_VdbeListing|SQLITE_VdbeEQP|SQLITE_VdbeTrace))!=0
67047 ){
67048 int i;
67049 int once = 1;
67050 sqlite3VdbePrintSql(p);
67051 if( p->db->flags & SQLITE_VdbeListing ){
67052 printf("VDBE Program Listing:\n");
67053 for(i=0; i<p->nOp; i++){
67054 sqlite3VdbePrintOp(stdout, i, &aOp[i]);
67055 }
67056 }
67057 if( p->db->flags & SQLITE_VdbeEQP ){
67058 for(i=0; i<p->nOp; i++){
67059 if( aOp[i].opcode==OP_Explain ){
67060 if( once ) printf("VDBE Query Plan:\n");
67061 printf("%s\n", aOp[i].p4.z);
67062 once = 0;
67063 }
67064 }
67065 }
67066 if( p->db->flags & SQLITE_VdbeTrace ) printf("VDBE Trace:\n");
67067 }
67068 sqlite3EndBenignMalloc();
67069 #endif
67070 for(pc=p->pc; rc==SQLITE_OK; pc++){
67071 assert( pc>=0 && pc<p->nOp );
@@ -67074,16 +67078,12 @@
67078 pOp = &aOp[pc];
67079
67080 /* Only allow tracing if SQLITE_DEBUG is defined.
67081 */
67082 #ifdef SQLITE_DEBUG
67083 if( db->flags & SQLITE_VdbeTrace ){
67084 sqlite3VdbePrintOp(stdout, pc, pOp);
 
 
 
 
67085 }
67086 #endif
67087
67088
67089 /* Check to see if we need to simulate an interrupt. This only happens
@@ -67210,19 +67210,16 @@
67210 ** sqlite3VdbeExec() or since last time the progress callback was called).
67211 ** If the progress callback returns non-zero, exit the virtual machine with
67212 ** a return code SQLITE_ABORT.
67213 */
67214 if( db->xProgress!=0 && nVmStep>=nProgressLimit ){
67215 assert( db->nProgressOps!=0 );
67216 nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps);
67217 if( db->xProgress(db->pProgressArg) ){
67218 rc = SQLITE_INTERRUPT;
67219 goto vdbe_error_halt;
67220 }
 
 
 
67221 }
67222 #endif
67223
67224 break;
67225 }
@@ -67654,10 +67651,22 @@
67651 int i;
67652 #endif /* local variables moved into u.ag */
67653 assert( p->nResColumn==pOp->p2 );
67654 assert( pOp->p1>0 );
67655 assert( pOp->p1+pOp->p2<=(p->nMem-p->nCursor)+1 );
67656
67657 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
67658 /* Run the progress counter just before returning.
67659 */
67660 if( db->xProgress!=0
67661 && nVmStep>=nProgressLimit
67662 && db->xProgress(db->pProgressArg)!=0
67663 ){
67664 rc = SQLITE_INTERRUPT;
67665 goto vdbe_error_halt;
67666 }
67667 #endif
67668
67669 /* If this statement has violated immediate foreign key constraints, do
67670 ** not return the number of rows modified. And do not RELEASE the statement
67671 ** transaction. It needs to be rolled back. */
67672 if( SQLITE_OK!=(rc = sqlite3VdbeCheckFk(p, 0)) ){
@@ -72862,17 +72871,17 @@
72871 */
72872 #ifndef NDEBUG
72873 assert( pc>=-1 && pc<p->nOp );
72874
72875 #ifdef SQLITE_DEBUG
72876 if( db->flags & SQLITE_VdbeTrace ){
72877 if( rc!=0 ) printf("rc=%d\n",rc);
72878 if( pOp->opflags & (OPFLG_OUT2_PRERELEASE|OPFLG_OUT2) ){
72879 registerTrace(pOp->p2, &aMem[pOp->p2]);
72880 }
72881 if( pOp->opflags & OPFLG_OUT3 ){
72882 registerTrace(pOp->p3, &aMem[pOp->p3]);
72883 }
72884 }
72885 #endif /* SQLITE_DEBUG */
72886 #endif /* NDEBUG */
72887 } /* The end of the for(;;) loop the loops through opcodes */
@@ -83106,14 +83115,16 @@
83115 }
83116 pTable = sqlite3FindTable(pInfo->db, argv[0], pInfo->zDatabase);
83117 if( pTable==0 ){
83118 return 0;
83119 }
83120 if( argv[1]==0 ){
 
 
83121 pIndex = 0;
83122 }else if( sqlite3_stricmp(argv[0],argv[1])==0 ){
83123 pIndex = sqlite3PrimaryKeyIndex(pTable);
83124 }else{
83125 pIndex = sqlite3FindIndex(pInfo->db, argv[1], pInfo->zDatabase);
83126 }
83127 z = argv[2];
83128
83129 if( pIndex ){
83130 decodeIntArray((char*)z, pIndex->nKeyCol+1, pIndex->aiRowEst, pIndex);
@@ -84467,14 +84478,10 @@
84478
84479
84480 /* Get the VDBE program ready for execution
84481 */
84482 if( v && ALWAYS(pParse->nErr==0) && !db->mallocFailed ){
 
 
 
 
84483 assert( pParse->iCacheLevel==0 ); /* Disables and re-enables match */
84484 /* A minimum of one cursor is required if autoincrement is used
84485 * See ticket [a696379c1f08866] */
84486 if( pParse->pAinc!=0 && pParse->nTab==0 ) pParse->nTab = 1;
84487 sqlite3VdbeMakeReady(v, pParse);
@@ -96680,10 +96687,14 @@
96687 /* iArg: */ SQLITE_VdbeAddopTrace },
96688 { /* zName: */ "vdbe_debug",
96689 /* ePragTyp: */ PragTyp_FLAG,
96690 /* ePragFlag: */ 0,
96691 /* iArg: */ SQLITE_SqlTrace|SQLITE_VdbeListing|SQLITE_VdbeTrace },
96692 { /* zName: */ "vdbe_eqp",
96693 /* ePragTyp: */ PragTyp_FLAG,
96694 /* ePragFlag: */ 0,
96695 /* iArg: */ SQLITE_VdbeEQP },
96696 { /* zName: */ "vdbe_listing",
96697 /* ePragTyp: */ PragTyp_FLAG,
96698 /* ePragFlag: */ 0,
96699 /* iArg: */ SQLITE_VdbeListing },
96700 { /* zName: */ "vdbe_trace",
@@ -96707,11 +96718,11 @@
96718 /* ePragTyp: */ PragTyp_FLAG,
96719 /* ePragFlag: */ 0,
96720 /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
96721 #endif
96722 };
96723 /* Number of pragmas: 56 on by default, 69 total. */
96724 /* End of the automatically generated pragma table.
96725 ***************************************************************************/
96726
96727 /*
96728 ** Interpret the given string as a safety level. Return 0 for OFF,
@@ -107929,11 +107940,28 @@
107940 ** generating the code that loops through a table looking for applicable
107941 ** rows. Indices are selected and used to speed the search when doing
107942 ** so is applicable. Because this module is responsible for selecting
107943 ** indices, you might also think of this module as the "query optimizer".
107944 */
107945 /************** Include whereInt.h in the middle of where.c ******************/
107946 /************** Begin file whereInt.h ****************************************/
107947 /*
107948 ** 2013-11-12
107949 **
107950 ** The author disclaims copyright to this source code. In place of
107951 ** a legal notice, here is a blessing:
107952 **
107953 ** May you do good and not evil.
107954 ** May you find forgiveness for yourself and forgive others.
107955 ** May you share freely, never taking more than you give.
107956 **
107957 *************************************************************************
107958 **
107959 ** This file contains structure and macro definitions for the query
107960 ** planner logic in "where.c". These definitions are broken out into
107961 ** a separate source file for easier editing.
107962 */
107963
107964 /*
107965 ** Trace output macros
107966 */
107967 #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
@@ -107981,10 +108009,11 @@
108009 int iLeftJoin; /* Memory cell used to implement LEFT OUTER JOIN */
108010 int iTabCur; /* The VDBE cursor used to access the table */
108011 int iIdxCur; /* The VDBE cursor used to access pIdx */
108012 int addrBrk; /* Jump here to break out of the loop */
108013 int addrNxt; /* Jump here to start the next IN combination */
108014 int addrSkip; /* Jump here for next iteration of skip-scan */
108015 int addrCont; /* Jump here to continue with the next loop cycle */
108016 int addrFirst; /* First instruction of interior of the loop */
108017 int addrBody; /* Beginning of the body of this loop */
108018 u8 iFrom; /* Which entry in the FROM clause */
108019 u8 op, p5; /* Opcode and P5 of the opcode that ends the loop */
@@ -108030,11 +108059,11 @@
108059 LogEst rRun; /* Cost of running each loop */
108060 LogEst nOut; /* Estimated number of output rows */
108061 union {
108062 struct { /* Information for internal btree tables */
108063 u16 nEq; /* Number of equality constraints */
108064 u16 nSkip; /* Number of initial index columns to skip */
108065 Index *pIndex; /* Index used, or NULL */
108066 } btree;
108067 struct { /* Information for virtual tables */
108068 int idxNum; /* Index number */
108069 u8 needFree; /* True if sqlite3_free(idxStr) is needed */
@@ -108371,10 +108400,14 @@
108400 #define WHERE_VIRTUALTABLE 0x00000400 /* WhereLoop.u.vtab is valid */
108401 #define WHERE_IN_ABLE 0x00000800 /* Able to support an IN operator */
108402 #define WHERE_ONEROW 0x00001000 /* Selects no more than one row */
108403 #define WHERE_MULTI_OR 0x00002000 /* OR using multiple indices */
108404 #define WHERE_AUTO_INDEX 0x00004000 /* Uses an ephemeral index */
108405 #define WHERE_SKIPSCAN 0x00008000 /* Uses the skip-scan algorithm */
108406
108407 /************** End of whereInt.h ********************************************/
108408 /************** Continuing where we left off in where.c **********************/
108409
108410 /*
108411 ** Return the estimated number of output rows from a WHERE clause
108412 */
108413 SQLITE_PRIVATE u64 sqlite3WhereOutputRowCount(WhereInfo *pWInfo){
@@ -110775,11 +110808,11 @@
110808 return iReg;
110809 }
110810
110811 /*
110812 ** Generate code that will evaluate all == and IN constraints for an
110813 ** index scan.
110814 **
110815 ** For example, consider table t1(a,b,c,d,e,f) with index i1(a,b,c).
110816 ** Suppose the WHERE clause is this: a==5 AND b IN (1,2,3) AND c>5 AND c<10
110817 ** The index has as many as three equality constraints, but in this
110818 ** example, the third "c" value is an inequality. So only two
@@ -110790,13 +110823,19 @@
110823 ** In the example above nEq==2. But this subroutine works for any value
110824 ** of nEq including 0. If nEq==0, this routine is nearly a no-op.
110825 ** The only thing it does is allocate the pLevel->iMem memory cell and
110826 ** compute the affinity string.
110827 **
110828 ** The nExtraReg parameter is 0 or 1. It is 0 if all WHERE clause constraints
110829 ** are == or IN and are covered by the nEq. nExtraReg is 1 if there is
110830 ** an inequality constraint (such as the "c>=5 AND c<10" in the example) that
110831 ** occurs after the nEq quality constraints.
110832 **
110833 ** This routine allocates a range of nEq+nExtraReg memory cells and returns
110834 ** the index of the first memory cell in that range. The code that
110835 ** calls this routine will use that memory range to store keys for
110836 ** start and termination conditions of the loop.
110837 ** key value of the loop. If one or more IN operators appear, then
110838 ** this routine allocates an additional nEq memory cells for internal
110839 ** use.
110840 **
110841 ** Before returning, *pzAff is set to point to a buffer containing a
@@ -110819,11 +110858,12 @@
110858 WhereLevel *pLevel, /* Which nested loop of the FROM we are coding */
110859 int bRev, /* Reverse the order of IN operators */
110860 int nExtraReg, /* Number of extra registers to allocate */
110861 char **pzAff /* OUT: Set to point to affinity string */
110862 ){
110863 u16 nEq; /* The number of == or IN constraints to code */
110864 u16 nSkip; /* Number of left-most columns to skip */
110865 Vdbe *v = pParse->pVdbe; /* The vm under construction */
110866 Index *pIdx; /* The index being used for this loop */
110867 WhereTerm *pTerm; /* A single constraint term */
110868 WhereLoop *pLoop; /* The WhereLoop object */
110869 int j; /* Loop counter */
@@ -110833,10 +110873,11 @@
110873
110874 /* This module is only called on query plans that use an index. */
110875 pLoop = pLevel->pWLoop;
110876 assert( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 );
110877 nEq = pLoop->u.btree.nEq;
110878 nSkip = pLoop->u.btree.nSkip;
110879 pIdx = pLoop->u.btree.pIndex;
110880 assert( pIdx!=0 );
110881
110882 /* Figure out how many memory cells we will need then allocate them.
110883 */
@@ -110846,19 +110887,34 @@
110887
110888 zAff = sqlite3DbStrDup(pParse->db, sqlite3IndexAffinityStr(v, pIdx));
110889 if( !zAff ){
110890 pParse->db->mallocFailed = 1;
110891 }
110892
110893 if( nSkip ){
110894 int iIdxCur = pLevel->iIdxCur;
110895 sqlite3VdbeAddOp1(v, (bRev?OP_Last:OP_Rewind), iIdxCur);
110896 VdbeComment((v, "begin skip-scan on %s", pIdx->zName));
110897 j = sqlite3VdbeAddOp0(v, OP_Goto);
110898 pLevel->addrSkip = sqlite3VdbeAddOp4Int(v, (bRev?OP_SeekLt:OP_SeekGt),
110899 iIdxCur, 0, regBase, nSkip);
110900 sqlite3VdbeJumpHere(v, j);
110901 for(j=0; j<nSkip; j++){
110902 sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, j, regBase+j);
110903 assert( pIdx->aiColumn[j]>=0 );
110904 VdbeComment((v, "%s", pIdx->pTable->aCol[pIdx->aiColumn[j]].zName));
110905 }
110906 }
110907
110908 /* Evaluate the equality constraints
110909 */
110910 assert( zAff==0 || (int)strlen(zAff)>=nEq );
110911 for(j=nSkip; j<nEq; j++){
110912 int r1;
110913 pTerm = pLoop->aLTerm[j];
110914 assert( pTerm!=0 );
110915 /* The following testcase is true for indices with redundant columns.
110916 ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */
110917 testcase( (pTerm->wtFlags & TERM_CODED)!=0 );
110918 testcase( pTerm->wtFlags & TERM_VIRTUAL );
110919 r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, regBase+j);
110920 if( r1!=regBase+j ){
@@ -110928,11 +110984,12 @@
110984 ** It is the responsibility of the caller to free the buffer when it is
110985 ** no longer required.
110986 */
110987 static char *explainIndexRange(sqlite3 *db, WhereLoop *pLoop, Table *pTab){
110988 Index *pIndex = pLoop->u.btree.pIndex;
110989 u16 nEq = pLoop->u.btree.nEq;
110990 u16 nSkip = pLoop->u.btree.nSkip;
110991 int i, j;
110992 Column *aCol = pTab->aCol;
110993 i16 *aiColumn = pIndex->aiColumn;
110994 StrAccum txt;
110995
@@ -110942,11 +110999,18 @@
110999 sqlite3StrAccumInit(&txt, 0, 0, SQLITE_MAX_LENGTH);
111000 txt.db = db;
111001 sqlite3StrAccumAppend(&txt, " (", 2);
111002 for(i=0; i<nEq; i++){
111003 char *z = (i==pIndex->nKeyCol ) ? "rowid" : aCol[aiColumn[i]].zName;
111004 if( i>=nSkip ){
111005 explainAppendTerm(&txt, i, z, "=");
111006 }else{
111007 if( i ) sqlite3StrAccumAppend(&txt, " AND ", 5);
111008 sqlite3StrAccumAppend(&txt, "ANY(", 4);
111009 sqlite3StrAccumAppend(&txt, z, -1);
111010 sqlite3StrAccumAppend(&txt, ")", 1);
111011 }
111012 }
111013
111014 j = i;
111015 if( pLoop->wsFlags&WHERE_BTM_LIMIT ){
111016 char *z = (j==pIndex->nKeyCol ) ? "rowid" : aCol[aiColumn[j]].zName;
@@ -110972,11 +111036,14 @@
111036 WhereLevel *pLevel, /* Scan to write OP_Explain opcode for */
111037 int iLevel, /* Value for "level" column of output */
111038 int iFrom, /* Value for "from" column of output */
111039 u16 wctrlFlags /* Flags passed to sqlite3WhereBegin() */
111040 ){
111041 #ifndef SQLITE_DEBUG
111042 if( pParse->explain==2 )
111043 #endif
111044 {
111045 struct SrcList_item *pItem = &pTabList->a[pLevel->iFrom];
111046 Vdbe *v = pParse->pVdbe; /* VM being constructed */
111047 sqlite3 *db = pParse->db; /* Database handle */
111048 char *zMsg; /* Text to add to EQP output */
111049 int iId = pParse->iSelectId; /* Select id (left-most output column) */
@@ -111078,11 +111145,11 @@
111145 iCur = pTabItem->iCursor;
111146 pLevel->notReady = notReady & ~getMask(&pWInfo->sMaskSet, iCur);
111147 bRev = (pWInfo->revMask>>iLevel)&1;
111148 omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0
111149 && (pWInfo->wctrlFlags & WHERE_FORCE_TABLE)==0;
111150 VdbeNoopComment((v, "Begin WHERE-loop%d: %s",iLevel,pTabItem->pTab->zName));
111151
111152 /* Create labels for the "break" and "continue" instructions
111153 ** for the current loop. Jump to addrBrk to break out of a loop.
111154 ** Jump to cont to go immediately to the next iteration of the
111155 ** loop.
@@ -111305,12 +111372,12 @@
111372 static const u8 aEndOp[] = {
111373 OP_Noop, /* 0: (!end_constraints) */
111374 OP_IdxGE, /* 1: (end_constraints && !bRev) */
111375 OP_IdxLT /* 2: (end_constraints && bRev) */
111376 };
111377 u16 nEq = pLoop->u.btree.nEq; /* Number of == or IN terms */
111378 int isMinQuery = 0; /* If this is an optimized SELECT min(x).. */
111379 int regBase; /* Base register holding constraint values */
111380 int r1; /* Temp register */
111381 WhereTerm *pRangeStart = 0; /* Inequality constraint at range start */
111382 WhereTerm *pRangeEnd = 0; /* Inequality constraint at range end */
111383 int startEq; /* True if range start uses ==, >= or <= */
@@ -111324,10 +111391,11 @@
111391 char *zStartAff; /* Affinity for start of range constraint */
111392 char *zEndAff; /* Affinity for end of range constraint */
111393
111394 pIdx = pLoop->u.btree.pIndex;
111395 iIdxCur = pLevel->iIdxCur;
111396 assert( nEq>=pLoop->u.btree.nSkip );
111397
111398 /* If this loop satisfies a sort order (pOrderBy) request that
111399 ** was passed to this function to implement a "SELECT min(x) ..."
111400 ** query, then the caller will only allow the loop to run for
111401 ** a single iteration. This means that the first row returned
@@ -111337,12 +111405,11 @@
111405 */
111406 if( (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)!=0
111407 && (pWInfo->bOBSat!=0)
111408 && (pIdx->nKeyCol>nEq)
111409 ){
111410 assert( pLoop->u.btree.nSkip==0 );
 
111411 isMinQuery = 1;
111412 nExtraReg = 1;
111413 }
111414
111415 /* Find any inequality constraint terms for the start and end
@@ -111469,12 +111536,16 @@
111536 ** If it is, jump to the next iteration of the loop.
111537 */
111538 r1 = sqlite3GetTempReg(pParse);
111539 testcase( pLoop->wsFlags & WHERE_BTM_LIMIT );
111540 testcase( pLoop->wsFlags & WHERE_TOP_LIMIT );
111541 if( (pLoop->wsFlags & (WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0
111542 && (j = pIdx->aiColumn[nEq])>=0
111543 && pIdx->pTable->aCol[j].notNull==0
111544 ){
111545 sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, nEq, r1);
111546 VdbeComment((v, "%s", pIdx->pTable->aCol[j].zName));
111547 sqlite3VdbeAddOp2(v, OP_IsNull, r1, addrCont);
111548 }
111549 sqlite3ReleaseTempReg(pParse, r1);
111550
111551 /* Seek the table cursor, if required */
@@ -111858,16 +111929,11 @@
111929 if( strncmp(zName, "sqlite_autoindex_", 17)==0 ){
111930 int i = sqlite3Strlen30(zName) - 1;
111931 while( zName[i]!='_' ) i--;
111932 zName += i;
111933 }
111934 sqlite3DebugPrintf(".%-16s %2d", zName, p->u.btree.nEq);
 
 
 
 
 
111935 }else{
111936 sqlite3DebugPrintf("%20s","");
111937 }
111938 }else{
111939 char *z;
@@ -111890,10 +111956,11 @@
111956 int i;
111957 Vdbe *v = pWInfo->pParse->pVdbe;
111958 sqlite3ExplainBegin(v);
111959 for(i=0; i<p->nLTerm; i++){
111960 WhereTerm *pTerm = p->aLTerm[i];
111961 if( pTerm==0 ) continue;
111962 sqlite3ExplainPrintf(v, " (%d) #%-2d ", i+1, (int)(pTerm-pWC->a));
111963 sqlite3ExplainPush(v);
111964 whereExplainTerm(v, pTerm);
111965 sqlite3ExplainPop(v);
111966 sqlite3ExplainNL(v);
@@ -112173,10 +112240,11 @@
112240 if( (pTerm->wtFlags & TERM_VIRTUAL)!=0 ) break;
112241 if( (pTerm->prereqAll & pLoop->maskSelf)==0 ) continue;
112242 if( (pTerm->prereqAll & notAllowed)!=0 ) continue;
112243 for(j=pLoop->nLTerm-1; j>=0; j--){
112244 pX = pLoop->aLTerm[j];
112245 if( pX==0 ) continue;
112246 if( pX==pTerm ) break;
112247 if( pX->iParent>=0 && (&pWC->a[pX->iParent])==pTerm ) break;
112248 }
112249 if( j<0 ) pLoop->nOut += pTerm->truthProb;
112250 }
@@ -112202,11 +112270,12 @@
112270 WhereTerm *pTerm; /* A WhereTerm under consideration */
112271 int opMask; /* Valid operators for constraints */
112272 WhereScan scan; /* Iterator for WHERE terms */
112273 Bitmask saved_prereq; /* Original value of pNew->prereq */
112274 u16 saved_nLTerm; /* Original value of pNew->nLTerm */
112275 u16 saved_nEq; /* Original value of pNew->u.btree.nEq */
112276 u16 saved_nSkip; /* Original value of pNew->u.btree.nSkip */
112277 u32 saved_wsFlags; /* Original value of pNew->wsFlags */
112278 LogEst saved_nOut; /* Original value of pNew->nOut */
112279 int iCol; /* Index of the column in the table */
112280 int rc = SQLITE_OK; /* Return code */
112281 LogEst nRowEst; /* Estimated index selectivity */
@@ -112237,16 +112306,30 @@
112306 nRowEst = 0;
112307 }
112308 pTerm = whereScanInit(&scan, pBuilder->pWC, pSrc->iCursor, iCol,
112309 opMask, pProbe);
112310 saved_nEq = pNew->u.btree.nEq;
112311 saved_nSkip = pNew->u.btree.nSkip;
112312 saved_nLTerm = pNew->nLTerm;
112313 saved_wsFlags = pNew->wsFlags;
112314 saved_prereq = pNew->prereq;
112315 saved_nOut = pNew->nOut;
112316 pNew->rSetup = 0;
112317 rLogSize = estLog(sqlite3LogEst(pProbe->aiRowEst[0]));
112318 if( pTerm==0
112319 && saved_nEq==saved_nSkip
112320 && saved_nEq+1<pProbe->nKeyCol
112321 && pProbe->aiRowEst[saved_nEq+1]>50
112322 ){
112323 LogEst nIter;
112324 pNew->u.btree.nEq++;
112325 pNew->u.btree.nSkip++;
112326 pNew->aLTerm[pNew->nLTerm++] = 0;
112327 pNew->wsFlags |= WHERE_SKIPSCAN;
112328 nIter = sqlite3LogEst(pProbe->aiRowEst[0]/pProbe->aiRowEst[saved_nEq+1]);
112329 whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nIter);
112330 }
112331 for(; rc==SQLITE_OK && pTerm!=0; pTerm = whereScanNext(&scan)){
112332 int nIn = 0;
112333 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
112334 int nRecValid = pBuilder->nRecValid;
112335 #endif
@@ -112278,12 +112361,14 @@
112361 }
112362 pNew->rRun += nIn;
112363 pNew->u.btree.nEq++;
112364 pNew->nOut = nRowEst + nInMul + nIn;
112365 }else if( pTerm->eOperator & (WO_EQ) ){
112366 assert(
112367 (pNew->wsFlags & (WHERE_COLUMN_NULL|WHERE_COLUMN_IN|WHERE_SKIPSCAN))!=0
112368 || nInMul==0
112369 );
112370 pNew->wsFlags |= WHERE_COLUMN_EQ;
112371 if( iCol<0
112372 || (pProbe->onError!=OE_None && nInMul==0
112373 && pNew->u.btree.nEq==pProbe->nKeyCol-1)
112374 ){
@@ -112360,10 +112445,11 @@
112445 pBuilder->nRecValid = nRecValid;
112446 #endif
112447 }
112448 pNew->prereq = saved_prereq;
112449 pNew->u.btree.nEq = saved_nEq;
112450 pNew->u.btree.nSkip = saved_nSkip;
112451 pNew->wsFlags = saved_wsFlags;
112452 pNew->nOut = saved_nOut;
112453 pNew->nLTerm = saved_nLTerm;
112454 return rc;
112455 }
@@ -112506,10 +112592,11 @@
112592 WhereTerm *pWCEnd = pWC->a + pWC->nTerm;
112593 for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){
112594 if( pTerm->prereqRight & pNew->maskSelf ) continue;
112595 if( termCanDriveIndex(pTerm, pSrc, 0) ){
112596 pNew->u.btree.nEq = 1;
112597 pNew->u.btree.nSkip = 0;
112598 pNew->u.btree.pIndex = 0;
112599 pNew->nLTerm = 1;
112600 pNew->aLTerm[0] = pTerm;
112601 /* TUNING: One-time cost for computing the automatic index is
112602 ** approximately 7*N*log2(N) where N is the number of rows in
@@ -112535,10 +112622,11 @@
112622 if( pProbe->pPartIdxWhere!=0
112623 && !whereUsablePartialIndex(pNew->iTab, pWC, pProbe->pPartIdxWhere) ){
112624 continue; /* Partial index inappropriate for this query */
112625 }
112626 pNew->u.btree.nEq = 0;
112627 pNew->u.btree.nSkip = 0;
112628 pNew->nLTerm = 0;
112629 pNew->iSortIdx = 0;
112630 pNew->rSetup = 0;
112631 pNew->prereq = mExtra;
112632 pNew->nOut = rSize;
@@ -112620,11 +112708,12 @@
112708 /*
112709 ** Add all WhereLoop objects for a table of the join identified by
112710 ** pBuilder->pNew->iTab. That table is guaranteed to be a virtual table.
112711 */
112712 static int whereLoopAddVirtual(
112713 WhereLoopBuilder *pBuilder, /* WHERE clause information */
112714 Bitmask mExtra
112715 ){
112716 WhereInfo *pWInfo; /* WHERE analysis context */
112717 Parse *pParse; /* The parsing context */
112718 WhereClause *pWC; /* The WHERE clause */
112719 struct SrcList_item *pSrc; /* The FROM clause term to search */
@@ -112710,11 +112799,11 @@
112799 pIdxInfo->estimatedCost = SQLITE_BIG_DBL / (double)2;
112800 pIdxInfo->estimatedRows = 25;
112801 rc = vtabBestIndex(pParse, pTab, pIdxInfo);
112802 if( rc ) goto whereLoopAddVtab_exit;
112803 pIdxCons = *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint;
112804 pNew->prereq = mExtra;
112805 mxTerm = -1;
112806 assert( pNew->nLSlot>=nConstraint );
112807 for(i=0; i<nConstraint; i++) pNew->aLTerm[i] = 0;
112808 pNew->u.vtab.omitMask = 0;
112809 for(i=0; i<nConstraint; i++, pIdxCons++){
@@ -112837,12 +112926,11 @@
112926 continue;
112927 }
112928 sCur.n = 0;
112929 #ifndef SQLITE_OMIT_VIRTUALTABLE
112930 if( IsVirtual(pItem->pTab) ){
112931 rc = whereLoopAddVirtual(&sSubBuild, mExtra);
 
112932 }else
112933 #endif
112934 {
112935 rc = whereLoopAddBtree(&sSubBuild, mExtra);
112936 }
@@ -112908,11 +112996,11 @@
112996 if( ((pItem->jointype|priorJoinType) & (JT_LEFT|JT_CROSS))!=0 ){
112997 mExtra = mPrior;
112998 }
112999 priorJoinType = pItem->jointype;
113000 if( IsVirtual(pItem->pTab) ){
113001 rc = whereLoopAddVirtual(pBuilder, mExtra);
113002 }else{
113003 rc = whereLoopAddBtree(pBuilder, mExtra);
113004 }
113005 if( rc==SQLITE_OK ){
113006 rc = whereLoopAddOr(pBuilder, mExtra);
@@ -113069,10 +113157,11 @@
113157 for(j=0; j<nColumn; j++){
113158 u8 bOnce; /* True to run the ORDER BY search loop */
113159
113160 /* Skip over == and IS NULL terms */
113161 if( j<pLoop->u.btree.nEq
113162 && pLoop->u.btree.nSkip==0
113163 && ((i = pLoop->aLTerm[j]->eOperator) & (WO_EQ|WO_ISNULL))!=0
113164 ){
113165 if( i & WO_ISNULL ){
113166 testcase( isOrderDistinct );
113167 isOrderDistinct = 0;
@@ -113494,10 +113583,11 @@
113583 if( pItem->zIndex ) return 0;
113584 iCur = pItem->iCursor;
113585 pWC = &pWInfo->sWC;
113586 pLoop = pBuilder->pNew;
113587 pLoop->wsFlags = 0;
113588 pLoop->u.btree.nSkip = 0;
113589 pTerm = findTerm(pWC, iCur, -1, 0, WO_EQ, 0);
113590 if( pTerm ){
113591 pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_IPK|WHERE_ONEROW;
113592 pLoop->aLTerm[0] = pTerm;
113593 pLoop->nLTerm = 1;
@@ -114037,10 +114127,11 @@
114127 notReady = codeOneLoopStart(pWInfo, ii, notReady);
114128 pWInfo->iContinue = pLevel->addrCont;
114129 }
114130
114131 /* Done. */
114132 VdbeNoopComment((v, "Begin WHERE-core"));
114133 return pWInfo;
114134
114135 /* Jump here if malloc fails */
114136 whereBeginError:
114137 if( pWInfo ){
@@ -114063,12 +114154,14 @@
114154 SrcList *pTabList = pWInfo->pTabList;
114155 sqlite3 *db = pParse->db;
114156
114157 /* Generate loop termination code.
114158 */
114159 VdbeNoopComment((v, "End WHERE-core"));
114160 sqlite3ExprCacheClear(pParse);
114161 for(i=pWInfo->nLevel-1; i>=0; i--){
114162 int addr;
114163 pLevel = &pWInfo->a[i];
114164 pLoop = pLevel->pWLoop;
114165 sqlite3VdbeResolveLabel(v, pLevel->addrCont);
114166 if( pLevel->op!=OP_Noop ){
114167 sqlite3VdbeAddOp2(v, pLevel->op, pLevel->p1, pLevel->p2);
@@ -114084,12 +114177,17 @@
114177 sqlite3VdbeJumpHere(v, pIn->addrInTop-1);
114178 }
114179 sqlite3DbFree(db, pLevel->u.in.aInLoop);
114180 }
114181 sqlite3VdbeResolveLabel(v, pLevel->addrBrk);
114182 if( pLevel->addrSkip ){
114183 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrSkip);
114184 VdbeComment((v, "next skip-scan on %s", pLoop->u.btree.pIndex->zName));
114185 sqlite3VdbeJumpHere(v, pLevel->addrSkip);
114186 sqlite3VdbeJumpHere(v, pLevel->addrSkip-2);
114187 }
114188 if( pLevel->iLeftJoin ){
 
114189 addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin);
114190 assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
114191 || (pLoop->wsFlags & WHERE_INDEXED)!=0 );
114192 if( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 ){
114193 sqlite3VdbeAddOp1(v, OP_NullRow, pTabList->a[i].iCursor);
@@ -114102,11 +114200,11 @@
114200 }else{
114201 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrFirst);
114202 }
114203 sqlite3VdbeJumpHere(v, addr);
114204 }
114205 VdbeNoopComment((v, "End WHERE-loop%d: %s", i,
114206 pWInfo->pTabList->a[pLevel->iFrom].pTab->zName));
114207 }
114208
114209 /* The "break" point is here, just past the end of the outer loop.
114210 ** Set it.
@@ -123687,10 +123785,14 @@
123785 char *aDoclist; /* Pointer to doclist buffer */
123786 int nDoclist; /* Size of aDoclist[] in bytes */
123787 };
123788
123789 SQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table*,int,int);
123790
123791 #define fts3GetVarint32(p, piVal) ( \
123792 (*(u8*)(p)&0x80) ? sqlite3Fts3GetVarint32(p, piVal) : (*piVal=*(u8*)(p), 1) \
123793 )
123794
123795 /* fts3.c */
123796 SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64);
123797 SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
123798 SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);
@@ -123795,36 +123897,60 @@
123897 q[-1] &= 0x7f; /* turn off high bit in final byte */
123898 assert( q - (unsigned char *)p <= FTS3_VARINT_MAX );
123899 return (int) (q - (unsigned char *)p);
123900 }
123901
123902 #define GETVARINT_STEP(v, ptr, shift, mask1, mask2, var, ret) \
123903 v = (v & mask1) | ( (*ptr++) << shift ); \
123904 if( (v & mask2)==0 ){ var = v; return ret; }
123905
123906 /*
123907 ** Read a 64-bit variable-length integer from memory starting at p[0].
123908 ** Return the number of bytes read, or 0 on error.
123909 ** The value is stored in *v.
123910 */
123911 SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *p, sqlite_int64 *v){
123912 const char *pStart = p;
123913 u32 a;
123914 u64 b;
123915 int shift;
123916
123917 GETVARINT_STEP(a, p, 0, 0x00, 0x80, *v, 1);
123918 GETVARINT_STEP(a, p, 7, 0x7F, 0x4000, *v, 2);
123919 GETVARINT_STEP(a, p, 14, 0x3FFF, 0x200000, *v, 3);
123920 GETVARINT_STEP(a, p, 21, 0x1FFFFF, 0x10000000, *v, 4);
123921 b = (a & 0x0FFFFFFF );
123922
123923 for(shift=28; shift<=63; shift+=7){
123924 u64 c = *p++;
123925 b += (c&0x7F) << shift;
123926 if( (c & 0x80)==0 ) break;
123927 }
123928 *v = b;
123929 return p - pStart;
123930 }
123931
123932 /*
123933 ** Similar to sqlite3Fts3GetVarint(), except that the output is truncated to a
123934 ** 32-bit integer before it is returned.
123935 */
123936 SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *p, int *pi){
123937 u32 a;
123938
123939 #ifndef fts3GetVarint32
123940 GETVARINT_STEP(a, p, 0, 0x00, 0x80, *pi, 1);
123941 #else
123942 a = (*p++);
123943 assert( a & 0x80 );
123944 #endif
123945
123946 GETVARINT_STEP(a, p, 7, 0x7F, 0x4000, *pi, 2);
123947 GETVARINT_STEP(a, p, 14, 0x3FFF, 0x200000, *pi, 3);
123948 GETVARINT_STEP(a, p, 21, 0x1FFFFF, 0x10000000, *pi, 4);
123949 a = (a & 0x0FFFFFFF );
123950 *pi = (int)(a | ((u32)(*p & 0x0F) << 28));
123951 return 5;
123952 }
123953
123954 /*
123955 ** Return the number of bytes required to encode v as a varint
123956 */
@@ -125180,14 +125306,14 @@
125306 int nBuffer; /* Total term size */
125307
125308 /* Load the next term on the node into zBuffer. Use realloc() to expand
125309 ** the size of zBuffer if required. */
125310 if( !isFirstTerm ){
125311 zCsr += fts3GetVarint32(zCsr, &nPrefix);
125312 }
125313 isFirstTerm = 0;
125314 zCsr += fts3GetVarint32(zCsr, &nSuffix);
125315
125316 if( nPrefix<0 || nSuffix<0 || &zCsr[nSuffix]>zEnd ){
125317 rc = FTS_CORRUPT_VTAB;
125318 goto finish_scan;
125319 }
@@ -125271,11 +125397,11 @@
125397 int rc; /* Return code */
125398 int iHeight; /* Height of this node in tree */
125399
125400 assert( piLeaf || piLeaf2 );
125401
125402 fts3GetVarint32(zNode, &iHeight);
125403 rc = fts3ScanInteriorNode(zTerm, nTerm, zNode, nNode, piLeaf, piLeaf2);
125404 assert( !piLeaf2 || !piLeaf || rc!=SQLITE_OK || (*piLeaf<=*piLeaf2) );
125405
125406 if( rc==SQLITE_OK && iHeight>1 ){
125407 char *zBlob = 0; /* Blob read from %_segments table */
@@ -125473,15 +125599,15 @@
125599
125600 while( *p1 || *p2 ){
125601 int iCol1; /* The current column index in pp1 */
125602 int iCol2; /* The current column index in pp2 */
125603
125604 if( *p1==POS_COLUMN ) fts3GetVarint32(&p1[1], &iCol1);
125605 else if( *p1==POS_END ) iCol1 = POSITION_LIST_END;
125606 else iCol1 = 0;
125607
125608 if( *p2==POS_COLUMN ) fts3GetVarint32(&p2[1], &iCol2);
125609 else if( *p2==POS_END ) iCol2 = POSITION_LIST_END;
125610 else iCol2 = 0;
125611
125612 if( iCol1==iCol2 ){
125613 sqlite3_int64 i1 = 0; /* Last position from pp1 */
@@ -125570,15 +125696,15 @@
125696 assert( isSaveLeft==0 || isExact==0 );
125697
125698 assert( p!=0 && *p1!=0 && *p2!=0 );
125699 if( *p1==POS_COLUMN ){
125700 p1++;
125701 p1 += fts3GetVarint32(p1, &iCol1);
125702 }
125703 if( *p2==POS_COLUMN ){
125704 p2++;
125705 p2 += fts3GetVarint32(p2, &iCol2);
125706 }
125707
125708 while( 1 ){
125709 if( iCol1==iCol2 ){
125710 char *pSave = p;
@@ -125624,13 +125750,13 @@
125750 fts3ColumnlistCopy(0, &p2);
125751 assert( (*p1&0xFE)==0 && (*p2&0xFE)==0 );
125752 if( 0==*p1 || 0==*p2 ) break;
125753
125754 p1++;
125755 p1 += fts3GetVarint32(p1, &iCol1);
125756 p2++;
125757 p2 += fts3GetVarint32(p2, &iCol2);
125758 }
125759
125760 /* Advance pointer p1 or p2 (whichever corresponds to the smaller of
125761 ** iCol1 and iCol2) so that it points to either the 0x00 that marks the
125762 ** end of the position list, or the 0x01 that precedes the next
@@ -125638,16 +125764,16 @@
125764 */
125765 else if( iCol1<iCol2 ){
125766 fts3ColumnlistCopy(0, &p1);
125767 if( 0==*p1 ) break;
125768 p1++;
125769 p1 += fts3GetVarint32(p1, &iCol1);
125770 }else{
125771 fts3ColumnlistCopy(0, &p2);
125772 if( 0==*p2 ) break;
125773 p2++;
125774 p2 += fts3GetVarint32(p2, &iCol2);
125775 }
125776 }
125777
125778 fts3PoslistCopy(0, &p2);
125779 fts3PoslistCopy(0, &p1);
@@ -128810,11 +128936,11 @@
128936 */
128937 pExpr->aMI[iCol*3 + 1] += iCnt;
128938 pExpr->aMI[iCol*3 + 2] += (iCnt>0);
128939 if( *p==0x00 ) break;
128940 p++;
128941 p += fts3GetVarint32(p, &iCol);
128942 }
128943 }
128944
128945 fts3EvalUpdateCounts(pExpr->pLeft);
128946 fts3EvalUpdateCounts(pExpr->pRight);
@@ -129111,19 +129237,19 @@
129237 }
129238 if( pIter==0 ) return SQLITE_OK;
129239
129240 if( *pIter==0x01 ){
129241 pIter++;
129242 pIter += fts3GetVarint32(pIter, &iThis);
129243 }else{
129244 iThis = 0;
129245 }
129246 while( iThis<iCol ){
129247 fts3ColumnlistCopy(0, &pIter);
129248 if( *pIter==0x00 ) return 0;
129249 pIter++;
129250 pIter += fts3GetVarint32(pIter, &iThis);
129251 }
129252
129253 *ppOut = ((iCol==iThis)?pIter:0);
129254 return SQLITE_OK;
129255 }
@@ -134568,12 +134694,12 @@
134694 rc = fts3SegReaderRequire(pReader, pNext, FTS3_VARINT_MAX*2);
134695 if( rc!=SQLITE_OK ) return rc;
134696
134697 /* Because of the FTS3_NODE_PADDING bytes of padding, the following is
134698 ** safe (no risk of overread) even if the node data is corrupted. */
134699 pNext += fts3GetVarint32(pNext, &nPrefix);
134700 pNext += fts3GetVarint32(pNext, &nSuffix);
134701 if( nPrefix<0 || nSuffix<=0
134702 || &pNext[nSuffix]>&pReader->aNode[pReader->nNode]
134703 ){
134704 return FTS_CORRUPT_VTAB;
134705 }
@@ -134592,11 +134718,11 @@
134718 if( rc!=SQLITE_OK ) return rc;
134719
134720 memcpy(&pReader->zTerm[nPrefix], pNext, nSuffix);
134721 pReader->nTerm = nPrefix+nSuffix;
134722 pNext += nSuffix;
134723 pNext += fts3GetVarint32(pNext, &pReader->nDoclist);
134724 pReader->aDoclist = pNext;
134725 pReader->pOffsetList = 0;
134726
134727 /* Check that the doclist does not appear to extend past the end of the
134728 ** b-tree node. And that the final byte of the doclist is 0x00. If either
@@ -135753,11 +135879,11 @@
135879 pList = p;
135880 if( nList==0 ){
135881 break;
135882 }
135883 p = &pList[1];
135884 p += fts3GetVarint32(p, &iCurrent);
135885 }
135886
135887 if( bZero && &pList[nList]!=pEnd ){
135888 memset(&pList[nList], 0, pEnd - &pList[nList]);
135889 }
@@ -136718,21 +136844,21 @@
136844 if( p->iOff>=p->nNode ){
136845 /* EOF */
136846 p->aNode = 0;
136847 }else{
136848 if( bFirst==0 ){
136849 p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nPrefix);
136850 }
136851 p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nSuffix);
136852
136853 blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);
136854 if( rc==SQLITE_OK ){
136855 memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix);
136856 p->term.n = nPrefix+nSuffix;
136857 p->iOff += nSuffix;
136858 if( p->iChild==0 ){
136859 p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist);
136860 p->aDoclist = &p->aNode[p->iOff];
136861 p->iOff += p->nDoclist;
136862 }
136863 }
136864 }
@@ -137780,11 +137906,11 @@
137906 while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
137907 while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
137908
137909 pHint->n = i;
137910 i += sqlite3Fts3GetVarint(&pHint->a[i], piAbsLevel);
137911 i += fts3GetVarint32(&pHint->a[i], pnInput);
137912 if( i!=nHint ) return SQLITE_CORRUPT_VTAB;
137913
137914 return SQLITE_OK;
137915 }
137916
@@ -138773,11 +138899,11 @@
138899 ** After it returns, *piPos contains the value of the next element of the
138900 ** list and *pp is advanced to the following varint.
138901 */
138902 static void fts3GetDeltaPosition(char **pp, int *piPos){
138903 int iVal;
138904 *pp += fts3GetVarint32(*pp, &iVal);
138905 *piPos += (iVal-2);
138906 }
138907
138908 /*
138909 ** Helper function for fts3ExprIterate() (see below).
138910
+1 -1
--- 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.2"
111111
#define SQLITE_VERSION_NUMBER 3008002
112
-#define SQLITE_SOURCE_ID "2013-11-12 15:33:40 0f924c6ef6cf2ac5a61aafa8dd8e3309b3970499"
112
+#define SQLITE_SOURCE_ID "2013-11-14 19:34:10 10d59226382adcb8016fc2d927e5a0c0b36f3980"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
118118
--- 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.2"
111 #define SQLITE_VERSION_NUMBER 3008002
112 #define SQLITE_SOURCE_ID "2013-11-12 15:33:40 0f924c6ef6cf2ac5a61aafa8dd8e3309b3970499"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
118
--- 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.2"
111 #define SQLITE_VERSION_NUMBER 3008002
112 #define SQLITE_SOURCE_ID "2013-11-14 19:34:10 10d59226382adcb8016fc2d927e5a0c0b36f3980"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
118
--- win/Makefile.dmc
+++ win/Makefile.dmc
@@ -24,11 +24,11 @@
2424
CFLAGS = -o
2525
BCC = $(DMDIR)\bin\dmc $(CFLAGS)
2626
TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL)
2727
LIBS = $(DMDIR)\extra\lib\ zlib wsock32 advapi32
2828
29
-SQLITE_OPTIONS = -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_STAT3 -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_WIN32_NO_ANSI
29
+SQLITE_OPTIONS = -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_WIN32_NO_ANSI
3030
3131
SRC = add_.c allrepo_.c attach_.c bag_.c bisect_.c blob_.c branch_.c browse_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c db_.c delta_.c deltacmd_.c descendants_.c diff_.c diffcmd_.c doc_.c encode_.c event_.c export_.c file_.c finfo_.c glob_.c graph_.c gzip_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c pivot_.c popen_.c pqueue_.c printf_.c rebuild_.c regexp_.c report_.c rss_.c schema_.c search_.c setup_.c sha1_.c shun_.c skins_.c sqlcmd_.c stash_.c stat_.c style_.c sync_.c tag_.c tar_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c
3232
3333
OBJ = $(OBJDIR)\add$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\file$O $(OBJDIR)\finfo$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\path$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\setup$O $(OBJDIR)\sha1$O $(OBJDIR)\shun$O $(OBJDIR)\skins$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winhttp$O $(OBJDIR)\wysiwyg$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O
3434
3535
--- win/Makefile.dmc
+++ win/Makefile.dmc
@@ -24,11 +24,11 @@
24 CFLAGS = -o
25 BCC = $(DMDIR)\bin\dmc $(CFLAGS)
26 TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL)
27 LIBS = $(DMDIR)\extra\lib\ zlib wsock32 advapi32
28
29 SQLITE_OPTIONS = -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_STAT3 -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_WIN32_NO_ANSI
30
31 SRC = add_.c allrepo_.c attach_.c bag_.c bisect_.c blob_.c branch_.c browse_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c db_.c delta_.c deltacmd_.c descendants_.c diff_.c diffcmd_.c doc_.c encode_.c event_.c export_.c file_.c finfo_.c glob_.c graph_.c gzip_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c pivot_.c popen_.c pqueue_.c printf_.c rebuild_.c regexp_.c report_.c rss_.c schema_.c search_.c setup_.c sha1_.c shun_.c skins_.c sqlcmd_.c stash_.c stat_.c style_.c sync_.c tag_.c tar_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c
32
33 OBJ = $(OBJDIR)\add$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\file$O $(OBJDIR)\finfo$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\path$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\setup$O $(OBJDIR)\sha1$O $(OBJDIR)\shun$O $(OBJDIR)\skins$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winhttp$O $(OBJDIR)\wysiwyg$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O
34
35
--- win/Makefile.dmc
+++ win/Makefile.dmc
@@ -24,11 +24,11 @@
24 CFLAGS = -o
25 BCC = $(DMDIR)\bin\dmc $(CFLAGS)
26 TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL)
27 LIBS = $(DMDIR)\extra\lib\ zlib wsock32 advapi32
28
29 SQLITE_OPTIONS = -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_WIN32_NO_ANSI
30
31 SRC = add_.c allrepo_.c attach_.c bag_.c bisect_.c blob_.c branch_.c browse_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c db_.c delta_.c deltacmd_.c descendants_.c diff_.c diffcmd_.c doc_.c encode_.c event_.c export_.c file_.c finfo_.c glob_.c graph_.c gzip_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c pivot_.c popen_.c pqueue_.c printf_.c rebuild_.c regexp_.c report_.c rss_.c schema_.c search_.c setup_.c sha1_.c shun_.c skins_.c sqlcmd_.c stash_.c stat_.c style_.c sync_.c tag_.c tar_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c
32
33 OBJ = $(OBJDIR)\add$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\file$O $(OBJDIR)\finfo$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\path$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\setup$O $(OBJDIR)\sha1$O $(OBJDIR)\shun$O $(OBJDIR)\skins$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winhttp$O $(OBJDIR)\wysiwyg$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O
34
35
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -1685,11 +1685,11 @@
16851685
$(XTCC) -o $(OBJDIR)/zip.o -c $(OBJDIR)/zip_.c
16861686
16871687
$(OBJDIR)/zip.h: $(OBJDIR)/headers
16881688
16891689
$(OBJDIR)/sqlite3.o: $(SRCDIR)/sqlite3.c
1690
- $(XTCC) -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_STAT3 -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_WIN32_NO_ANSI -D_HAVE_SQLITE_CONFIG_H -DSQLITE_USE_MALLOC_H -DSQLITE_USE_MSIZE -c $(SRCDIR)/sqlite3.c -o $(OBJDIR)/sqlite3.o
1690
+ $(XTCC) -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_WIN32_NO_ANSI -D_HAVE_SQLITE_CONFIG_H -DSQLITE_USE_MALLOC_H -DSQLITE_USE_MSIZE -c $(SRCDIR)/sqlite3.c -o $(OBJDIR)/sqlite3.o
16911691
16921692
$(OBJDIR)/cson_amalgamation.o: $(SRCDIR)/cson_amalgamation.c
16931693
$(XTCC) -c $(SRCDIR)/cson_amalgamation.c -o $(OBJDIR)/cson_amalgamation.o
16941694
16951695
$(OBJDIR)/json.o $(OBJDIR)/json_artifact.o $(OBJDIR)/json_branch.o $(OBJDIR)/json_config.o $(OBJDIR)/json_diff.o $(OBJDIR)/json_dir.o $(OBJDIR)/jsos_finfo.o $(OBJDIR)/json_login.o $(OBJDIR)/json_query.o $(OBJDIR)/json_report.o $(OBJDIR)/json_status.o $(OBJDIR)/json_tag.o $(OBJDIR)/json_timeline.o $(OBJDIR)/json_user.o $(OBJDIR)/json_wiki.o : $(SRCDIR)/json_detail.h
16961696
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -1685,11 +1685,11 @@
1685 $(XTCC) -o $(OBJDIR)/zip.o -c $(OBJDIR)/zip_.c
1686
1687 $(OBJDIR)/zip.h: $(OBJDIR)/headers
1688
1689 $(OBJDIR)/sqlite3.o: $(SRCDIR)/sqlite3.c
1690 $(XTCC) -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_STAT3 -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_WIN32_NO_ANSI -D_HAVE_SQLITE_CONFIG_H -DSQLITE_USE_MALLOC_H -DSQLITE_USE_MSIZE -c $(SRCDIR)/sqlite3.c -o $(OBJDIR)/sqlite3.o
1691
1692 $(OBJDIR)/cson_amalgamation.o: $(SRCDIR)/cson_amalgamation.c
1693 $(XTCC) -c $(SRCDIR)/cson_amalgamation.c -o $(OBJDIR)/cson_amalgamation.o
1694
1695 $(OBJDIR)/json.o $(OBJDIR)/json_artifact.o $(OBJDIR)/json_branch.o $(OBJDIR)/json_config.o $(OBJDIR)/json_diff.o $(OBJDIR)/json_dir.o $(OBJDIR)/jsos_finfo.o $(OBJDIR)/json_login.o $(OBJDIR)/json_query.o $(OBJDIR)/json_report.o $(OBJDIR)/json_status.o $(OBJDIR)/json_tag.o $(OBJDIR)/json_timeline.o $(OBJDIR)/json_user.o $(OBJDIR)/json_wiki.o : $(SRCDIR)/json_detail.h
1696
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -1685,11 +1685,11 @@
1685 $(XTCC) -o $(OBJDIR)/zip.o -c $(OBJDIR)/zip_.c
1686
1687 $(OBJDIR)/zip.h: $(OBJDIR)/headers
1688
1689 $(OBJDIR)/sqlite3.o: $(SRCDIR)/sqlite3.c
1690 $(XTCC) -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_WIN32_NO_ANSI -D_HAVE_SQLITE_CONFIG_H -DSQLITE_USE_MALLOC_H -DSQLITE_USE_MSIZE -c $(SRCDIR)/sqlite3.c -o $(OBJDIR)/sqlite3.o
1691
1692 $(OBJDIR)/cson_amalgamation.o: $(SRCDIR)/cson_amalgamation.c
1693 $(XTCC) -c $(SRCDIR)/cson_amalgamation.c -o $(OBJDIR)/cson_amalgamation.o
1694
1695 $(OBJDIR)/json.o $(OBJDIR)/json_artifact.o $(OBJDIR)/json_branch.o $(OBJDIR)/json_config.o $(OBJDIR)/json_diff.o $(OBJDIR)/json_dir.o $(OBJDIR)/jsos_finfo.o $(OBJDIR)/json_login.o $(OBJDIR)/json_query.o $(OBJDIR)/json_report.o $(OBJDIR)/json_status.o $(OBJDIR)/json_tag.o $(OBJDIR)/json_timeline.o $(OBJDIR)/json_user.o $(OBJDIR)/json_wiki.o : $(SRCDIR)/json_detail.h
1696
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -67,11 +67,12 @@
6767
!endif
6868
6969
SQLITE_OPTIONS = /DSQLITE_OMIT_LOAD_EXTENSION=1 \
7070
/DSQLITE_THREADSAFE=0 \
7171
/DSQLITE_DEFAULT_FILE_FORMAT=4 \
72
- /DSQLITE_ENABLE_STAT3 \
72
+ /DSQLITE_OMIT_DEPRECATED \
73
+ /DSQLITE_ENABLE_EXPLAIN_COMMENTS \
7374
/Dlocaltime=fossil_localtime \
7475
/DSQLITE_ENABLE_LOCKING_STYLE=0 \
7576
/DSQLITE_WIN32_NO_ANSI
7677
7778
SRC = add_.c \
7879
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -67,11 +67,12 @@
67 !endif
68
69 SQLITE_OPTIONS = /DSQLITE_OMIT_LOAD_EXTENSION=1 \
70 /DSQLITE_THREADSAFE=0 \
71 /DSQLITE_DEFAULT_FILE_FORMAT=4 \
72 /DSQLITE_ENABLE_STAT3 \
 
73 /Dlocaltime=fossil_localtime \
74 /DSQLITE_ENABLE_LOCKING_STYLE=0 \
75 /DSQLITE_WIN32_NO_ANSI
76
77 SRC = add_.c \
78
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -67,11 +67,12 @@
67 !endif
68
69 SQLITE_OPTIONS = /DSQLITE_OMIT_LOAD_EXTENSION=1 \
70 /DSQLITE_THREADSAFE=0 \
71 /DSQLITE_DEFAULT_FILE_FORMAT=4 \
72 /DSQLITE_OMIT_DEPRECATED \
73 /DSQLITE_ENABLE_EXPLAIN_COMMENTS \
74 /Dlocaltime=fossil_localtime \
75 /DSQLITE_ENABLE_LOCKING_STYLE=0 \
76 /DSQLITE_WIN32_NO_ANSI
77
78 SRC = add_.c \
79

Keyboard Shortcuts

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