Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-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

pgsql-hackers by date

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

pgsql-patches by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group