Per SQL spec (in particular, the grammar in SQL:2008 7.13) we should allow
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 6 Jul 2009 02:58:40 +0000 (02:58 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 6 Jul 2009 02:58:40 +0000 (02:58 +0000)
parentheses around the <query expression body> that follows a WITH clause, eg
with cte(foo) as ( values(0) ) ((select foo from cte));
This seems to be just an oversight/thinko in gram.y.  Noted while
experimenting with bug #4902.

src/backend/parser/gram.y

index ac17b93bf6863115a54496fcdf9bb2a6e7c15a20..20ab0bac2afa791781c91e107ab0154b78678405 100644 (file)
@@ -6879,7 +6879,7 @@ select_no_parens:
                                                                                NULL);
                                        $$ = $1;
                                }
-                       | with_clause simple_select
+                       | with_clause select_clause
                                {
                                        insertSelectOptions((SelectStmt *) $2, NULL, NIL,
                                                                                NULL, NULL,