Add code to select.c for printing the contents of parse-tree structures.
The code is normally omitted. You must compile with -DSQLITE_TEST or -DSQLITE_DEBUG to enable it. (CVS 3606) FossilOrigin-Name: 1b26d6875612a0ed25d6e293f005ea4966692759
This commit is contained in:
parent
0ee5a1e763
commit
485f00391b
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\sa\s(harmless)\sassertion\sfault\son\snested\sviews\swhere\sthe\sinner\sviews\nare\scompound\sselects.\s\sTicket\s#2192.\s(CVS\s3605)
|
||||
D 2007-01-26T19:04:00
|
||||
C Add\scode\sto\sselect.c\sfor\sprinting\sthe\scontents\sof\sparse-tree\sstructures.\nThe\scode\sis\snormally\somitted.\s\sYou\smust\scompile\swith\s-DSQLITE_TEST\nor\s-DSQLITE_DEBUG\sto\senable\sit.\s(CVS\s3606)
|
||||
D 2007-01-26T19:23:33
|
||||
F Makefile.in 7fa74bf4359aa899da5586e394d17735f221315f
|
||||
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||
@ -90,9 +90,9 @@ F src/pager.h 2e6d42f4ae004ae748a037b8468112b851c447a7
|
||||
F src/parse.y 2f571c5f6219428d7fb08737db3d113742b1cceb
|
||||
F src/pragma.c fd4df6cf0857dd78a7cb5be5f9805419b53ae7a0
|
||||
F src/prepare.c 484389c6811415b8f23d259ac9c029613e1c72c3
|
||||
F src/printf.c b179b6ed12f793e028dd169e2e2e2b2a37eedc63
|
||||
F src/printf.c aade23a789d7cc88b397ec0d33a0a01a33a7a9c1
|
||||
F src/random.c 6119474a6f6917f708c1dee25b9a8e519a620e88
|
||||
F src/select.c d46aceb4eb0c3e9ca7d6c9a2b65f4c19723f9763
|
||||
F src/select.c 628f49827d5a94ed9b6246efb8dc9f5c24e413f1
|
||||
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
|
||||
F src/shell.c d13ca007cd18192c07a668aeddcdd6a9fe639be9
|
||||
F src/sqlite.h.in 6b7383baf76070214f6381f603328ca9b22a7fae
|
||||
@ -428,7 +428,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
|
||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
||||
P e1fae43c89253fe5ca85bd149cd7697234f9aa91
|
||||
R 740aa5a4d6cddbb1dfb22766971a0377
|
||||
P 942e7193bbf1ffe9a703891d175e016631e2ad5c
|
||||
R 86392c521ecdc1f677b7dec2a6adf709
|
||||
U drh
|
||||
Z 72ba24e0b38388758e3d22c3170f3238
|
||||
Z 3de0eae131c19c851cc5eabe5fd41eaa
|
||||
|
@ -1 +1 @@
|
||||
942e7193bbf1ffe9a703891d175e016631e2ad5c
|
||||
1b26d6875612a0ed25d6e293f005ea4966692759
|
@ -857,7 +857,7 @@ void sqlite3DebugPrintf(const char *zFormat, ...){
|
||||
va_start(ap, zFormat);
|
||||
base_vprintf(0, 0, zBuf, sizeof(zBuf), zFormat, ap);
|
||||
va_end(ap);
|
||||
fprintf(stdout,"%d: %s", getpid(), zBuf);
|
||||
fprintf(stdout,"%s", zBuf);
|
||||
fflush(stdout);
|
||||
}
|
||||
#endif
|
||||
|
98
src/select.c
98
src/select.c
@ -12,7 +12,7 @@
|
||||
** This file contains C code routines that are called by the parser
|
||||
** to handle SELECT statements in SQLite.
|
||||
**
|
||||
** $Id: select.c,v 1.324 2007/01/26 19:04:00 drh Exp $
|
||||
** $Id: select.c,v 1.325 2007/01/26 19:23:33 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@ -3300,3 +3300,99 @@ select_end:
|
||||
sqliteFree(sAggInfo.aFunc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
|
||||
/*
|
||||
*******************************************************************************
|
||||
** The following code is used for testing and debugging only. The code
|
||||
** that follows does not appear in normal builds.
|
||||
**
|
||||
** These routines are used to print out the content of all or part of a
|
||||
** parse structures such as Select or Expr. Such printouts are useful
|
||||
** for helping to understand what is happening inside the code generator
|
||||
** during the execution of complex SELECT statements.
|
||||
**
|
||||
** These routine are not called anywhere from within the normal
|
||||
** code base. Then are intended to be called from within the debugger
|
||||
** or from temporary "printf" statements inserted for debugging.
|
||||
*/
|
||||
void sqlite3PrintExpr(Expr *p){
|
||||
if( p->token.z && p->token.n>0 ){
|
||||
sqlite3DebugPrintf("(%.*s", p->token.n, p->token.z);
|
||||
}else{
|
||||
sqlite3DebugPrintf("(%d", p->op);
|
||||
}
|
||||
if( p->pLeft ){
|
||||
sqlite3DebugPrintf(" ");
|
||||
sqlite3PrintExpr(p->pLeft);
|
||||
}
|
||||
if( p->pRight ){
|
||||
sqlite3DebugPrintf(" ");
|
||||
sqlite3PrintExpr(p->pRight);
|
||||
}
|
||||
sqlite3DebugPrintf(")");
|
||||
}
|
||||
void sqlite3PrintExprList(ExprList *pList){
|
||||
int i;
|
||||
for(i=0; i<pList->nExpr; i++){
|
||||
sqlite3PrintExpr(pList->a[i].pExpr);
|
||||
if( i<pList->nExpr-1 ){
|
||||
sqlite3DebugPrintf(", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
void sqlite3PrintSelect(Select *p, int indent){
|
||||
sqlite3DebugPrintf("%*sSELECT(%p) ", indent, "", p);
|
||||
sqlite3PrintExprList(p->pEList);
|
||||
sqlite3DebugPrintf("\n");
|
||||
if( p->pSrc ){
|
||||
char *zPrefix;
|
||||
int i;
|
||||
zPrefix = "FROM";
|
||||
for(i=0; i<p->pSrc->nSrc; i++){
|
||||
struct SrcList_item *pItem = &p->pSrc->a[i];
|
||||
sqlite3DebugPrintf("%*s ", indent+6, zPrefix);
|
||||
zPrefix = "";
|
||||
if( pItem->pSelect ){
|
||||
sqlite3DebugPrintf("(\n");
|
||||
sqlite3PrintSelect(pItem->pSelect, indent+10);
|
||||
sqlite3DebugPrintf("%*s)", indent+8, "");
|
||||
}else if( pItem->zName ){
|
||||
sqlite3DebugPrintf("%s", pItem->zName);
|
||||
}
|
||||
if( pItem->pTab ){
|
||||
sqlite3DebugPrintf("(table: %s)", pItem->pTab->zName);
|
||||
}
|
||||
if( pItem->zAlias ){
|
||||
sqlite3DebugPrintf(" AS %s", pItem->zAlias);
|
||||
}
|
||||
if( i<p->pSrc->nSrc-1 ){
|
||||
sqlite3DebugPrintf(",");
|
||||
}
|
||||
sqlite3DebugPrintf("\n");
|
||||
}
|
||||
}
|
||||
if( p->pWhere ){
|
||||
sqlite3DebugPrintf("%*s WHERE ", indent, "");
|
||||
sqlite3PrintExpr(p->pWhere);
|
||||
sqlite3DebugPrintf("\n");
|
||||
}
|
||||
if( p->pGroupBy ){
|
||||
sqlite3DebugPrintf("%*s GROUP BY ", indent, "");
|
||||
sqlite3PrintExprList(p->pGroupBy);
|
||||
sqlite3DebugPrintf("\n");
|
||||
}
|
||||
if( p->pHaving ){
|
||||
sqlite3DebugPrintf("%*s HAVING ", indent, "");
|
||||
sqlite3PrintExpr(p->pHaving);
|
||||
sqlite3DebugPrintf("\n");
|
||||
}
|
||||
if( p->pOrderBy ){
|
||||
sqlite3DebugPrintf("%*s ORDER BY ", indent, "");
|
||||
sqlite3PrintExprList(p->pOrderBy);
|
||||
sqlite3DebugPrintf("\n");
|
||||
}
|
||||
}
|
||||
/* End of the structure debug printing code
|
||||
*****************************************************************************/
|
||||
#endif /* defined(SQLITE_TEST) || defined(SQLITE_DEBUG) */
|
||||
|
Loading…
x
Reference in New Issue
Block a user