using composite types in insert/update - Mailing list pgsql-hackers

From Merlin Moncure
Subject using composite types in insert/update
Date
Msg-id b42b73150901280903kee75173nafd9393fb24f3a17@mail.gmail.com
Whole thread Raw
Responses Re: using composite types in insert/update  (ITAGAKI Takahiro <itagaki.takahiro@oss.ntt.co.jp>)
Re: using composite types in insert/update  (Sam Mason <sam@samason.me.uk>)
List pgsql-hackers
IMO, composite types on insert/update should work as they do on select:

SELECT foo FROM foo; -- works, returning type foo

INSERT INTO foo VALUES '(something)'::foo -- fails,

but we have a workaround:
INSERT INTO foo SELECT  ('(something)'::foo).* -- expands foo into foo columns

however no such workaround exists for update. ideally,
UPDATE foo SET foo = foo;

would be valid.  Aside from fixing a surprising behavior, it would
greatly aid in writing triggers that do things like ship updates over
dblink _much_ easier (in fact...the dblink_build_xxx family would
become obsolete).

e.g.
perform dblink.dblink('UPDATE foo SET foo = \'' || new || '\'::foo);

I call the existing behavior of insert/update of composite types
broken to the point of almost being a bug.  Fixing the above to work
would close the loop on a broad new set of things you can do with
composite types.

merlin


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg_upgrade project status
Next
From: Robert Treat
Date:
Subject: Re: 8.4 release planning