DROP FUNCTION failure: cache lookup failed for relation X

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: DROP FUNCTION failure: cache lookup failed for relation X
Date: 2007-01-22 04:45:19
Message-ID: 20070122044519.GA62207@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

I've found a situation that causes DROP FUNCTION to fail (tested
in 8.1.6, 8.2.1, and 8.3devel):

CREATE TABLE foo (id integer);

CREATE FUNCTION foofunc() RETURNS trigger AS $$
BEGIN
RETURN NEW;
END;
$$ LANGUAGE plpgsql;

Then in concurrent sessions:

A: BEGIN;

A: CREATE TRIGGER footrig BEFORE INSERT ON foo
FOR EACH ROW EXECUTE PROCEDURE foofunc();

B: DROP TABLE foo; -- blocks pending A's commit

A: COMMIT; -- B's DROP TABLE completes

A: SELECT tgrelid FROM pg_trigger WHERE tgname = 'footrig';
tgrelid
---------
66153
(1 row)

A: DROP FUNCTION foofunc();
ERROR: cache lookup failed for relation 66153

Apparently the row in pg_trigger that A committed wasn't deleted
by B's DROP TABLE, presumably because B didn't have visibility to
to the trigger when its DROP TABLE statement began. This case is
admittedly contrived but I did stumble across it in a test environment.

--
Michael Fuhr

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2007-01-22 04:52:55 Re: [HACKERS] Win32 WEXITSTATUS too simplistic
Previous Message Tom Lane 2007-01-22 03:51:39 Re: Function execution costs 'n all that

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2007-01-22 04:52:55 Re: [HACKERS] Win32 WEXITSTATUS too simplistic
Previous Message Jaime Casanova 2007-01-21 07:32:31 Re: [PATCHES] Tablespace for temporary objects and sort files