Index: third_party/sqlite/src/src/walker.c |
diff --git a/third_party/sqlite/src/src/walker.c b/third_party/sqlite/src/src/walker.c |
index c95a9c169db3125ad877cca14d88abd13495ac21..e30bb60b5a493f19da3ddc117cf6b8d2c03e89c6 100644 |
--- a/third_party/sqlite/src/src/walker.c |
+++ b/third_party/sqlite/src/src/walker.c |
@@ -19,7 +19,7 @@ |
/* |
** Walk an expression tree. Invoke the callback once for each node |
-** of the expression, while decending. (In other words, the callback |
+** of the expression, while descending. (In other words, the callback |
** is invoked before visiting children.) |
** |
** The return value from the callback should be one of the WRC_* |
@@ -43,7 +43,7 @@ int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){ |
testcase( ExprHasProperty(pExpr, EP_Reduced) ); |
rc = pWalker->xExprCallback(pWalker, pExpr); |
if( rc==WRC_Continue |
- && !ExprHasAnyProperty(pExpr,EP_TokenOnly) ){ |
+ && !ExprHasProperty(pExpr,EP_TokenOnly) ){ |
if( sqlite3WalkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort; |
if( sqlite3WalkExpr(pWalker, pExpr->pRight) ) return WRC_Abort; |
if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
@@ -113,7 +113,12 @@ int sqlite3WalkSelectFrom(Walker *pWalker, Select *p){ |
/* |
** Call sqlite3WalkExpr() for every expression in Select statement p. |
** Invoke sqlite3WalkSelect() for subqueries in the FROM clause and |
-** on the compound select chain, p->pPrior. |
+** on the compound select chain, p->pPrior. |
+** |
+** If it is not NULL, the xSelectCallback() callback is invoked before |
+** the walk of the expressions and FROM clause. The xSelectCallback2() |
+** method, if it is not NULL, is invoked following the walk of the |
+** expressions and FROM clause. |
** |
** Return WRC_Continue under normal conditions. Return WRC_Abort if |
** there is an abort request. |
@@ -123,14 +128,27 @@ int sqlite3WalkSelectFrom(Walker *pWalker, Select *p){ |
*/ |
int sqlite3WalkSelect(Walker *pWalker, Select *p){ |
int rc; |
- if( p==0 || pWalker->xSelectCallback==0 ) return WRC_Continue; |
+ if( p==0 || (pWalker->xSelectCallback==0 && pWalker->xSelectCallback2==0) ){ |
+ return WRC_Continue; |
+ } |
rc = WRC_Continue; |
- while( p ){ |
- rc = pWalker->xSelectCallback(pWalker, p); |
- if( rc ) break; |
- if( sqlite3WalkSelectExpr(pWalker, p) ) return WRC_Abort; |
- if( sqlite3WalkSelectFrom(pWalker, p) ) return WRC_Abort; |
+ pWalker->walkerDepth++; |
+ while( p ){ |
+ if( pWalker->xSelectCallback ){ |
+ rc = pWalker->xSelectCallback(pWalker, p); |
+ if( rc ) break; |
+ } |
+ if( sqlite3WalkSelectExpr(pWalker, p) |
+ || sqlite3WalkSelectFrom(pWalker, p) |
+ ){ |
+ pWalker->walkerDepth--; |
+ return WRC_Abort; |
+ } |
+ if( pWalker->xSelectCallback2 ){ |
+ pWalker->xSelectCallback2(pWalker, p); |
+ } |
p = p->pPrior; |
} |
+ pWalker->walkerDepth--; |
return rc & WRC_Abort; |
} |