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