Skip site navigation (1) Skip section navigation (2)

Re: BUG #2242: Inconsistent casting in query with literal vs query with parameter

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Matthew Bellew" <postgres(at)bellew(dot)net>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #2242: Inconsistent casting in query with literal vs query with parameter
Date: 2006-02-07 14:49:29
Message-ID: 6732.1139323769@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
"Matthew Bellew" <postgres(at)bellew(dot)net> writes:
> In the script below, I'd expect all four queries to return 10 rows
> (1,2,3,4,5,10,20,30,40,50).  However, function bystr() returns two rows
> (1,10).  Clearly, in this one case the query processor is casting the column
> to the parameter type, rather than the other way around.  The optimizer
> should always preferentially cast the parameter to the type of the column.

I see no bug here.  You are confused about the difference between an
unknown literal ('100') and a value that is actually declared to be of
type text.  See
http://www.postgresql.org/docs/8.1/static/typeconv.html

			regards, tom lane

In response to

pgsql-bugs by date

Next:From: Tom LaneDate: 2006-02-07 15:09:41
Subject: Re: BUG #2239: "vacuumdb -a" remove freeze
Previous:From: Tom LaneDate: 2006-02-07 14:37:49
Subject: Re: BUG #2245: pg_dump doesn't dump expressions with sequence in DEFAULT setting for some column in table

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group