Re: Changing a column's type - Mailing list pgsql-general

From Tom Lane
Subject Re: Changing a column's type
Date
Msg-id 29983.1040083974@sss.pgh.pa.us
Whole thread Raw
In response to Re: Changing a column's type  (Hadley Willan <hadley.willan@deeper.co.nz>)
Responses Re: Changing a column's type
List pgsql-general
Hadley Willan <hadley.willan@deeper.co.nz> writes:
> FUNCTION fn_create_new_item()
>     _seq RECORD;
> begin
>     SELECT INTO _seq NEXTVAL(''source_sequence'');
>     ..do stuff, insert ....
>     PERFORM fn_b( _seq.next_value );
> end;

> Call to fn_b breaks because _seq.next_value is of type BIGINT.

Oh, I see.  It seems like a rather random coding technique: why'd you
not declare _seq as type int?  If you don't want to change that, you
could insert an explicit cast in the PERFORM, too:

    PERFORM fn_b( _seq.next_value::int );

There's been some recent talk of allowing fn_b() with an int8 argument
to be resolved as fn_b(int4) --- with a runtime down-conversion --- if
there are no other candidates for fn_b().  But no one's put forward a
convincing argument for that as yet.  It might just add confusion.

            regards, tom lane

pgsql-general by date:

Previous
From: Jakub Ouhrabka
Date:
Subject: Re: working around setQuerySnapshot limitations in functions
Next
From: "scott.marlowe"
Date:
Subject: Server testing.