Re: union query

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Tamsin" <tg_mail(at)bryncadfan(dot)co(dot)uk>
Cc: "Postgres General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: union query
Date: 2001-01-12 15:41:19
Message-ID: 15863.979314079@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Tamsin" <tg_mail(at)bryncadfan(dot)co(dot)uk> writes:
> select 'other' union select description from address;
> ERROR: Unable to transform varchar to unknown
> Each UNION | EXCEPT | INTERSECT clause must have compatible target
> types

The behavior in 7.0.* and before (as far back as I recall) has been that
the first select determines the output type of the union, so the above
fails, but reversing it works. 7.1 is a little smarter about
unknown-type literals, so it accepts both of your cases, but it will
still do the Wrong Thing for examples like select int4 union select int8.

> I just wondered
> if the order of the selects in a union should matter?

It shouldn't, really, but without a complete type promotion hierarchy
we have a hard time doing anything intelligent with arbitrary pairs of
types.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Nick Fankhauser 2001-01-12 15:42:31 Correlated subquery/update
Previous Message john mcmanus 2001-01-12 15:29:50 Re: I have a problem with postmaster ( Newbie question)