On Thu, Sep 18, 2014 at 5:22 PM, Hannu Krosing <[email protected]> wrote:
> Though it would be even nicer to have fully in-line type definition
>
> SELECT (tup).* FROM
> (
> SELECT CASE WHEN .. THEN ROW(1,2,3)::(a int, b text, c int2)
> WHEN .. THEN ROW(2,3,4)
> ELSE ROW (3,4,5) END AS tup
> FROM ..
> ) ss
+1. Workaround at present (which I mostly use during json serialization) is:
SELECT (tup).* FROM
(
SELECT CASE WHEN .. THEN
(SELECT q FROM (SELECT 1, 2, 3) q)
WHEN .. THEN
(SELECT q FROM (SELECT 2, 3, 4) q)
ELSE (SELECT q FROM (SELECT 3, 4, 5) q)
END AS tup
FROM ..
) ss
If you're talking in line type definitions (which is kinda off topic)
though, it'd be nice to consider:
* nested type definition:
create type foo_t as
(
a text,
b int,
bars bar_t[] as
(
c int,
d text
),
baz baz_t as
(
e text,
f text
)
);
* ...and recursive type references (not being able to recursively
serialize json is a major headache)
create type foo_t as
(
path text,
children foo_t[]
);
merlin
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers