Re: INSERT with RETURNING clause inside SQL function

From: "Diego Schulz" <dschulz(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: INSERT with RETURNING clause inside SQL function
Date: 2008-11-04 12:31:40
Message-ID: 47dcfe400811040431u10da28acj4c8717a9382b47eb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Nov 4, 2008 at 2:38 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "Diego Schulz" <dschulz(at)gmail(dot)com> writes:
>> On Mon, Nov 3, 2008 at 10:24 PM, Raymond O'Donnell <rod(at)iol(dot)ie> wrote:
>>> Just curious - what have you got against currval()? It seems to me that
>>> it would make your life easier....
>
>> I simply don't like having to cast from BIGINT to INTEGER,
>
> Under what circumstances do you need an explicit cast?
>
> regards, tom lane
>

When I want the function to return the same type as the index of the
table (normally SERIAL),
and I have other functions that rely on the datatype returned. To
avoid casting I can simply change the function's
signature to return BIGINT (to match currval() return type) and the
problem vanishes but.. then I have more functions
that needs to be adapted.

Maybe I'm a bit paranoid of BIGINT's performance penalty too, as the
set of functions will be heavily
used, but honestly, this fear completely lacks foundation.

Just to make it clear, the main reason for this thread was curiosity :)
Thank you for your time.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Lennin Caro 2008-11-04 12:57:41 Re: INSERT with RETURNING clause inside SQL function
Previous Message sathiya psql 2008-11-04 12:25:51 epqa; postgres performance optimizer support tool; opensource.