mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-05 04:30:38 +03:00
Improved auto-detection of EXPLAIN output in the shell.
FossilOrigin-Name: 6c6d7a6e89e67cdb0813d3eebb869aafb43d43ed
This commit is contained in:
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.
|
C Improved\sauto-detection\sof\sEXPLAIN\soutput\sin\sthe\sshell.
|
||||||
D 2016-02-09T18:39:25.001
|
D 2016-02-09T20:04:07.701
|
||||||
F Makefile.in 95ea52e9c02962e31f986fe8ea5805104c84f94b
|
F Makefile.in 95ea52e9c02962e31f986fe8ea5805104c84f94b
|
||||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||||
F Makefile.msc 0fe3b22f8e29bcde0533ada7957a5f15835d797a
|
F Makefile.msc 0fe3b22f8e29bcde0533ada7957a5f15835d797a
|
||||||
@@ -349,7 +349,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696
|
|||||||
F src/resolve.c 9f7ce3a3c087afb7597b7c916c99126ff3f12f0c
|
F src/resolve.c 9f7ce3a3c087afb7597b7c916c99126ff3f12f0c
|
||||||
F src/rowset.c 9fe4b3ad7cc00944386bb600233d8f523de07a6e
|
F src/rowset.c 9fe4b3ad7cc00944386bb600233d8f523de07a6e
|
||||||
F src/select.c ff80004a9a6ece891a8d9327a88e7b6e2588ee6d
|
F src/select.c ff80004a9a6ece891a8d9327a88e7b6e2588ee6d
|
||||||
F src/shell.c eae68d3a7aff0f4195074d5f204dc2c219e748fd
|
F src/shell.c dad82078194d5dae39d35f131e4b60dd3276ab27
|
||||||
F src/sqlite.h.in cf22ad1d52dca2c9862d63833e581028119aab7e
|
F src/sqlite.h.in cf22ad1d52dca2c9862d63833e581028119aab7e
|
||||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||||
F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d
|
F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d
|
||||||
@@ -1427,10 +1427,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
|
|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||||
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
|
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
|
||||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||||
P 51b6823f4c9376d549f572f5a33cac1e4c9783a2
|
P 1d62aa6b315df47cafb33da7ca79d3386a2fdd48
|
||||||
R 38fbc467636eda7f2b73a6fc60969ca8
|
R 7efe35d4fa73e934642e7f03926fba5a
|
||||||
T *branch * auto-explain
|
|
||||||
T *sym-auto-explain *
|
|
||||||
T -sym-trunk *
|
|
||||||
U drh
|
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
|
/* Try to figure out if this is really an EXPLAIN statement. If this
|
||||||
** cannot be verified, return early. */
|
** cannot be verified, return early. */
|
||||||
|
if( sqlite3_column_count(pSql)!=8 ){
|
||||||
|
p->cMode = p->mode;
|
||||||
|
return;
|
||||||
|
}
|
||||||
zSql = sqlite3_sql(pSql);
|
zSql = sqlite3_sql(pSql);
|
||||||
if( zSql==0 ) return;
|
if( zSql==0 ) return;
|
||||||
for(z=zSql; *z==' ' || *z=='\t' || *z=='\n' || *z=='\f' || *z=='\r'; z++);
|
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++){
|
for(iOp=0; SQLITE_ROW==sqlite3_step(pSql); iOp++){
|
||||||
int i;
|
int i;
|
||||||
@@ -1526,6 +1533,20 @@ static void explain_data_prepare(ShellState *p, sqlite3_stmt *pSql){
|
|||||||
|
|
||||||
/* Grow the p->aiIndent array as required */
|
/* Grow the p->aiIndent array as required */
|
||||||
if( iOp>=nAlloc ){
|
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;
|
nAlloc += 100;
|
||||||
p->aiIndent = (int*)sqlite3_realloc64(p->aiIndent, nAlloc*sizeof(int));
|
p->aiIndent = (int*)sqlite3_realloc64(p->aiIndent, nAlloc*sizeof(int));
|
||||||
abYield = (int*)sqlite3_realloc64(abYield, nAlloc*sizeof(int));
|
abYield = (int*)sqlite3_realloc64(abYield, nAlloc*sizeof(int));
|
||||||
@@ -1631,9 +1652,9 @@ static int shell_exec(
|
|||||||
|
|
||||||
if( pArg ){
|
if( pArg ){
|
||||||
pArg->cMode = pArg->mode;
|
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("%EXPLAIN%", sqlite3_sql(pStmt),0)==0
|
||||||
&& sqlite3_strlike("%QUERY%", sqlite3_sql(pStmt),0)!=0
|
|
||||||
){
|
){
|
||||||
pArg->cMode = MODE_Explain;
|
pArg->cMode = MODE_Explain;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user