Re: 'real' strange problem in 7.1.3

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "G(dot) Anthony Reina" <reina(at)nsi(dot)edu>
Cc: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: 'real' strange problem in 7.1.3
Date: 2001-11-09 23:43:08
Message-ID: 29037.1005349388@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"G. Anthony Reina" <reina(at)nsi(dot)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 write
WHERE 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2001-11-09 23:46:14 Re: best method of reloading pg_hba.conf
Previous Message Bruce Momjian 2001-11-09 23:31:47 Re: best method of reloading pg_hba.conf