Patch: UNNEST (and other functions) WITH ORDINALITY - Mailing list pgsql-hackers

From David Fetter
Subject Patch: UNNEST (and other functions) WITH ORDINALITY
Date
Msg-id 20130123062943.GB26369@fetter.org
Whole thread Raw
Responses Re: Patch: UNNEST (and other functions) WITH ORDINALITY
Re: Patch: UNNEST (and other functions) WITH ORDINALITY
List pgsql-hackers
Folks,

Please find attached a patch which implements the SQL standard
UNNEST() WITH ORDINALITY.  It doesn't stop there.  Any function call
in a FROM clause can now take WITH ORDINALITY, which appends a counter
(ordinality) column to the columns the function outputs and produce
results like this:

postgres@postgres:5493=# select * FROM pg_ls_dir('.') WITH ORDINALITY AS t(ls,n);
       ls        | n
-----------------+----
 pg_serial       |  1
 pg_twophase     |  2
 postmaster.opts |  3
 pg_notify       |  4
 postgresql.conf |  5
 pg_tblspc       |  6
 logfile         |  7
 base            |  8
 postmaster.pid  |  9
 pg_ident.conf   | 10
 global          | 11
 pg_clog         | 12
 pg_snapshots    | 13
 pg_multixact    | 14
 PG_VERSION      | 15
 pg_xlog         | 16
 pg_hba.conf     | 17
 pg_stat_tmp     | 18
 pg_subtrans     | 19
(19 rows)

TBD: polish the docs, add regression tests, possibly add psql support.

Thanks to Andrew (RhodiumToad) Gierth for the hard work designing and
implementing this feature.

Tom, is there some better way to do this?

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

Attachment

pgsql-hackers by date:

Previous
From: Craig Ringer
Date:
Subject: Re: Visual Studio 2012 RC
Next
From: David Fetter
Date:
Subject: Re: .gitignore additions