plan cache doesn't clean plans with references to dropped procedures

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Subject: plan cache doesn't clean plans with references to dropped procedures
Date: 2020-10-15 17:54:31
Message-ID: CAFj8pRBc4ksLgOAaSCX2uvZ3aNqW1NV1g=PZ+f2_+trpEyDJEw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

I am playing with fixing the speed of CALL statement in a non atomic
context, and when I tested my patch I found another issue of CALL statement
- an invalidation of plans doesn't work for CALL statement (in atomic
context).

CREATE OR REPLACE FUNCTION public.fx(a integer)
RETURNS integer
LANGUAGE plpgsql
AS $function$
begin
return a;
end;
$function$

create or replace function fxo(a int)
returns int as $$
begin
return fx(a);
end;
$$ language plpgsql;

drop function fx;

-- create fx again
create or replace function fx(a int)
returns int as $$
begin
return a;
end;
$$ language plpgsql;

-- should be ok
select fxo(10);

-- but
create procedure pe(a int)
as $$
begin
end;
$$ language plpgsql;

create or replace function fxo(a int)
returns int as $$
begin
call pe(a);
return fx(a);
end;
$$ language plpgsql;

-- ok
select fxo(10);

postgres=# drop procedure pe;
DROP PROCEDURE
postgres=# create procedure pe(a int)
as $$
begin
end;
$$ language plpgsql;
CREATE PROCEDURE
postgres=# select fxo(10);
ERROR: cache lookup failed for function 16389
CONTEXT: SQL statement "CALL pe(a)"
PL/pgSQL function fxo(integer) line 2 at CALL

Regards

Pavel

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2020-10-15 17:57:25 Re: CREATE TABLE .. PARTITION OF fails to preserve tgenabled for inherited row triggers
Previous Message Alvaro Herrera 2020-10-15 17:36:10 Re: AppendStringInfoChar instead of appendStringInfoString