Re: plpgsql: numeric assignment to an integer variable errors out - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: plpgsql: numeric assignment to an integer variable errors out
Date
Msg-id 201002270312.o1R3Ccj22792@momjian.us
Whole thread Raw
In response to Re: plpgsql: numeric assignment to an integer variable errors out  ("Nikhil Sontakke" <nikhil.sontakke@enterprisedb.com>)
Responses Re: plpgsql: numeric assignment to an integer variable errors out
List pgsql-hackers
Whatever happened to this patch?

---------------------------------------------------------------------------

Nikhil Sontakke wrote:
> Hi,
> 
> <nikhil.sontakke@enterprisedb.com> wrote:
> 
> > The following plpgsql function errors out with cvs head:
> >
> > CREATE function test_assign() returns void
> > AS
> > $$ declare x int;
> > BEGIN
> > x := 9E3/2;
> > END
> > $$ LANGUAGE 'plpgsql';
> >
> > postgres=# select test_assign();
> > ERROR:  invalid input syntax for integer: "4500.0000000000000000"
> > CONTEXT:  PL/pgSQL function "test_assign" line 3 at assignment
> >
> > We do have an existing cast from numeric to type integer. But here
> > basically we convert the value to string in exec_cast_value before calling
> > int4in. And then use of strtol in pg_atoi leads to this complaint. Guess
> > converting the value to string is not always a good strategy.
> >
> 
> PFA, patch which uses find_coercion_pathway to find a direct
> COERCION_PATH_FUNC function and uses that if it is available. Or is there a
> better approach? Seems to handle the above issue with this patch.
> 
> Regards,
> Nikhils
> -- 
> http://www.enterprisedb.com

[ Attachment, skipping... ]

> 
> -- 
> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.comPG East:  http://www.enterprisedb.com/community/nav-pg-east-2010.do + If your life is a hard
drive,Christ can be your backup. +
 


pgsql-hackers by date:

Previous
From: Greg Smith
Date:
Subject: Re: Hot Standby query cancellation and Streaming Replication integration
Next
From: "Joshua D. Drake"
Date:
Subject: Re: Re: Hot Standby query cancellation and StreamingReplication integration