From: | Philip Warner <pjw(at)rhyme(dot)com(dot)au> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Appetite for syntactic sugar to match result set columns to UDT fields? |
Date: | 2025-09-05 05:31:30 |
Message-ID: | 0751f6cf8f55e71600fd03f24266002b@rhyme.com.au |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Julien Rouhaud | 2025-09-05 05:41:55 | Re: Update outdated references to SLRU ControlLock |
Previous Message | jian he | 2025-09-05 05:13:04 | pg_dump, pg_dumpall, pg_restore HELP progname descrption of "--no-table-access-method" is wrong? |