Re: syntax error WITH ORDINALITY

From: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: syntax error WITH ORDINALITY
Date: 2014-07-23 18:36:04
Message-ID: 1406140564415-5812568.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Simon Riggs wrote
> postgres=# select * from unnest(ARRAY[1,2,3]) with ordinality;
>
> unnest | ordinality
> --------+------------
> 1 | 1
> 2 | 2
> 3 | 3
>
> postgres=# select unnest(ARRAY[1,2,3]) with ordinality;
>
> ERROR: syntax error at or near "ordinality"
> LINE 1: select unnest(ARRAY[1,2,3]) with ordinality;
>
> though this works
>
> postgres=# select unnest(ARRAY[1,2,3]);
>
> unnest
> --------
> 1
> 2
> 3
>
> The manual
> http://www.postgresql.org/docs/devel/static/queries-table-expressions.html#QUERIES-TABLEFUNCTIONS
> says
> "Columns returned by table functions can be included in SELECT, JOIN,
> or WHERE clauses in the same manner as columns of a table, view, or
> subquery."
> There is no qualification of that for WITH ORDINALITY, nor an example

A function used in the select-list of a query does not constitute a "table
expression" and so is not covered by this particular section of the
documentation.

From your link:

"Table functions are functions that produce a set of rows [...]. They are
used like a table, view, or subquery in the FROM clause of a query."

So even if the documentation could be improved altering this section to deal
with select-list invocations of set-returning functions seems like an
overkill and verbose solution.

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/syntax-error-WITH-ORDINALITY-tp5812550p5812568.html
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2014-07-23 19:12:47 Re: BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars
Previous Message fleminra 2014-07-23 17:56:29 BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars