Prepared statement is not re-parsed after used type is re-created -ERROR: cache lookup failed for type NNN - Mailing list pgsql-bugs

From Rashid Abzalov
Subject Prepared statement is not re-parsed after used type is re-created -ERROR: cache lookup failed for type NNN
Date
Msg-id CACrSCdHQndjyWQVAO9Ksh_SASHtoWqWnkG1WkPWvHstbetzPQg@mail.gmail.com
Whole thread Raw
Responses Re: Prepared statement is not re-parsed after used type is re-created - ERROR: cache lookup failed for type NNN
List pgsql-bugs
Prepared statement is not re-parsed after used type is re-created. While the re-creation of other types of objects (for example, a table or a function) works correctly.

According to the documentation, the prepared statement was to be re-analyzed again:
PostgreSQL will force re-analysis and re-planning of the statement before using it whenever database objects used in the statement have undergone definitional (DDL) changes since the previous use of the prepared statement.

Tested on 11.2 and 9.6.12.

Steps to reproduce:
1) Create type and function:
create type pg_temp.temp_type AS (field varchar(64));

create function pg_temp.test_func(param pg_temp.temp_type) returns temp_type as $$
begin
  param.field = 'qqq';
  return param;
end;
$$ language plpgsql;

2) Prepare and use them:
PREPARE testplan (pg_temp.temp_type) AS
    select * from pg_temp.test_func($1);
EXECUTE testplan(('(qqq)')::pg_temp.temp_type);

3) Drop type and function:
drop function pg_temp.test_func(param pg_temp.temp_type);
drop type pg_temp.temp_type;

4) Recreate type and function:
create type pg_temp.temp_type as (field varchar(64));

create function pg_temp.test_func(param pg_temp.temp_type) returns temp_type as $$
begin
  param.field = 'qqq';
  return param;
end;
$$ language plpgsql;

5) Trying execute prepared SQL:
EXECUTE testplan(('(qqq)')::pg_temp.temp_type);

ERROR: cache lookup failed for type 2906443

pgsql-bugs by date:

Previous
From: hubert depesz lubaczewski
Date:
Subject: Current HEAD creates dumps that can't be loaded
Next
From: Tom Lane
Date:
Subject: Re: Prepared statement is not re-parsed after used type is re-created - ERROR: cache lookup failed for type NNN