Re: BUG #7644: Missing implicit types of Result and failing type-conversion

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: rep(dot)dot(dot)nop(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #7644: Missing implicit types of Result and failing type-conversion
Date: 2012-11-10 15:20:24
Message-ID: 8891.1352560824@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

rep(dot)dot(dot)nop(at)gmail(dot)com writes:
> select distinct on (bug) bug
> from (
> select * from (select 'string one' AS bug from generate_series(0,1))
> s1
> UNION
> select * from (select 'string two' bug from generate_series(0,0))
> s2
> ) x
> ;
> ERROR: could not determine which collation to use for string comparison
> HINT: Use the COLLATE clause to set the collation explicitly.

> What am i missing or doing wrong?

Leaving out the cast. An undecorated string literal is not a constant
of type text --- it is a constant of unknown type, and the parser will
throw an error if the type can't be resolved from fairly-local context.
(The same applies to NULL, btw.)

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bernhard Reutner-Fischer 2012-11-10 15:56:02 Re: BUG #7644: Missing implicit types of Result and failing type-conversion
Previous Message Peter Geoghegan 2012-11-10 11:47:28 Re: BUG #7648: Momentary index corruption while in hot standby