Appetite for syntactic sugar to match result set columns to UDT fields? - Mailing list pgsql-hackers

From Philip Warner
Subject Appetite for syntactic sugar to match result set columns to UDT fields?
Date
Msg-id 0751f6cf8f55e71600fd03f24266002b@rhyme.com.au
Whole thread Raw
Responses Appetite for syntactic sugar to match result set columns to UDT fields?
Re: Appetite for syntactic sugar to match result set columns to UDT fields?
List pgsql-hackers

I could not see anything on this subject but would like to know if there would be any appetite for this kind of feature.

I am happy to flesh out more details if they were likely to be deemed worth implementing.

The Problem

Currently, if one has:

Create Type FOO(
   VALUE1 Int,
   VALUE2 Int);

And one has a query:

    Select F1, F2 from A_TABLE;

One can return the rows, or one can create a row object and cast it to FOO type.

This is fine for simple cases.

When the number of columns grows large and the code grows old this can become risky to maintain. Trusting that the order will always match and that someone wont accidentally move columns seems risky to me.

The Solution

Some syntax like:

    SELECT CAST((F1=> value1, F2 => value2) AS FOO BY NAME)

or

    SELECT FOO(F1 => VALUE1, F2=> value2);

or some other well-defined and non-conflicting syntax.


pgsql-hackers by date:

Previous
From: jian he
Date:
Subject: pg_dump, pg_dumpall, pg_restore HELP progname descrption of "--no-table-access-method" is wrong?
Next
From: Julien Rouhaud
Date:
Subject: Re: Update outdated references to SLRU ControlLock