Re: [HACKERS] Error in parser with UNIONS.

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: chris(at)topdog(dot)pas1(dot)logicon(dot)com (Chris Albertson)
Cc: pgsql-hackers(at)hub(dot)org
Subject: Re: [HACKERS] Error in parser with UNIONS.
Date: 1998-05-22 03:38:08
Message-ID: 199805220338.XAA18447@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> Got no reply on "questions". Someone here may want to
> know this...
>
> I think I may have uncovered an error in the parser. The
> following is the simplest example that shows the problem.
> Maybe a counter needs to be reset by 'union' or checked
> after select not statement. I would like to use this syntax
> in my libpq program. Is this a bug? Is it already known?
>
> Would someone please e-mail me the syntax for the
> "explicit cast" the system wants
>
> I am using 6.3.2 on an Ultra SPARC. The error occurs on
> a Linux RH50 Intel system too.
>
> I think the following should work but does not:
>
> testdb=> select 'a' as X
> testdb-> union
> testdb-> select 'b' as X;
> NOTICE: there is more than one operator < for types
> NOTICE: unknown and unknown. You will have to retype this query
> ERROR: using an explicit cast
>
> Notice that this does work
>
> testdb=> select 'b' as X;
> x
> -
> b
> (1 row)
>
> And this works too:
>
> testdb=> select 1 as X
> testdb-> union
> testdb-> select 2 as X;
> x
> -
> 1
> 2
> (2 rows)
>

This caused because UNION removes duplicates, and to do that, it must
sort, but the character constants can't be sorted because they could be
text, varchar, char(), etc. 6.4 will fix that with new auto-casting.
For now, us UNION ALL, which will not remove duplicates.

--
Bruce Momjian | 830 Blythe Avenue
maillist(at)candle(dot)pha(dot)pa(dot)us | Drexel Hill, Pennsylvania 19026
+ If your life is a hard drive, | (610) 353-9879(w)
+ Christ can be your backup. | (610) 853-3000(h)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1998-05-22 04:33:50 Re: [HACKERS] Bug in postgresql-6.3.2
Previous Message Thomas G. Lockhart 1998-05-22 01:26:03 Re: [HACKERS] Error in parser with UNIONS.