Re: 'real' strange problem in 7.1.3 - Mailing list pgsql-hackers

From Tom Lane
Subject Re: 'real' strange problem in 7.1.3
Date
Msg-id 29037.1005349388@sss.pgh.pa.us
Whole thread Raw
In response to Re: 'real' strange problem in 7.1.3  ("G. Anthony Reina" <reina@nsi.edu>)
List pgsql-hackers
"G. Anthony Reina" <reina@nsi.edu> writes:
> you're saying that putting the 1.8 in quotes is interpreted by the parser
> as adding the ::float4 at the end. That's the bit of information that I
> needed. I thought that perhaps my value was being stored as a string even
> though PG was telling me that it was a float.

More precisely, when you writeWHERE foo = 'const'
the constant is essentially forced to take on the datatype of foo.
(It's initially treated as a constant of type UNKNOWN, and then the
operator resolution rules will prefer to select an "=" operator with
foo's datatype on both sides, and then the unknown constant gets
coerced to that type.  Messy but it works.)

There has been some discussion about trying to handle numeric literals
in a similar fashion, wherein we don't nail down their type immediately,
but it's not been done yet.  Right now 1.8 will be taken as float8
on sight, and then you end up with a float4-vs-float8 comparison,
which is unlikely to work nicely except with values that are exactly
representable in float4 (such as small integers).
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: best method of reloading pg_hba.conf
Next
From: Bruce Momjian
Date:
Subject: Re: best method of reloading pg_hba.conf