pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #15462: WITH ORDINALITY and CTEs don't work
2+ messages / 2 participants
[nested] [flat]

* BUG #15462: WITH ORDINALITY and CTEs don't work
@ 2018-10-26 10:55 PG Bug reporting form <noreply@postgresql.org>
  2018-10-26 11:34 ` Re: BUG #15462: WITH ORDINALITY and CTEs don't work hubert depesz lubaczewski <depesz@depesz.com>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2018-10-26 10:55 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: michael.meyer@pace.de

The following bug has been logged on the website:

Bug reference:      15462
Logged by:          Michael Meyer
Email address:      michael.meyer@pace.de
PostgreSQL version: 11.0
Operating system:   Windows 10
Description:        

CTEs don't play nicely together with 'WITH ORDINALITY':

This is working:

SELECT * FROM generate_series(4,1,-1) WITH ORDINALITY;
WITH a AS (SELECT * FROM generate_series(4,1,-1) )
SELECT * FROM a;

whereas this yields syntax error (42601)

WITH a AS (SELECT * FROM generate_series(4,1,-1) )
SELECT * FROM a WITH ORDINALITY;



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

* Re: BUG #15462: WITH ORDINALITY and CTEs don't work
  2018-10-26 10:55 BUG #15462: WITH ORDINALITY and CTEs don't work PG Bug reporting form <noreply@postgresql.org>
@ 2018-10-26 11:34 ` hubert depesz lubaczewski <depesz@depesz.com>
  0 siblings, 0 replies; 2+ messages in thread

From: hubert depesz lubaczewski @ 2018-10-26 11:34 UTC (permalink / raw)
  To: michael.meyer@pace.de; pgsql-bugs@lists.postgresql.org

On Fri, Oct 26, 2018 at 10:55:57AM +0000, PG Bug reporting form wrote:
> CTEs don't play nicely together with 'WITH ORDINALITY':

Sure they do.

> This is working:
> SELECT * FROM generate_series(4,1,-1) WITH ORDINALITY;
> WITH a AS (SELECT * FROM generate_series(4,1,-1) )
> SELECT * FROM a;
> 
> whereas this yields syntax error (42601)
> 
> WITH a AS (SELECT * FROM generate_series(4,1,-1) )
> SELECT * FROM a WITH ORDINALITY;


This is because "with ORDINALITY" is for function call, not for any
table query.

So the correct syntax would be:

WITH a AS (SELECT * FROM generate_series(4,1,-1) WITH ORDINALITY) SELECT * FROM a;

depesz




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


end of thread, other threads:[~2018-10-26 11:34 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-10-26 10:55 BUG #15462: WITH ORDINALITY and CTEs don't work PG Bug reporting form <noreply@postgresql.org>
2018-10-26 11:34 ` hubert depesz lubaczewski <depesz@depesz.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