pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
syntax error WITH ORDINALITY
4+ messages / 3 participants
[nested] [flat]

* syntax error WITH ORDINALITY
@ 2014-07-23 17:12  Simon Riggs <simon@2ndQuadrant.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Simon Riggs @ 2014-07-23 17:12 UTC (permalink / raw)
  To: pgsql-bugs

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

So either the manual is wrong, or the syntax is.

Also, WITH ORDINALITY is not mentioned here...
http://www.postgresql.org/docs/devel/static/functions-array.html

-- 
 Simon Riggs                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: syntax error WITH ORDINALITY
@ 2014-07-23 17:23  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Simon Riggs <simon@2ndQuadrant.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Tom Lane @ 2014-07-23 17:23 UTC (permalink / raw)
  To: Simon Riggs <simon@2ndQuadrant.com>; +Cc: pgsql-bugs

Simon Riggs <simon@2ndQuadrant.com> writes:
> 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;

This is not a bug.  The WITH ORDINALITY option is only available in FROM.
I don't see any place in the documentation that suggests otherwise.

> Also, WITH ORDINALITY is not mentioned here...
> http://www.postgresql.org/docs/devel/static/functions-array.html

Indeed.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: syntax error WITH ORDINALITY
@ 2014-07-23 18:36  David G Johnston <david.g.johnston@gmail.com>
  parent: Simon Riggs <simon@2ndQuadrant.com>
  1 sibling, 0 replies; 4+ messages in thread

From: David G Johnston @ 2014-07-23 18:36 UTC (permalink / raw)
  To: 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.



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: syntax error WITH ORDINALITY
@ 2014-07-23 19:46  Simon Riggs <simon@2ndQuadrant.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Simon Riggs @ 2014-07-23 19:46 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs

On 23 July 2014 18:23, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Simon Riggs <simon@2ndQuadrant.com> writes:
>> 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;
>
> This is not a bug.  The WITH ORDINALITY option is only available in FROM.
> I don't see any place in the documentation that suggests otherwise.

The phrase "The WITH ORDINALITY option is only available in FROM." is
a clear and useful statement; it isn't in the docs and should be.

Or we should have an ERROR message that says "WITH ORDINALITY may not
be used in the SELECT clause".

Perhaps both.

-- 
 Simon Riggs                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2014-07-23 19:46 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-07-23 17:12 syntax error WITH ORDINALITY Simon Riggs <simon@2ndQuadrant.com>
2014-07-23 17:23 ` Tom Lane <tgl@sss.pgh.pa.us>
2014-07-23 19:46   ` Simon Riggs <simon@2ndQuadrant.com>
2014-07-23 18:36 ` David G Johnston <david.g.johnston@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox