Thread: BUG #14426: union causes error

BUG #14426: union causes error

From
abo@zetescards.be
Date:
VGhlIGZvbGxvd2luZyBidWcgaGFzIGJlZW4gbG9nZ2VkIG9uIHRoZSB3ZWJz
aXRlOgoKQnVnIHJlZmVyZW5jZTogICAgICAxNDQyNgpMb2dnZWQgYnk6ICAg
ICAgICAgIEFsYWluIEJvdXJnZW9pcwpFbWFpbCBhZGRyZXNzOiAgICAgIGFi
b0B6ZXRlc2NhcmRzLmJlClBvc3RncmVTUUwgdmVyc2lvbjogOS42LjEKT3Bl
cmF0aW5nIHN5c3RlbTogICBMaW51eApEZXNjcmlwdGlvbjogICAgICAgIAoK
c2VsZWN0IG51bGwgdW5pb24gc2VsZWN0IG51bGwgdW5pb24gc2VsZWN0IDEg
DQoNCmNhdXNlcyBhbiBlcnJvci4KCg==

Re: BUG #14426: union causes error

From
Vik Fearing
Date:
On 11/16/2016 03:25 PM, abo@zetescards.be wrote:
> The following bug has been logged on the website:
>
> Bug reference:      14426
> Logged by:          Alain Bourgeois
> Email address:      abo@zetescards.be
> PostgreSQL version: 9.6.1
> Operating system:   Linux
> Description:
>
> select null union select null union select 1
>
> causes an error.

First of all, it is standard practice to say what the error is.

This is not a bug, but a known limitation.  In your first query, your
column is of type "unknown", but when you union it with another unknown
type, it gets turned into text.  Unioning text with integer is what is
giving you your error.

The solution is to make sure you type your data, at least in the first
query.
--
Vik Fearing                                          +33 6 46 75 15 36
http://2ndQuadrant.fr     PostgreSQL : Expertise, Formation et Support