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

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

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: Sun, 21 Jan 2007 21:45:19 -0700
  • Message-id: <20070122044519.GA62207@winnie.fuhr.org> <text/plain>

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



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group