Made some progress:
postgres=> select 1.2 as float8 union select 1;
float8
------
1
1.2
(2 rows)
postgres=> select text 'a' as text union select 'b';
text
----
a
b
(2 rows)
At the moment I'm forcing the types of the union to match the types of
the first/top clause in the union:
postgres=> select 1 as all_integers
postgres-> union select '2.2'::float4 union select 3.3;
all_integers
------------
1
2
3
(3 rows)
The better strategy might be to choose the "best" type of the bunch, but
is more difficult because of the nice recursion technique used in the
parser. However, it does work OK when selecting _into_ a table:
postgres=> create table ff (f float);
CREATE
postgres=> insert into ff
postgres-> select 1 union select '2.2'::float4 union select 3.3;
INSERT 0 3
postgres=> select * from ff;
f
----------------
1
2.20000004768372
3.3
(3 rows)
Comments??
- Tom