Subject: error in rules?

From: Kent Archie <[email-masked]>
Date: Sun, 29 Aug 93 23:50:21 CDT

I am using Postgres 4.1 with the pre-compiled binaries for the Sun under
SunOS 4.1.3.

I create a rule like this.

define rule addfile2 is
on append to amt_files
do append amt_version(file_id = new.file_id,amt_table = "struct_tree",ver_num=0)
\g

After appending to amt_files, the amt_version table is empty.
It appears the rule did not fire.

I attempt to remove the rule and re-do it but:

ginko>monitor -c"remove rule addfile2" amt
WARN:Aug 29 23:36:14:prs2GetRuleEventRel: class 20816 not found

I then add the rule again anyway and get:

*
Query sent to backend is "define rule addfile2 is  on append to amt_files do app
end amt_version(file_id = new.file_id,amt_table = "struct_tree",ver_num=0)"
WARN:Aug 29 23:31:17:Sorry, rule addfile2 is already defined

This stuff worked earlier this month or so, on this version of Postgres.
Or at least it appeared to.
Any suggestions?
**kent
Kent Archie
[email-masked]

---

From: [email-masked] (Paul M. Aoki)
Date: Mon, 30 Aug 93 08:54:16 -0700

> WARN:Aug 29 23:36:14:prs2GetRuleEventRel: class 20816 not found

i've seen this happen when i've destroyed a class before cleaning all
of the rules out.

something like the following should clean up the dead rule info in
the catalogs:

delete pg_prs2plans where pg_prs2plans.prs2ruleid = pg_prs2rule.oid 
        and pg_prs2rule.prs2eventrel = "20816"::oid\g
delete pg_prs2rule where pg_prs2rule.prs2eventrel = "20816"::oid\g
delete pg_prs2stub where pg_prs2stub.prs2relid = "20816"::oid\g

the system should probably be smarter and nuke all rules defined on
a class before nuking the class.  in general the system does not try
hard to ensure that you are not leaving dangling references in the
system catalogs when you blow things away (classes, types, etc.).
it assumes you are going to do that -- there are some circularities
involved...
--
  Paul M. Aoki  |  CS Div., Dept. of EECS, UCB  |  [email-masked]
                |  Berkeley, CA 94720           |  ...!uunet!ucbvax!aoki