TABLE command

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема TABLE command
Дата
Msg-id 4909726F.8000800@gmx.net
обсуждение
Ответы Re: TABLE command
Re: TABLE command
Re: TABLE command
Re: TABLE command
Список pgsql-hackers
If I read this right, SQL would allow writing

TABLE foo;

as a top-level command, equivalent to SELECT * FROM foo; (see production
<explicit table>).  It can be used whereever a SELECT or VALUES can be used.

This is probably about as useless as some of my other recent patches,
but the implementation is simple (see attachment), so we could add it.
Comments?
diff -ur ../cvs-pgsql/src/backend/parser/gram.y ./src/backend/parser/gram.y
--- ../cvs-pgsql/src/backend/parser/gram.y    2008-10-29 13:37:47.000000000 +0200
+++ ./src/backend/parser/gram.y    2008-10-29 16:49:09.000000000 +0200
@@ -6416,6 +6416,25 @@
                     $$ = (Node *)n;
                 }
             | values_clause                            { $$ = $1; }
+            | TABLE table_ref
+                {
+                    /* same as SELECT * FROM table_ref */
+                    ColumnRef *cr = makeNode(ColumnRef);
+                    ResTarget *rt = makeNode(ResTarget);
+                    SelectStmt *n = makeNode(SelectStmt);
+
+                    cr->fields = list_make1(makeNode(A_Star));
+                    cr->location = -1;
+
+                    rt->name = NULL;
+                    rt->indirection = NIL;
+                    rt->val = (Node *)cr;
+                    rt->location = -1;
+
+                    n->targetList = list_make1(rt);
+                    n->fromClause = list_make1($2);
+                    $$ = (Node *)n;
+                }
             | select_clause UNION opt_all select_clause
                 {
                     $$ = makeSetOp(SETOP_UNION, $3, $1, $4);

В списке pgsql-hackers по дате отправления: