BUG #1278: PL/pgSQL: ROWTYPE does not care for droped columns - Mailing list pgsql-bugs

From PostgreSQL Bugs List
Subject BUG #1278: PL/pgSQL: ROWTYPE does not care for droped columns
Date
Msg-id 20041004113305.304BA5A107B@www.postgresql.com
Whole thread Raw
Responses Re: BUG #1278: PL/pgSQL: ROWTYPE does not care for droped columns  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
The following bug has been logged online:

Bug reference:      1278
Logged by:          Michael Howitz

Email address:      mh+postgres@gocept.com

PostgreSQL version: 7.3.7

Operating system:   2.6.8-gentoo-r3

Description:        PL/pgSQL: ROWTYPE does not care for droped columns

Details:

IF you drop a column on a Table which is accessed via a PL/pgSQL-Function
using tablename%ROWTYPE you get an Error. It seems that ROWTYPE does not
take care about droped columns.

Example in code:

CREATE TABLE test (
  id SERIAL,
  start_date DATE,
  testing INTEGER);

INSERT INTO test (start_date, testing) VALUES ('2003-05-03', 1);

SELECT * from test;
-- test.id will be 1

ALTER TABLE test DROP COLUMN start_date;

CREATE OR REPLACE FUNCTION dcTest(INTEGER) RETURNS INTEGER AS
'
    DECLARE
        tid ALIAS FOR $1;
        test_rec test%ROWTYPE;
    BEGIN
        SELECT INTO test_rec *
            FROM test
            WHERE id = tid;
        RETURN test_rec.testing;
    END;
' LANGUAGE 'plpgsql';

SELECT dcTest(1);

gives the following Error:
WARNING:  plpgsql: ERROR during compile of dctest near line 0
ERROR:  cache lookup for type 0 of test.........pg.dropped.2........ failed

This code works correct in 7.4.1-dbExperts but also fails in
7.3.4-dbExperts.

pgsql-bugs by date:

Previous
From: Sean Chittenden
Date:
Subject: Denial of service via VACUUM, all backends exit and restart...
Next
From: Tom Lane
Date:
Subject: Re: PLPGSQL and FOUND stange behaviour after EXECUTE