Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: third_party/sqlite/sqlite-src-3080704/src/walker.c

Issue 883353008: [sql] Import reference version of SQLite 3.8.7.4. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Hold back encoding change which is messing up patch. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 **
11 ************************************************************************* 11 *************************************************************************
12 ** This file contains routines used for walking the parser tree for 12 ** This file contains routines used for walking the parser tree for
13 ** an SQL statement. 13 ** an SQL statement.
14 */ 14 */
15 #include "sqliteInt.h" 15 #include "sqliteInt.h"
16 #include <stdlib.h> 16 #include <stdlib.h>
17 #include <string.h> 17 #include <string.h>
18 18
19 19
20 /* 20 /*
21 ** Walk an expression tree. Invoke the callback once for each node 21 ** Walk an expression tree. Invoke the callback once for each node
22 ** of the expression, while decending. (In other words, the callback 22 ** of the expression, while descending. (In other words, the callback
23 ** is invoked before visiting children.) 23 ** is invoked before visiting children.)
24 ** 24 **
25 ** The return value from the callback should be one of the WRC_* 25 ** The return value from the callback should be one of the WRC_*
26 ** constants to specify how to proceed with the walk. 26 ** constants to specify how to proceed with the walk.
27 ** 27 **
28 ** WRC_Continue Continue descending down the tree. 28 ** WRC_Continue Continue descending down the tree.
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 int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){
40 int rc; 40 int rc;
41 if( pExpr==0 ) return WRC_Continue; 41 if( pExpr==0 ) return WRC_Continue;
42 testcase( ExprHasProperty(pExpr, EP_TokenOnly) ); 42 testcase( ExprHasProperty(pExpr, EP_TokenOnly) );
43 testcase( ExprHasProperty(pExpr, EP_Reduced) ); 43 testcase( ExprHasProperty(pExpr, EP_Reduced) );
44 rc = pWalker->xExprCallback(pWalker, pExpr); 44 rc = pWalker->xExprCallback(pWalker, pExpr);
45 if( rc==WRC_Continue 45 if( rc==WRC_Continue
46 && !ExprHasAnyProperty(pExpr,EP_TokenOnly) ){ 46 && !ExprHasProperty(pExpr,EP_TokenOnly) ){
47 if( sqlite3WalkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort; 47 if( sqlite3WalkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
48 if( sqlite3WalkExpr(pWalker, pExpr->pRight) ) return WRC_Abort; 48 if( sqlite3WalkExpr(pWalker, pExpr->pRight) ) return WRC_Abort;
49 if( ExprHasProperty(pExpr, EP_xIsSelect) ){ 49 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
50 if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort; 50 if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
51 }else{ 51 }else{
52 if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort; 52 if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
53 } 53 }
54 } 54 }
55 return rc & WRC_Abort; 55 return rc & WRC_Abort;
56 } 56 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 return WRC_Abort; 106 return WRC_Abort;
107 } 107 }
108 } 108 }
109 } 109 }
110 return WRC_Continue; 110 return WRC_Continue;
111 } 111 }
112 112
113 /* 113 /*
114 ** Call sqlite3WalkExpr() for every expression in Select statement p. 114 ** Call sqlite3WalkExpr() for every expression in Select statement p.
115 ** Invoke sqlite3WalkSelect() for subqueries in the FROM clause and 115 ** Invoke sqlite3WalkSelect() for subqueries in the FROM clause and
116 ** on the compound select chain, p->pPrior. 116 ** on the compound select chain, p->pPrior.
117 **
118 ** If it is not NULL, the xSelectCallback() callback is invoked before
119 ** the walk of the expressions and FROM clause. The xSelectCallback2()
120 ** method, if it is not NULL, is invoked following the walk of the
121 ** expressions and FROM clause.
117 ** 122 **
118 ** Return WRC_Continue under normal conditions. Return WRC_Abort if 123 ** Return WRC_Continue under normal conditions. Return WRC_Abort if
119 ** there is an abort request. 124 ** there is an abort request.
120 ** 125 **
121 ** If the Walker does not have an xSelectCallback() then this routine 126 ** If the Walker does not have an xSelectCallback() then this routine
122 ** is a no-op returning WRC_Continue. 127 ** is a no-op returning WRC_Continue.
123 */ 128 */
124 int sqlite3WalkSelect(Walker *pWalker, Select *p){ 129 int sqlite3WalkSelect(Walker *pWalker, Select *p){
125 int rc; 130 int rc;
126 if( p==0 || pWalker->xSelectCallback==0 ) return WRC_Continue; 131 if( p==0 || (pWalker->xSelectCallback==0 && pWalker->xSelectCallback2==0) ){
132 return WRC_Continue;
133 }
127 rc = WRC_Continue; 134 rc = WRC_Continue;
128 while( p ){ 135 pWalker->walkerDepth++;
129 rc = pWalker->xSelectCallback(pWalker, p); 136 while( p ){
130 if( rc ) break; 137 if( pWalker->xSelectCallback ){
131 if( sqlite3WalkSelectExpr(pWalker, p) ) return WRC_Abort; 138 rc = pWalker->xSelectCallback(pWalker, p);
132 if( sqlite3WalkSelectFrom(pWalker, p) ) return WRC_Abort; 139 if( rc ) break;
140 }
141 if( sqlite3WalkSelectExpr(pWalker, p)
142 || sqlite3WalkSelectFrom(pWalker, p)
143 ){
144 pWalker->walkerDepth--;
145 return WRC_Abort;
146 }
147 if( pWalker->xSelectCallback2 ){
148 pWalker->xSelectCallback2(pWalker, p);
149 }
133 p = p->pPrior; 150 p = p->pPrior;
134 } 151 }
152 pWalker->walkerDepth--;
135 return rc & WRC_Abort; 153 return rc & WRC_Abort;
136 } 154 }
OLDNEW
« no previous file with comments | « third_party/sqlite/sqlite-src-3080704/src/wal.c ('k') | third_party/sqlite/sqlite-src-3080704/src/where.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698