CREATE RULE may generate duplicate entries in pg_depend
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)*
Ashwin Agrawal <ashwinstar@gmail.com> writes:
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.
Yeah, we generally don't try that hard to prevent duplicate pg_depend
entries. It's relatively easy to get rid of them in limited contexts
like a single expression, but over a wider scope, I doubt it's worth
the trouble.
regards, tom lane