pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #7644: Missing implicit types of Result and failing type-conversion
5+ messages / 3 participants
[nested] [flat]
* BUG #7644: Missing implicit types of Result and failing type-conversion
@ 2012-11-09 09:57 rep.dot.nop@gmail.com
0 siblings, 1 reply; 5+ messages in thread
From: rep.dot.nop@gmail.com @ 2012-11-09 09:57 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 7644
Logged by: Bernhard Reutner-Fischer
Email address: rep.dot.nop@gmail.com
PostgreSQL version: 9.1.6
Operating system: debian
Description:
Hi,
According to
http://www.postgresql.org/docs/9.1/static/typeconv-union-case.html
i think that these 2 (separate?) issues are bugs(?)
1)
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.
When casting the return value of the union to :text _explicitly_ it works as
expected:
select distinct on (bug) bug
from (
select * from (select 'string one'::text AS bug from
generate_series(0,1)) s1
UNION
select * from (select 'string two' bug from generate_series(0,0))
s2
) x
;
bug
------------
string one
string two
(2 rows)
2)
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) s2
) x
;
ERROR: failed to find conversion function from unknown to text
In this case, however, using a "Result" fails to implicitly typecast to
:text, i.e. casting the return value of the first return value of the union
to :text explicitly does _not_ work:
select distinct on (bug) bug
from (
select * from (select 'string one'::text AS bug from
generate_series(0,1)) s1
UNION
select * from (select 'string two' bug ) s2
) x
;
ERROR: failed to find conversion function from unknown to text
What am i missing or doing wrong?
thanks and cheers,
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BUG #7644: Missing implicit types of Result and failing type-conversion
@ 2012-11-10 15:20 Tom Lane <tgl@sss.pgh.pa.us>
parent: rep.dot.nop@gmail.com
0 siblings, 1 reply; 5+ messages in thread
From: Tom Lane @ 2012-11-10 15:20 UTC (permalink / raw)
To: rep.dot.nop@gmail.com; +Cc: pgsql-bugs
rep.dot.nop@gmail.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
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BUG #7644: Missing implicit types of Result and failing type-conversion
@ 2012-11-10 15:56 Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 5+ messages in thread
From: Bernhard Reutner-Fischer @ 2012-11-10 15:56 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs
On 10 November 2012 16:20:24 Tom Lane <tgl@sss.pgh.pa.us> wrote:
> rep.dot.nop@gmail.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.)
Fair enough but what about the failure for the case with the Result
that fails to merge? There I do have a cast but it fails on the Result
as opposed to a genera e_series(0,0):
select distinct on (bug) bug
from (
select * from (select 'string one'::text AS bug from
generate_series(0,1)) s1
UNION
select * from (select 'string two' bug ) s2
) x
;
Sent with AquaMail for Android
http://www.aqua-mail.com
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BUG #7644: Missing implicit types of Result and failing type-conversion
@ 2012-11-10 15:58 Tom Lane <tgl@sss.pgh.pa.us>
parent: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Tom Lane @ 2012-11-10 15:58 UTC (permalink / raw)
To: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>; +Cc: pgsql-bugs
"Bernhard Reutner-Fischer" <rep.dot.nop@gmail.com> writes:
> Fair enough but what about the failure for the case with the Result
> that fails to merge? There I do have a cast
No you don't:
> select * from (select 'string two' bug ) s2
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BUG #7644: Missing implicit types of Result and failing type-conversion
@ 2012-11-12 09:14 Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 5+ messages in thread
From: Bernhard Reutner-Fischer @ 2012-11-12 09:14 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs
On 10 November 2012 16:58, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "Bernhard Reutner-Fischer" <rep.dot.nop@gmail.com> writes:
> > Fair enough but what about the failure for the case with the Result
> > that fails to merge? There I do have a cast
>
> No you don't:
>
> > select * from (select 'string two' bug ) s2
>
> regards, tom lane
>
I do not need the cast in the second select when using generate_series
either.
select distinct on (bug) bug
from (
select * from (select 'string one'::text bug from generate_series(0,1))
s1
UNION
select * from (select 'string two' bug) s2
-- select * from (select 'string two' bug from generate_series(0,0)) s2
) x
;
IMO this contradicts the "Type Resolution for UNION, CASE, and Related
Constructs" from the documentation.
4) Choose the first non-unknown input type which is a preferred type in
that category, if there is one.
Please explain why the two selects for 'string two' in the example above
behave different?
Many TIA && cheers,
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2012-11-12 09:14 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-11-09 09:57 BUG #7644: Missing implicit types of Result and failing type-conversion rep.dot.nop@gmail.com
2012-11-10 15:20 ` Tom Lane <tgl@sss.pgh.pa.us>
2012-11-10 15:56 ` Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-11-10 15:58 ` Tom Lane <tgl@sss.pgh.pa.us>
2012-11-12 09:14 ` Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox