]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Further comments on WITH-clause processing routines in select.c.
authordrh <drh@noemail.net>
Wed, 15 Jan 2014 18:35:52 +0000 (18:35 +0000)
committerdrh <drh@noemail.net>
Wed, 15 Jan 2014 18:35:52 +0000 (18:35 +0000)
FossilOrigin-Name: c948384dfdd9f68a832d5a452af44f35337f66e7

manifest
manifest.uuid
src/select.c
src/sqliteInt.h

index 7b7db93b32247ceb250531d88f7ea151088b48bb..b46bf3bc8359dd7e9e57f64fb87d976a229ae33a 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sa\sheader\scomment\sto\sthe\ssearchWith()\sroutine.
-D 2014-01-15T18:23:00.349
+C Further\scomments\son\sWITH-clause\sprocessing\sroutines\sin\sselect.c.
+D 2014-01-15T18:35:52.482
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -219,12 +219,12 @@ F src/printf.c 85d07756e45d7496d19439dcae3e6e9e0090f269
 F src/random.c d10c1f85b6709ca97278428fd5db5bbb9c74eece
 F src/resolve.c 41d0cf644aa98131204e6243e108829797f038ab
 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
-F src/select.c 240e9795df3fbaca15e2fa9c3b0a95796e60e5d7
+F src/select.c 6bdb90db59e3e8277b8953e4cd3df01ccc253d70
 F src/shell.c a3541193d5fce37e91dad8ef46a9505aa7c9b344
 F src/sqlite.h.in d94a8b89522f526ba711182ee161e06f8669bcc9
 F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e
 F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc
-F src/sqliteInt.h 31bcde5190ca666e4873188a9039ac6ff017a0a8
+F src/sqliteInt.h d91991457386b4a1414fa96f51a9a5bfd2b8606d
 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
 F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158
 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
@@ -1150,7 +1150,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
-P 28aa6db8c878655255dbfb618f8d65be78e3d7e5
-R 19b67b003a2571a98d1dce07a86e95af
+P d9ae0f5d9f8230ca7ca10ebed300e2f6635a0614
+R de20d9dcfc2fdd09cc5e9c05dc6deb70
 U drh
-Z 5c4be2977b3d2e13595e058b593ca068
+Z 626093c1115d7d3f00c431f06f508aa1
index 3f055fe737bd6bf3a0886c6a082dfe3ac9bbef08..fc2d2ece546f1701cde80f68ef4a02815550bf4a 100644 (file)
@@ -1 +1 @@
-d9ae0f5d9f8230ca7ca10ebed300e2f6635a0614
\ No newline at end of file
+c948384dfdd9f68a832d5a452af44f35337f66e7
\ No newline at end of file
index 3a30031c006da9bd0a6acb148900957d73f2b707..0984bd30ed40e22f905627811807d3751e1d4b45 100644 (file)
@@ -3482,9 +3482,9 @@ static int convertCompoundSelectToSubquery(Walker *pWalker, Select *p){
   return WRC_Continue;
 }
 
-/* If the table identified by p is a transient table of 
+/* If the table identified by FROM clause element p is really
 ** a common-table-expression (CTE) then return a pointer to the
-** CTE that defines table p.  If p is not a CTE, then return NULL.
+** CTE definition for that table.
 */
 static struct Cte *searchWith(Parse *pParse, struct SrcList_item *p){
   if( p->zDatabase==0 ){
@@ -3503,6 +3503,11 @@ static struct Cte *searchWith(Parse *pParse, struct SrcList_item *p){
   return 0;
 }
 
+/* The code generator maintains a stack of active WITH clauses
+** with the inner-most WITH clause being at the top of the stack.
+**
+** These routines push and pull WITH clauses on the stack.
+*/
 void sqlite3WithPush(Parse *pParse, With *pWith){
   if( pWith ){
     pWith->pOuter = pParse->pWith;
@@ -3516,6 +3521,9 @@ static void withPop(Parse *pParse, With *pWith){
   }
 }
 
+/* Push or pull a CTE on the stack of all CTEs currently being
+** coded.
+*/
 static int ctePush(Parse *pParse, struct Cte *pCte){
   if( pCte ){
     struct Cte *p;
@@ -3533,7 +3541,6 @@ static int ctePush(Parse *pParse, struct Cte *pCte){
   }
   return SQLITE_OK;
 }
-
 static void ctePop(Parse *pParse, struct Cte *pCte){
   if( pCte ){
     assert( pParse->pCte==pCte );
index c52013f87f1192be063c91b895497fbb9525e8de..3973c0283086159d943a6bb1949e7799f0f7ec8b 100644 (file)
@@ -2640,18 +2640,18 @@ int sqlite3WalkSelectFrom(Walker*, Select*);
 #define WRC_Abort       2   /* Abandon the tree walk */
 
 /*
-** An instance of this structure represents a set of CTEs (common table 
-** expressions) created by a single WITH clause.
+** An instance of this structure represents a set of on or more CTEs
+** (common table expressions) created by a single WITH clause.
 */
 struct With {
-  int nCte;                       /* Number of CTEs */
+  int nCte;                       /* Number of CTEs in the WITH clause */
   With *pOuter;                   /* Containing WITH clause, or NULL */
-  struct Cte {
-    char *zName;                  /* Name of this CTE */
-    ExprList *pCols;              /* List of explicit column names, or NULL */
-    Select *pSelect;              /* The contents of the CTE */
-    struct Cte *pOuterCte;
-    Table *pTab;
+  struct Cte {                    /* For each CTE in the WITH clause.... */
+    char *zName;                    /* Name of this CTE */
+    ExprList *pCols;                /* List of explicit column names, or NULL */
+    Select *pSelect;                /* The definition of this CTE */
+    struct Cte *pOuterCte;          /* Next WITH clause in outer context */
+    Table *pTab;                    /* Table object for this CTE */
   } a[1];
 };