The resolution to my problem with the select_common_type() error message
turned out to be that this doesn't work:
postgres=# select null union select null union select 1;
ERROR: UNION types text and integer cannot be matched
That's because it resolves the first two branches independently, then defaults
to text if it can't find anything better, and then tries to match text to the
integer in the third branch.
This should probably be fixed sometime. Maybe make a note in the TODO list?
--
Peter Eisentraut
http://developer.postgresql.org/~petere/