You can assign the row type as a whole, which does what you ask for. But it also overwrites every other (sub-)field. (I use NULL for the rest.) See x
in the demo.
You can also assign a whole composite type value to a column at the outer level. This preserves all other column values in the outer level. See y
in the demo.
But you cannot do the same for nested composite types. See z
in the demo.
DO
$$
DECLARE
x t3;
y t3;
z t3;
BEGIN
x := '("(""(,,true)"",)",)'::t3; -- works
y.a := '("(,,true)",)'::t2; -- works
--(z.a).a := '(,,true)'::t1; -- does not work
RAISE NOTICE E'\nx: %\ny: %\nz: %', x, y, z;
END
$$
dbfiddle here
(Using an EXCEPTION
to make the result visible in the fiddle.)
x.a := z.a ;
would work. It doesn't when you're some levels deeper... dbfiddle here. I thought this Accessing Composite Types would help, but it doesn't. – joanolo Jul 19 '17 at 6:53