TABLE command - Mailing list pgsql-hackers

From Peter Eisentraut
Subject TABLE command
Date
Msg-id 4909726F.8000800@gmx.net
Whole thread Raw
Responses Re: TABLE command
Re: TABLE command
Re: TABLE command
Re: TABLE command
List 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 by date:

Previous
From: "Joshua D. Drake"
Date:
Subject: Re: pre-MED
Next
From: Heikki Linnakangas
Date:
Subject: Re: Updating FSM on recovery