Fossil SCM

Only use SQLITE_TESTCTRL_EXPLAIN_STMT/SQLITE_STMTSTATUS_VM_STEP when necessary/supported

jan.nijtmans 2014-10-05 23:11 sqlite3-compat
Commit 99d52b38fb154f9471e2c3fadc483e28b82515a1
1 file changed +15 -3
+15 -3
--- src/shell.c
+++ src/shell.c
@@ -1176,12 +1176,14 @@
11761176
fprintf(pArg->out, "Fullscan Steps: %d\n", iCur);
11771177
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_SORT, bReset);
11781178
fprintf(pArg->out, "Sort Operations: %d\n", iCur);
11791179
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX, bReset);
11801180
fprintf(pArg->out, "Autoindex Inserts: %d\n", iCur);
1181
- iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset);
1182
- fprintf(pArg->out, "Virtual Machine Steps: %d\n", iCur);
1181
+ if( sqlite3_libversion_number()>=3008000 ){
1182
+ iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset);
1183
+ fprintf(pArg->out, "Virtual Machine Steps: %d\n", iCur);
1184
+ }
11831185
}
11841186
11851187
return 0;
11861188
}
11871189
@@ -1350,10 +1352,21 @@
13501352
}
13511353
}
13521354
sqlite3_finalize(pExplain);
13531355
sqlite3_free(zEQP);
13541356
}
1357
+
1358
+#if USE_SYSTEM_SQLITE+0==1
1359
+ /* Output TESTCTRL_EXPLAIN text of requested */
1360
+ if( pArg && pArg->mode==MODE_Explain && sqlite3_libversion_number()<3008007 ){
1361
+ const char *zExplain = 0;
1362
+ sqlite3_test_control(SQLITE_TESTCTRL_EXPLAIN_STMT, pStmt, &zExplain);
1363
+ if( zExplain && zExplain[0] ){
1364
+ fprintf(pArg->out, "%s", zExplain);
1365
+ }
1366
+ }
1367
+#endif
13551368
13561369
/* If the shell is currently in ".explain" mode, gather the extra
13571370
** data required to add indents to the output.*/
13581371
if( pArg && pArg->mode==MODE_Explain ){
13591372
explain_data_prepare(pArg, pStmt);
@@ -3723,11 +3736,10 @@
37233736
}
37243737
}
37253738
if( nSql ){
37263739
if( !_all_whitespace(zSql) ){
37273740
fprintf(stderr, "Error: incomplete SQL: %s\n", zSql);
3728
- errCnt++;
37293741
}
37303742
free(zSql);
37313743
}
37323744
free(zLine);
37333745
return errCnt>0;
37343746
--- src/shell.c
+++ src/shell.c
@@ -1176,12 +1176,14 @@
1176 fprintf(pArg->out, "Fullscan Steps: %d\n", iCur);
1177 iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_SORT, bReset);
1178 fprintf(pArg->out, "Sort Operations: %d\n", iCur);
1179 iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX, bReset);
1180 fprintf(pArg->out, "Autoindex Inserts: %d\n", iCur);
1181 iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset);
1182 fprintf(pArg->out, "Virtual Machine Steps: %d\n", iCur);
 
 
1183 }
1184
1185 return 0;
1186 }
1187
@@ -1350,10 +1352,21 @@
1350 }
1351 }
1352 sqlite3_finalize(pExplain);
1353 sqlite3_free(zEQP);
1354 }
 
 
 
 
 
 
 
 
 
 
 
1355
1356 /* If the shell is currently in ".explain" mode, gather the extra
1357 ** data required to add indents to the output.*/
1358 if( pArg && pArg->mode==MODE_Explain ){
1359 explain_data_prepare(pArg, pStmt);
@@ -3723,11 +3736,10 @@
3723 }
3724 }
3725 if( nSql ){
3726 if( !_all_whitespace(zSql) ){
3727 fprintf(stderr, "Error: incomplete SQL: %s\n", zSql);
3728 errCnt++;
3729 }
3730 free(zSql);
3731 }
3732 free(zLine);
3733 return errCnt>0;
3734
--- src/shell.c
+++ src/shell.c
@@ -1176,12 +1176,14 @@
1176 fprintf(pArg->out, "Fullscan Steps: %d\n", iCur);
1177 iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_SORT, bReset);
1178 fprintf(pArg->out, "Sort Operations: %d\n", iCur);
1179 iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX, bReset);
1180 fprintf(pArg->out, "Autoindex Inserts: %d\n", iCur);
1181 if( sqlite3_libversion_number()>=3008000 ){
1182 iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset);
1183 fprintf(pArg->out, "Virtual Machine Steps: %d\n", iCur);
1184 }
1185 }
1186
1187 return 0;
1188 }
1189
@@ -1350,10 +1352,21 @@
1352 }
1353 }
1354 sqlite3_finalize(pExplain);
1355 sqlite3_free(zEQP);
1356 }
1357
1358 #if USE_SYSTEM_SQLITE+0==1
1359 /* Output TESTCTRL_EXPLAIN text of requested */
1360 if( pArg && pArg->mode==MODE_Explain && sqlite3_libversion_number()<3008007 ){
1361 const char *zExplain = 0;
1362 sqlite3_test_control(SQLITE_TESTCTRL_EXPLAIN_STMT, pStmt, &zExplain);
1363 if( zExplain && zExplain[0] ){
1364 fprintf(pArg->out, "%s", zExplain);
1365 }
1366 }
1367 #endif
1368
1369 /* If the shell is currently in ".explain" mode, gather the extra
1370 ** data required to add indents to the output.*/
1371 if( pArg && pArg->mode==MODE_Explain ){
1372 explain_data_prepare(pArg, pStmt);
@@ -3723,11 +3736,10 @@
3736 }
3737 }
3738 if( nSql ){
3739 if( !_all_whitespace(zSql) ){
3740 fprintf(stderr, "Error: incomplete SQL: %s\n", zSql);
 
3741 }
3742 free(zSql);
3743 }
3744 free(zLine);
3745 return errCnt>0;
3746

Keyboard Shortcuts

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