Re: Values list-of-targetlists patch for comments (was Re: [HACKERS] 8.2 features?) - Mailing list pgsql-patches

From Tom Lane
Subject Re: Values list-of-targetlists patch for comments (was Re: [HACKERS] 8.2 features?)
Date
Msg-id 28402.1154486324@sss.pgh.pa.us
Whole thread Raw
In response to Re: Values list-of-targetlists patch for comments (was Re:  (Gavin Sherry <swm@linuxworld.com.au>)
List pgsql-patches
Gavin Sherry <swm@linuxworld.com.au> writes:
> Is this intentional:

> template1=# values(1), (2);
>  column1
> ---------
>        1
>        2
> (2 rows)

You bet.  VALUES is parallel to SELECT in the SQL grammar, so AFAICS
it should be legal anywhere you can write SELECT.

The basic productions in the spec's grammar are respectively

         <query specification> ::=
              SELECT [ <set quantifier> ] <select list>
                <table expression>

and

         <table value constructor> ::=
              VALUES <row value expression list>

and both of them link into the rest of the grammar here:

         <simple table> ::=
                <query specification>
              | <table value constructor>
              | <explicit table>

There is no construct I can find in the spec grammar that allows
<query specification> but not <table value constructor>.  QED.

Try some stuff like
    DECLARE c CURSOR FOR VALUES ...
    WHERE foo IN (VALUES ...


            regards, tom lane

pgsql-patches by date:

Previous
From: Christopher Browne
Date:
Subject: Re: Replication Documentation
Next
From: "Joshua D. Drake"
Date:
Subject: Re: Replication Documentation