Re: Weird type selection choice - Mailing list pgsql-hackers

From Bernd Helmle
Subject Re: Weird type selection choice
Date
Msg-id 77CFD63F45729B2BD54BDB7D@imhotep.credativ.de
Whole thread Raw
In response to Weird type selection choice  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
--On Dienstag, November 06, 2007 16:31:05 +0100 Peter Eisentraut 
<peter_e@gmx.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@localhost:bernd #= UPDATE pg_cast SET castcontext = 'e' WHERE 
castsource = 23 AND casttarget = 701;
UPDATE 1
Time: 7,320 ms
bernd@localhost:bernd #=  select mod( trunc( 1 ), 2 );mod
-----  1
(1 row)

--  Thanks
                   Bernd


pgsql-hackers by date:

Previous
From: "Gokulakannan Somasundaram"
Date:
Subject: Re: Visibility map thoughts
Next
From: Peter Eisentraut
Date:
Subject: Re: Weird type selection choice