Calling PLpgSQL function with composite type fails with an error: "ERROR: could not open relation with OID ..."

Ashutosh Sharma <ashu.coek88@gmail.com>

From: Ashutosh Sharma <ashu.coek88@gmail.com>
To: pgsql-hackers <pgsql-hackers@postgresql.org>, Tom Lane <tgl@sss.pgh.pa.us>
Date: 2019-12-26T10:27:18Z
Lists: pgsql-hackers
Hi All,

When the following test-case is executed on master, it fails with an
error: "ERROR:  could not open relation with OID ..."

-- create a test table:
create table tab1(a int, b text);

-- create a test function:
create or replace function f1() returns void as
$$
declare
   var1 tab1;
begin
   select * into var1 from tab1;
end
$$ language plpgsql;

-- call the test function:
select f1();

-- drop the test table and re-create it:
drop table tab1;
create table tab1(a int, b text);

-- call the test function:
select f1();

-- call the test function once again:
select f1(); -- this fails with an error "ERROR:  could not open
relation with OID .."

I'm trying to investigate this issue and will try to share my findings soon...

--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com



Commits

  1. Fix possible loss of sync between rectypeid and underlying PLpgSQL_type.