Improved auto-detection of EXPLAIN output in the shell.
FossilOrigin-Name: 6c6d7a6e89e67cdb0813d3eebb869aafb43d43ed
This commit is contained in:
parent
700c252a72
commit
87a24aa1ca
15
manifest
15
manifest
@ -1,5 +1,5 @@
|
||||
C Add\sauto-explain\smode\sto\sthe\scommand-line\sshell.\s\sDefault\son.\s\sAuto-explain\ntries\sto\sautomatically\sdetect\sEXPLAIN\squeries\sand\sformat\sthem\sappropriately.
|
||||
D 2016-02-09T18:39:25.001
|
||||
C Improved\sauto-detection\sof\sEXPLAIN\soutput\sin\sthe\sshell.
|
||||
D 2016-02-09T20:04:07.701
|
||||
F Makefile.in 95ea52e9c02962e31f986fe8ea5805104c84f94b
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc 0fe3b22f8e29bcde0533ada7957a5f15835d797a
|
||||
@ -349,7 +349,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696
|
||||
F src/resolve.c 9f7ce3a3c087afb7597b7c916c99126ff3f12f0c
|
||||
F src/rowset.c 9fe4b3ad7cc00944386bb600233d8f523de07a6e
|
||||
F src/select.c ff80004a9a6ece891a8d9327a88e7b6e2588ee6d
|
||||
F src/shell.c eae68d3a7aff0f4195074d5f204dc2c219e748fd
|
||||
F src/shell.c dad82078194d5dae39d35f131e4b60dd3276ab27
|
||||
F src/sqlite.h.in cf22ad1d52dca2c9862d63833e581028119aab7e
|
||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||
F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d
|
||||
@ -1427,10 +1427,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
|
||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||
P 51b6823f4c9376d549f572f5a33cac1e4c9783a2
|
||||
R 38fbc467636eda7f2b73a6fc60969ca8
|
||||
T *branch * auto-explain
|
||||
T *sym-auto-explain *
|
||||
T -sym-trunk *
|
||||
P 1d62aa6b315df47cafb33da7ca79d3386a2fdd48
|
||||
R 7efe35d4fa73e934642e7f03926fba5a
|
||||
U drh
|
||||
Z 2feb45f9e3784b1a58bde6f86e718a1d
|
||||
Z d64951a4b1ff916463dbab9f9acfa416
|
||||
|
@ -1 +1 @@
|
||||
1d62aa6b315df47cafb33da7ca79d3386a2fdd48
|
||||
6c6d7a6e89e67cdb0813d3eebb869aafb43d43ed
|
27
src/shell.c
27
src/shell.c
@ -1506,10 +1506,17 @@ static void explain_data_prepare(ShellState *p, sqlite3_stmt *pSql){
|
||||
|
||||
/* Try to figure out if this is really an EXPLAIN statement. If this
|
||||
** cannot be verified, return early. */
|
||||
if( sqlite3_column_count(pSql)!=8 ){
|
||||
p->cMode = p->mode;
|
||||
return;
|
||||
}
|
||||
zSql = sqlite3_sql(pSql);
|
||||
if( zSql==0 ) return;
|
||||
for(z=zSql; *z==' ' || *z=='\t' || *z=='\n' || *z=='\f' || *z=='\r'; z++);
|
||||
if( sqlite3_strnicmp(z, "explain", 7) ) return;
|
||||
if( sqlite3_strnicmp(z, "explain", 7) ){
|
||||
p->cMode = p->mode;
|
||||
return;
|
||||
}
|
||||
|
||||
for(iOp=0; SQLITE_ROW==sqlite3_step(pSql); iOp++){
|
||||
int i;
|
||||
@ -1526,6 +1533,20 @@ static void explain_data_prepare(ShellState *p, sqlite3_stmt *pSql){
|
||||
|
||||
/* Grow the p->aiIndent array as required */
|
||||
if( iOp>=nAlloc ){
|
||||
if( iOp==0 ){
|
||||
/* Do further verfication that this is explain output. Abort if
|
||||
** it is not */
|
||||
static const char *explainCols[] = {
|
||||
"addr", "opcode", "p1", "p2", "p3", "p4", "p5", "comment" };
|
||||
int jj;
|
||||
for(jj=0; jj<ArraySize(explainCols); jj++){
|
||||
if( strcmp(sqlite3_column_name(pSql,jj),explainCols[jj])!=0 ){
|
||||
p->cMode = p->mode;
|
||||
sqlite3_reset(pSql);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
nAlloc += 100;
|
||||
p->aiIndent = (int*)sqlite3_realloc64(p->aiIndent, nAlloc*sizeof(int));
|
||||
abYield = (int*)sqlite3_realloc64(abYield, nAlloc*sizeof(int));
|
||||
@ -1631,9 +1652,9 @@ static int shell_exec(
|
||||
|
||||
if( pArg ){
|
||||
pArg->cMode = pArg->mode;
|
||||
if( sqlite3_column_count(pStmt)==8
|
||||
if( pArg->autoExplain
|
||||
&& sqlite3_column_count(pStmt)==8
|
||||
&& sqlite3_strlike("%EXPLAIN%", sqlite3_sql(pStmt),0)==0
|
||||
&& sqlite3_strlike("%QUERY%", sqlite3_sql(pStmt),0)!=0
|
||||
){
|
||||
pArg->cMode = MODE_Explain;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user