pg_event_trigger_ddl_commands fails with cache lookup failed

From: Sven Klemm <sven(at)timescale(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: pg_event_trigger_ddl_commands fails with cache lookup failed
Date: 2021-02-13 13:59:43
Message-ID: CAMCrgp39V7JQA_Gc+JaEZV3ALOU1ZG=Pwyk3oDpTq7F6Z0JSmg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello,

when creating an event trigger for ddl_command_end that calls
pg_event_trigger_ddl_commands certain statements will cause the
trigger to fail with a cache lookup error. The error happens on 12.5
and 13.2 i didnt test any other versions.

trg=# ALTER TABLE t ALTER COLUMN f1 DROP IDENTITY, ALTER COLUMN f1 SET
DATA TYPE bigint;
ERROR: XX000: cache lookup failed for relation 13476892
CONTEXT: PL/pgSQL function ddl_end() line 5 at FOR over SELECT rows
LOCATION: getRelationTypeDescription, objectaddress.c:4178

To reproduce:
CREATE OR REPLACE FUNCTION ddl_end()
RETURNS event_trigger AS $$
DECLARE
r RECORD;
BEGIN
FOR r IN SELECT * FROM pg_event_trigger_ddl_commands()
LOOP
RAISE NOTICE 'ddl_end: % %', r.command_tag, r.object_type;
END LOOP;
END;
$$ LANGUAGE plpgsql;

CREATE EVENT TRIGGER ddl_end ON ddl_command_end EXECUTE PROCEDURE ddl_end();

CREATE TABLE t(f1 int NOT NULL GENERATED ALWAYS AS IDENTITY);
ALTER TABLE t ALTER COLUMN f1 DROP IDENTITY, ALTER COLUMN f1 SET DATA
TYPE bigint;

--
Regards, Sven Klemm

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2021-02-13 17:21:58 Re: Unexpected serialization error
Previous Message PG Bug reporting form 2021-02-13 13:35:40 BUG #16864: cache lookup failed for relation 1255