In PostgreSQL I can create an anonymous row or composite type ``` postgres=# SELECT ROW(1,'Hello',false) as r; r ------------- (1,Hello,f) (1 row) ``` But how can I get the fields out again? None of the following work ``` postgres=# SELECT (r).* from (SELECT ROW(1,'Hello',false) as r) as T; ERROR: record type has not been registered postgres=# SELECT (r).column0 from (SELECT ROW(1,'Hello',false) as r) as T; ERROR: record type has not been registered ```
PeterVandivier (imported from SE)
[New in v13](https://www.postgresql.org/docs/13/release-13.html#:~:text=Allow%20ROW%20expressions%20to%20have%20their%20members%20extracted%20with%20suffix%20notation) > * Allow [`ROW expressions`](https://www.postgresql.org/docs/13/sql-expressions.html#SQL-SYNTAX-ROW-CONSTRUCTORS) to have their members extracted with suffix notation (Tom Lane) > > For example, `(ROW(4, 5.0)).f1` now returns 4. <>https://dbfiddle.uk/?rdbms=postgres_13&fiddle=9fe759a8732781061b86f283a2f2364d&hide=61 Note there are some gotchas. You may need to explicitly cast type <>https://dbfiddle.uk/?rdbms=postgres_13&fiddle=9fe759a8732781061b86f283a2f2364d&hide=51 See [db<>fiddle](https://dbfiddle.uk/?rdbms=postgres_13&fiddle=9fe759a8732781061b86f283a2f2364d) for more 🙂 The relevant commit in source appears to be [8b7a0f1d11](https://github.com/postgres/postgres/commit/8b7a0f1d11) with a discussion at https://www.postgresql.org/message-id/flat/10872.1572202006%40sss.pgh.pa.us I don't know at this time of any official documentation, but I'll [shout out Jack@TA](https://topanswers.xyz/transcript?room=2&id=72490&year=2020&month=10#c72490) for showing me the new trick.