Re: interesting difference for queries...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rod Taylor <rbt(at)rbt(dot)ca>
Cc: Mario Weilguni <mario(dot)weilguni(at)icomedias(dot)com>, "Postgresql " Mailinglist "" (E-Mail) <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: interesting difference for queries...
Date: 2002-12-04 17:22:15
Message-ID: 15259.1039022535@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Rod Taylor <rbt(at)rbt(dot)ca> writes:
>> cms=# CREATE TABLE foo(bar int);
>> CREATE
>> cms=# SELECT * from foo where bar=1.7;

> This is a numeric to integer coercion, which rounds

No, it's an integer to numeric promotion (the var is promoted, not the
constant). Obviously the '=' can never return true in this case.

>> cms=# SELECT * from foo where bar='1.7';
>> ERROR: pg_atoi: error in "1.7": can't parse ".7"

> This is a text to integer coercion, which doesn't round.

And should not, IMHO. This is effectively the same as

... where bar = '1.7'::int

which it seems to me is quite correct to throw a bad-input error.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marc G. Fournier 2002-12-04 17:22:20 Re: [GENERAL] PostgreSQL Global Development Group Announces
Previous Message Robert Treat 2002-12-04 17:21:14 setQuerySnapshot in plpgsql functions in 7.3