CREATE RULE may generate duplicate entries in pg_depend - Mailing list pgsql-hackers

From Ashwin Agrawal
Subject CREATE RULE may generate duplicate entries in pg_depend
Date
Msg-id CAKSySwf+ahKitw-QvDYs3j3orVL-eaBx=U0SN7SYamoL3toCyA@mail.gmail.com
Whole thread Raw
Responses Re: CREATE RULE may generate duplicate entries in pg_depend  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
If action and qual reference same object in CREATE RULE, it results in creating duplicate entries in pg_depend for it. Doesn't pose any harm, just unnecessarily bloats pg_depend. Reference InsertRule(). I think should be able to avoid adding duplicate entries.

Don't know if this behaviour was discussed earlier, I didn't find it on search.
We accidentally encountered it while enhancing a catalog check tool for Greenplum Database.

For example (from rules test):
create table rtest_t5 (a int4, b text);
create table rtest_t7 (a int4, b text);

create rule rtest_t5_ins as on insert to rtest_t5
where new.a > 15 do
insert into rtest_t7 values (new.a, new.b);

# select classid::regclass, refobjid::regclass,* from pg_depend where refobjid='rtest_t5'::regclass and deptype = 'n';
  classid   | refobjid | classid | objid | objsubid | refclassid | refobjid | refobjsubid | deptype
------------+----------+---------+-------+----------+------------+----------+-------------+---------
 pg_rewrite | rtest_t5 |    2618 | 16457 |        0 |       1259 |    16445 |           1 | n
 pg_rewrite | rtest_t5 |    2618 | 16457 |        0 |       1259 |    16445 |           1 | n
 pg_rewrite | rtest_t5 |    2618 | 16457 |        0 |       1259 |    16445 |           2 | n
(3 rows)


-- 
Ashwin Agrawal (VMware)

pgsql-hackers by date:

Previous
From: Jim Nasby
Date:
Subject: Typo in procarray.c comment about GlobalVisDataRels
Next
From: Tom Lane
Date:
Subject: Re: CREATE RULE may generate duplicate entries in pg_depend