--On Dienstag, November 06, 2007 16:31:05 +0100 Peter Eisentraut <[EMAIL PROTECTED]> 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:

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

--
 Thanks

                   Bernd

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to