Re: problems selecting from altered table - Mailing list pgsql-general

From Richard Huxton
Subject Re: problems selecting from altered table
Date
Msg-id 4677F522.8010105@archonet.com
Whole thread Raw
In response to problems selecting from altered table  (Rikard Pavelic <rikard.pavelic@zg.htnet.hr>)
Responses Re: problems selecting from altered table
List pgsql-general
Rikard Pavelic wrote:
> create function sel_test() returns test as
> $$
> declare red record;
> begin
>     select * into red from test limit 1;
>     return red;
> end
> $$ language plpgsql;

> alter table test drop column tekst;
>
> then select * from sel_test(); doesn't work anymore
> Even if I recreate the function.
>
> Is this a known problem?

Not known by me, certainly. It appears to be related to the definition
of red as type "record". If you define it as type "test" it all seems
OK. Or, you can set up a variable red2 type "test" and copy the value
into that, and that works.

I do know that dropping a column just flags it as dropped, it doesn't
automatically update the on-disk representation. That suggests to me
there's something in the "RETURN" or "SELECT INTO" statements that's not
checking for the flag and deducing the wrong type.

Trying to access a dropped column via assignment or RAISE NOTICE gives
errors, which makes me think it's the RETURN statement.

Any developers care to comment?

--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: Gerhard Hintermayer
Date:
Subject: Re: Apparent Wraparound?
Next
From: "Merlin Moncure"
Date:
Subject: Re: Subquery problems