BUG #13745: Alias notation after WITH ORDINALITY flattens composite types

From: duncanmgillis(at)gmail(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #13745: Alias notation after WITH ORDINALITY flattens composite types
Date: 2015-10-29 13:07:25
Message-ID: 20151029130725.3019.14923@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 13745
Logged by: Duncan Gillis
Email address: duncanmgillis(at)gmail(dot)com
PostgreSQL version: 9.4.4
Operating system: Ubuntu 13.04; Ubuntu 14.04
Description:

With "arr" being an array of some composite type, "UNNEST(arr) WITH
ORDINALITY _(rec, idx)" suprisingly will populate "rec" and "idx" with the
first two elements from each record in array, rather than the entire record
followed by the ordinality of that record.

This seems inconsistent with how the aliasing behaviour works with
subqueries. It also gets very tedious if you need to unpack a composite type
with lots of fields only to have to put it together again in the SELECT
clause:

SELECT ROW(col1, col2, ..., colN)::some_table, row_idx
FROM UNNEST(array_of_rows) WITH ORDINALITY _(col1, col2, ..., colN,
row_idx)

Browse pgsql-bugs by date

  From Date Subject
Next Message kchinnathambu 2015-10-29 18:28:40 BUG #13746: SQL Query Window stopped working
Previous Message b.phamhuu 2015-10-29 12:57:30 BUG #13744: Postgresql function auto add 's' character to the end of string