Re: [HACKERS] Error in parser with UNIONS. - Mailing list pgsql-hackers

From Thomas G. Lockhart
Subject Re: [HACKERS] Error in parser with UNIONS.
Date
Msg-id 35659C06.85048A4D@alumni.caltech.edu
Whole thread Raw
In response to Error in parser with UNIONS.  (Chris Albertson <chris@topdog.pas1.logicon.com>)
Responses Re: [HACKERS] Error in parser with UNIONS.
List pgsql-hackers
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

pgsql-hackers by date:

Previous
From: t-ishii@sra.co.jp (Tatsuo Ishii)
Date:
Subject: Re: [HACKERS] Current sources?
Next
From: serj
Date:
Subject: destroydb fail in pgsql CVS from 22.5.98