Re: BUG #13796: ALTER TYPE DROP COLUMN -- unexpected behavior ? - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #13796: ALTER TYPE DROP COLUMN -- unexpected behavior ?
Date
Msg-id 13819.1449598598@sss.pgh.pa.us
Whole thread Raw
In response to BUG #13796: ALTER TYPE DROP COLUMN -- unexpected behavior ?  (pplachta@gmail.com)
Responses Re: BUG #13796: ALTER TYPE DROP COLUMN -- unexpected behavior ?  (peter plachta <pplachta@gmail.com>)
List pgsql-bugs
pplachta@gmail.com writes:
> create type complex as (a1 int, a2 numeric, a3 text, a4 int, a5 int);
> create or replace function foo(arg complex) returns complex as $$
> begin
>   return ( select arg );
> end; $$ language plpgsql;
> alter type complex drop attribute a4;
> [ foo() stops working ]

Yeah, the problem is that since "arg" has a named composite type, it is
handled using the PLPGSQL_DTYPE_ROW code path, which sets up a plpgsql
Datum for each column at function compile time.  So the rowtype is baked
into the function at that point.  If you start a fresh session everything
is fine.

A real fix might involve switching over to the PLPGSQL_DTYPE_REC code
path, which I've advocated for for some time but it'd be pretty invasive.
Or perhaps we could arrange to force recompilation of a plpgsql function
if any composite type it depends on has changed.  Nobody's really gotten
excited enough about this to do either ...

            regards, tom lane

pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: BUG #13799: Unexpected multiple exection of user defined function with out parameters
Next
From: Kevin Grittner
Date:
Subject: Re: BUG #13798: Unexpected multiple exection of user defined function with out parameters