Comment 3 for bug 1240413

Revision history for this message
Alvin Peng (pengalvin) wrote :

Seems the cause is: when casting:

''::text as t1, ''::text as t2

the constant '' is the same for t1 and t2, so the second one is ignored.

if use another string for t2, for example ' ' (there is a space betwwn ''):

''::text as t1, ' '::text as t2

then the sql is ok.

Stado -> select * from (select t1,t2 from tableA union select '' as t1, '' as t2 from tableB) t order by t1;
SQLException: ERROR: ERROR: each UNION query must have the same number of columns

Stado -> select * from (select t1,t2 from tableA union select '' as t1, ' ' as t2 from tableB) t order by t1;
+---------------+
| t1 | t2 |
+---------------+
| | |
| text1 | text2 |
+---------------+
2 row(s).