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

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to