Re: Weird type selection choice

From: Bernd Helmle <mailings(at)oopsware(dot)de>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Weird type selection choice
Date: 2007-11-06 15:44:16
Message-ID: 77CFD63F45729B2BD54BDB7D@imhotep.credativ.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

--On Dienstag, November 06, 2007 16:31:05 +0100 Peter Eisentraut
<peter_e(at)gmx(dot)net> wrote:

> I noticed this problem in 8.2 and 8.3:
>
> pei=# select mod( trunc( 1 ), 2 );
> ERROR: 42883: function mod(double precision, integer) does not exist
> LINE 1: select mod( trunc( 1 ), 2 );
> ^
>
> It apparently casts the 1 to double precision to pick the variant
> trunc(dp)=>dp instead of trunc(numeric)=>numeric. I was under the
> impression that we didn't want to cast integers to float types
> implicitly because this loses information. Clearly, the numeric variant
> should be preferred anyway. What's wrong here?

Indeed, if i go and make the implicit cast from int4 to float8 explicit or
implicit on assignment it's going to work:

bernd(at)localhost:bernd #= UPDATE pg_cast SET castcontext = 'e' WHERE
castsource = 23 AND casttarget = 701;
UPDATE 1
Time: 7,320 ms
bernd(at)localhost:bernd #= select mod( trunc( 1 ), 2 );
mod
-----
1
(1 row)

--
Thanks

Bernd

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2007-11-06 15:50:08 Re: Weird type selection choice
Previous Message Gokulakannan Somasundaram 2007-11-06 15:44:00 Re: Visibility map thoughts