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

From: Rashid Abzalov <rashid(dot)abzalov(at)gmail(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Prepared statement is not re-parsed after used type is re-created - ERROR: cache lookup failed for type NNN
Date: 2019-04-30 19:44:44
Message-ID: CACrSCdHQndjyWQVAO9Ksh_SASHtoWqWnkG1WkPWvHstbetzPQg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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
<https://www.postgresql.org/docs/11/sql-prepare.html>, 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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2019-04-30 21:00:27 Re: Prepared statement is not re-parsed after used type is re-created - ERROR: cache lookup failed for type NNN
Previous Message hubert depesz lubaczewski 2019-04-30 17:39:08 Current HEAD creates dumps that can't be loaded