|
17 | 17 | * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
|
18 | 18 | * Portions Copyright (c) 1994, Regents of the University of California
|
19 | 19 | *
|
20 |
| - *$PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.400 2010/01/15 22:36:33 tgl Exp $ |
| 20 | + *$PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.401 2010/02/12 22:48:56 tgl Exp $ |
21 | 21 | *
|
22 | 22 | *-------------------------------------------------------------------------
|
23 | 23 | */
|
@@ -783,19 +783,19 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt)
|
783 | 783 |
|
784 | 784 | qry->commandType=CMD_SELECT;
|
785 | 785 |
|
786 |
| -/* make FOR UPDATE/FOR SHARE info available to addRangeTableEntry */ |
787 |
| -pstate->p_locking_clause=stmt->lockingClause; |
788 |
| - |
789 |
| -/* make WINDOW info available for window functions, too */ |
790 |
| -pstate->p_windowdefs=stmt->windowClause; |
791 |
| - |
792 |
| -/* process the WITH clause */ |
| 786 | +/* process the WITH clause independently of all else */ |
793 | 787 | if (stmt->withClause)
|
794 | 788 | {
|
795 | 789 | qry->hasRecursive=stmt->withClause->recursive;
|
796 | 790 | qry->cteList=transformWithClause(pstate,stmt->withClause);
|
797 | 791 | }
|
798 | 792 |
|
| 793 | +/* make FOR UPDATE/FOR SHARE info available to addRangeTableEntry */ |
| 794 | +pstate->p_locking_clause=stmt->lockingClause; |
| 795 | + |
| 796 | +/* make WINDOW info available for window functions, too */ |
| 797 | +pstate->p_windowdefs=stmt->windowClause; |
| 798 | + |
799 | 799 | /* process the FROM clause */
|
800 | 800 | transformFromClause(pstate,stmt->fromClause);
|
801 | 801 |
|
@@ -929,7 +929,7 @@ transformValuesClause(ParseState *pstate, SelectStmt *stmt)
|
929 | 929 | Assert(stmt->windowClause==NIL);
|
930 | 930 | Assert(stmt->op==SETOP_NONE);
|
931 | 931 |
|
932 |
| -/* process the WITH clause */ |
| 932 | +/* process the WITH clauseindependently of all else*/ |
933 | 933 | if (stmt->withClause)
|
934 | 934 | {
|
935 | 935 | qry->hasRecursive=stmt->withClause->recursive;
|
@@ -1149,6 +1149,13 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
|
1149 | 1149 |
|
1150 | 1150 | qry->commandType=CMD_SELECT;
|
1151 | 1151 |
|
| 1152 | +/* process the WITH clause independently of all else */ |
| 1153 | +if (stmt->withClause) |
| 1154 | +{ |
| 1155 | +qry->hasRecursive=stmt->withClause->recursive; |
| 1156 | +qry->cteList=transformWithClause(pstate,stmt->withClause); |
| 1157 | +} |
| 1158 | + |
1152 | 1159 | /*
|
1153 | 1160 | * Find leftmost leaf SelectStmt; extract the one-time-only items from it
|
1154 | 1161 | * and from the top-level node.
|
@@ -1188,13 +1195,6 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
|
1188 | 1195 | (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
1189 | 1196 | errmsg("SELECT FOR UPDATE/SHARE is not allowed with UNION/INTERSECT/EXCEPT")));
|
1190 | 1197 |
|
1191 |
| -/* process the WITH clause */ |
1192 |
| -if (stmt->withClause) |
1193 |
| -{ |
1194 |
| -qry->hasRecursive=stmt->withClause->recursive; |
1195 |
| -qry->cteList=transformWithClause(pstate,stmt->withClause); |
1196 |
| -} |
1197 |
| - |
1198 | 1198 | /*
|
1199 | 1199 | * Recursively transform the components of the tree.
|
1200 | 1200 | */
|
|