1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-08 03:22:21 +03:00

Begin adding the data-structure explaining subsystem. All is contained within

FossilOrigin-Name: 79ae51c5b1b20ed0a425a87e65a32a096a80b7e1
This commit is contained in:
drh
2011-12-06 19:44:51 +00:00
parent ed51f29774
commit 7e02e5e6b5
13 changed files with 297 additions and 89 deletions

View File

@@ -2939,6 +2939,56 @@ int sqlite3ExprCodeAndCache(Parse *pParse, Expr *pExpr, int target){
return inReg;
}
#if defined(SQLITE_DEBUG)
/*
** Generate a human-readable explanation of an expression tree.
*/
void sqlite3ExplainExpr(Vdbe *pOut, Expr *p){
if( p==0 ){
sqlite3ExplainPrintf(pOut, "(C-null)");
return;
}
if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){
sqlite3ExplainPrintf(pOut, "(%s", p->u.zToken);
}else{
sqlite3ExplainPrintf(pOut, "(op=%d", p->op);
}
if( p->pLeft ){
sqlite3ExplainPrintf(pOut, " left=");
sqlite3ExplainExpr(pOut, p->pLeft);
}
if( p->pRight ){
sqlite3ExplainPrintf(pOut, " right=");
sqlite3ExplainExpr(pOut, p->pRight);
}
sqlite3ExplainPrintf(pOut, ")");
}
#endif /* defined(SQLITE_DEBUG) */
#if defined(SQLITE_DEBUG)
/*
** Generate a human-readable explanation of an expression list.
*/
void sqlite3ExplainExprList(Vdbe *pOut, ExprList *pList){
int i;
if( pList==0 ){
sqlite3ExplainPrintf(pOut, "(empty-list)");
return;
}
sqlite3ExplainPush(pOut);
for(i=0; i<pList->nExpr; i++){
sqlite3ExplainPrintf(pOut, "%02d: ", i);
sqlite3ExplainPush(pOut);
sqlite3ExplainExpr(pOut, pList->a[i].pExpr);
sqlite3ExplainPop(pOut);
if( i<pList->nExpr-1 ){
sqlite3ExplainNL(pOut);
}
}
sqlite3ExplainPop(pOut);
}
#endif /* SQLITE_DEBUG */
/*
** Return TRUE if pExpr is an constant expression that is appropriate
** for factoring out of a loop. Appropriate expressions are: