OLD | NEW |
1 /* | 1 /* |
2 ** 2008 August 16 | 2 ** 2008 August 16 |
3 ** | 3 ** |
4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
6 ** | 6 ** |
7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
10 ** | 10 ** |
(...skipping 18 matching lines...) Expand all Loading... |
29 ** | 29 ** |
30 ** WRC_Prune Do not descend into child nodes. But allow | 30 ** WRC_Prune Do not descend into child nodes. But allow |
31 ** the walk to continue with sibling nodes. | 31 ** the walk to continue with sibling nodes. |
32 ** | 32 ** |
33 ** WRC_Abort Do no more callbacks. Unwind the stack and | 33 ** WRC_Abort Do no more callbacks. Unwind the stack and |
34 ** return the top-level walk call. | 34 ** return the top-level walk call. |
35 ** | 35 ** |
36 ** The return value from this routine is WRC_Abort to abandon the tree walk | 36 ** The return value from this routine is WRC_Abort to abandon the tree walk |
37 ** and WRC_Continue to continue. | 37 ** and WRC_Continue to continue. |
38 */ | 38 */ |
39 int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){ | 39 static SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){ |
40 int rc; | 40 int rc; |
41 if( pExpr==0 ) return WRC_Continue; | |
42 testcase( ExprHasProperty(pExpr, EP_TokenOnly) ); | 41 testcase( ExprHasProperty(pExpr, EP_TokenOnly) ); |
43 testcase( ExprHasProperty(pExpr, EP_Reduced) ); | 42 testcase( ExprHasProperty(pExpr, EP_Reduced) ); |
44 rc = pWalker->xExprCallback(pWalker, pExpr); | 43 rc = pWalker->xExprCallback(pWalker, pExpr); |
45 if( rc==WRC_Continue | 44 if( rc || ExprHasProperty(pExpr,(EP_TokenOnly|EP_Leaf)) ){ |
46 && !ExprHasProperty(pExpr,EP_TokenOnly) ){ | 45 return rc & WRC_Abort; |
47 if( sqlite3WalkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort; | |
48 if( sqlite3WalkExpr(pWalker, pExpr->pRight) ) return WRC_Abort; | |
49 if( ExprHasProperty(pExpr, EP_xIsSelect) ){ | |
50 if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort; | |
51 }else{ | |
52 if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort; | |
53 } | |
54 } | 46 } |
55 return rc & WRC_Abort; | 47 if( pExpr->pLeft && walkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort; |
| 48 if( pExpr->pRight && walkExpr(pWalker, pExpr->pRight) ) return WRC_Abort; |
| 49 if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| 50 if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort; |
| 51 }else if( pExpr->x.pList ){ |
| 52 if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort; |
| 53 } |
| 54 return WRC_Continue; |
| 55 } |
| 56 int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){ |
| 57 return pExpr ? walkExpr(pWalker,pExpr) : WRC_Continue; |
56 } | 58 } |
57 | 59 |
58 /* | 60 /* |
59 ** Call sqlite3WalkExpr() for every expression in list p or until | 61 ** Call sqlite3WalkExpr() for every expression in list p or until |
60 ** an abort request is seen. | 62 ** an abort request is seen. |
61 */ | 63 */ |
62 int sqlite3WalkExprList(Walker *pWalker, ExprList *p){ | 64 int sqlite3WalkExprList(Walker *pWalker, ExprList *p){ |
63 int i; | 65 int i; |
64 struct ExprList_item *pItem; | 66 struct ExprList_item *pItem; |
65 if( p ){ | 67 if( p ){ |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 return WRC_Abort; | 152 return WRC_Abort; |
151 } | 153 } |
152 if( pWalker->xSelectCallback2 ){ | 154 if( pWalker->xSelectCallback2 ){ |
153 pWalker->xSelectCallback2(pWalker, p); | 155 pWalker->xSelectCallback2(pWalker, p); |
154 } | 156 } |
155 p = p->pPrior; | 157 p = p->pPrior; |
156 } | 158 } |
157 pWalker->walkerDepth--; | 159 pWalker->walkerDepth--; |
158 return rc & WRC_Abort; | 160 return rc & WRC_Abort; |
159 } | 161 } |
OLD | NEW |