BUG #13745: Alias notation after WITH ORDINALITY flattens composite types - Mailing list pgsql-bugs

From duncanmgillis@gmail.com
Subject BUG #13745: Alias notation after WITH ORDINALITY flattens composite types
Date
Msg-id 20151029130725.3019.14923@wrigleys.postgresql.org
Whole thread Raw
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      13745
Logged by:          Duncan Gillis
Email address:      duncanmgillis@gmail.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)

pgsql-bugs by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Re: BUG #13739: Recurring corrupted page pointer panics on hot-standby replica
Next
From: kchinnathambu@mdsol.com
Date:
Subject: BUG #13746: SQL Query Window stopped working