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

From Rod Taylor
Subject Re: interesting difference for queries...
Date
Msg-id 1039020201.35854.48.camel@jester
Whole thread Raw
In response to interesting difference for queries...  ("Mario Weilguni" <mario.weilguni@icomedias.com>)
Responses Re: interesting difference for queries...
List pgsql-hackers
On Wed, 2002-12-04 at 11:21, Mario Weilguni wrote:
> I noticed an interesting difference in query behaviour:
>
> cms=# CREATE TABLE foo(bar int);
> CREATE
> cms=# SELECT * from foo where bar=1.7;

This is a numeric to integer coercion, which rounds

rbt=# select 1.7::int;int4
------   2
(1 row)

>  bar
> -----
> (0 rows)
>
> 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.


I guess the question is whether or not a numeric -> integer conversion
should 'wedge' numbers into the int, or throw an error.

--
Rod Taylor <rbt@rbt.ca>

PGP Key: http://www.rbt.ca/rbtpub.asc

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [GENERAL] PostgreSQL Global Development Group Announces
Next
From: Lee Kindness
Date:
Subject: Re: PQnotifies() in 7.3 broken?