Re: interesting difference for queries... - Mailing list pgsql-hackers

From Tom Lane
Subject Re: interesting difference for queries...
Date
Msg-id 15259.1039022535@sss.pgh.pa.us
Whole thread Raw
In response to Re: interesting difference for queries...  (Rod Taylor <rbt@rbt.ca>)
Responses Re: interesting difference for queries...
List pgsql-hackers
Rod Taylor <rbt@rbt.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


pgsql-hackers by date:

Previous
From: Robert Treat
Date:
Subject: setQuerySnapshot in plpgsql functions in 7.3
Next
From: "Marc G. Fournier"
Date:
Subject: Re: [GENERAL] PostgreSQL Global Development Group Announces