Fix a problem with the shell tool EXPLAIN indentation code and VDBE sub-programs.

FossilOrigin-Name: 9c8d6856253f8da06b2cb5dc6bd89b6952fa03ed
This commit is contained in:
dan 2013-11-18 08:41:06 +00:00
parent e73e067187
commit c4650bb33d
3 changed files with 26 additions and 16 deletions

View File

@ -1,5 +1,5 @@
C Enable\sthe\sONEPASS\soptimization\sfor\sDELETE,\sfor\sboth\srowid\sand\sWITHOUT\nROWID\stables.
D 2013-11-18T03:11:54.195
C Fix\sa\sproblem\swith\sthe\sshell\stool\sEXPLAIN\sindentation\scode\sand\sVDBE\ssub-programs.
D 2013-11-18T08:41:06.910
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 8a07bebafbfda0eb67728f4bd15a36201662d1a1
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -220,7 +220,7 @@ F src/random.c 0b2dbc37fdfbfa6bd455b091dfcef5bdb32dba68
F src/resolve.c 6fcceeb653a0020b14491975d567c989e794d408
F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
F src/select.c 253cb683e4a05b0b56b0f9c816f3c4a4e5575ebb
F src/shell.c b98e74123d6c2e20369607c1da2d23c71db633d9
F src/shell.c 849ee96c952d20e504d417e42a06acc5ca94ef17
F src/sqlite.h.in 4dedcab5b32358bf7a596badffe7363be1f1a82d
F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e
F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc
@ -1140,8 +1140,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
P 7edf39eb93a8f9059a788f5fccf41c2be40afd4d 6bd5750b7d5da221b0689f6df6be5ed0dce61bec
R de0ce1af524d0d7134e767478b5898b6
T +closed 6bd5750b7d5da221b0689f6df6be5ed0dce61bec
U drh
Z b3bca10fc785a82e3f00cdade511d055
P 44a07afdd9b3ae2460bc963383295deb0915f899
R fd745146c0298a78435ee62db781f33d
U dan
Z ccddbfb4ee4200a6ab72b0a768e815b9

View File

@ -1 +1 @@
44a07afdd9b3ae2460bc963383295deb0915f899
9c8d6856253f8da06b2cb5dc6bd89b6952fa03ed

View File

@ -466,6 +466,7 @@ struct callback_data {
FILE *pLog; /* Write log output here */
int *aiIndent; /* Array of indents used in MODE_Explain */
int nIndent; /* Size of array aiIndent[] */
int iIndent; /* Index of current op in aiIndent[] */
};
/*
@ -771,10 +772,10 @@ static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int
w = strlen30(azArg[i]);
}
if( i==1 && p->aiIndent && p->pStmt ){
int iOp = sqlite3_column_int(p->pStmt, 0);
if( iOp<p->nIndent ){
fprintf(p->out, "%*.s", p->aiIndent[iOp], "");
if( p->iIndent<p->nIndent ){
fprintf(p->out, "%*.s", p->aiIndent[p->iIndent], "");
}
p->iIndent++;
}
if( w<0 ){
fprintf(p->out,"%*.*s%s",-w,-w,
@ -1184,7 +1185,7 @@ static void explain_data_prepare(struct callback_data *p, sqlite3_stmt *pSql){
const char *z; /* Used to check if this is an EXPLAIN */
int *abYield = 0; /* True if op is an OP_Yield */
int nAlloc = 0; /* Allocated size of p->aiIndent[], abYield */
int iOp;
int iOp; /* Index of operation in p->aiIndent[] */
const char *azNext[] = { "Next", "Prev", "VPrev", "VNext", "SorterNext", 0 };
const char *azYield[] = { "Yield", "SeekLt", "SeekGt", "RowSetRead", 0 };
@ -1199,8 +1200,16 @@ static void explain_data_prepare(struct callback_data *p, sqlite3_stmt *pSql){
for(iOp=0; SQLITE_ROW==sqlite3_step(pSql); iOp++){
int i;
int iAddr = sqlite3_column_int(pSql, 0);
const char *zOp = (const char*)sqlite3_column_text(pSql, 1);
/* Set p2 to the P2 field of the current opcode. Then, assuming that
** p2 is an instruction address, set variable p2op to the index of that
** instruction in the aiIndent[] array. p2 and p2op may be different if
** the current instruction is part of a sub-program generated by an
** SQL trigger or foreign key. */
int p2 = sqlite3_column_int(pSql, 3);
int p2op = (p2 + (iOp-iAddr));
/* Grow the p->aiIndent array as required */
if( iOp>=nAlloc ){
@ -1213,13 +1222,14 @@ static void explain_data_prepare(struct callback_data *p, sqlite3_stmt *pSql){
p->nIndent = iOp+1;
if( str_in_array(zOp, azNext) ){
for(i=p2; i<iOp; i++) p->aiIndent[i] += 2;
for(i=p2op; i<iOp; i++) p->aiIndent[i] += 2;
}
if( str_in_array(zOp, azGoto) && p2<p->nIndent && abYield[p2] ){
for(i=p2+1; i<iOp; i++) p->aiIndent[i] += 2;
if( str_in_array(zOp, azGoto) && p2op<p->nIndent && abYield[p2op] ){
for(i=p2op; i<iOp; i++) p->aiIndent[i] += 2;
}
}
p->iIndent = 0;
sqlite3_free(abYield);
sqlite3_reset(pSql);
}
@ -1231,6 +1241,7 @@ static void explain_data_delete(struct callback_data *p){
sqlite3_free(p->aiIndent);
p->aiIndent = 0;
p->nIndent = 0;
p->iIndent = 0;
}
/*