BUG #1278: PL/pgSQL: ROWTYPE does not care for droped columns

From: "PostgreSQL Bugs List" <pgsql-bugs(at)postgresql(dot)org>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #1278: PL/pgSQL: ROWTYPE does not care for droped columns
Date: 2004-10-04 11:33:05
Message-ID: 20041004113305.304BA5A107B@www.postgresql.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 1278
Logged by: Michael Howitz

Email address: mh+postgres(at)gocept(dot)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.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2004-10-04 13:54:26 Re: PLPGSQL and FOUND stange behaviour after EXECUTE
Previous Message Neil Conway 2004-10-04 07:19:11 Re: PLPGSQL and FOUND stange behaviour after EXECUTE