Re: interesting difference for queries...

From: Rod Taylor <rbt(at)rbt(dot)ca>
To: Mario Weilguni <mario(dot)weilguni(at)icomedias(dot)com>
Cc: Postgresql "Mailinglist (E-Mail)" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: interesting difference for queries...
Date: 2002-12-04 16:43:21
Message-ID: 1039020201.35854.48.camel@jester
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)rbt(dot)ca>

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Lee Kindness 2002-12-04 16:50:14 Re: PQnotifies() in 7.3 broken?
Previous Message Tom Lane 2002-12-04 16:32:17 Re: [GENERAL] PostgreSQL Global Development Group Announces