Forum OpenACS Development: Response to Weird error invoking a plpgsql function (content_revision__delete)

If you delete a relation, then the relation will no longer be in the system catalogs.

You can see how this works in a simple test case:

-- file tst.sql
create table test_ids (
       val   integer
);

create function test_id_drop () returns integer as '
declare
        v_val   integer;
begin
        select val into v_val from test_ids where val = 3;
        return null;
end;' language 'plpgsql';

openacs4=# i tst.sql
DROP
CREATE
DROP
CREATE
openacs4=# select oid from pg_class where relname = 'test_ids';
  oid   
--------
 249461
(1 row)

openacs4=# select test_id_drop();
 test_id_drop 
--------------
             
(1 row)

openacs4=# drop table test_ids;
DROP
openacs4=# select test_id_drop();
ERROR:  Relation 249461 does not exist
openacs4=# select oid from pg_class where relname = 'test_ids';
 oid 
-----
(0 rows)

openacs4=#