Rod Taylor <rbt@rbt.ca> writes:
> /* Call CreateComments() to create/drop the comments */
> CreateComments(ruleoid, classoid, 0, comment);
> +
> + heap_close(relation, AccessShareLock);
> }
>
> /*
Ooops.
I think though that this should read
+ heap_close(relation, NoLock);
In general, we hold locks on user relations we are modifying until end
of transaction. This is different from the rule for system catalogs
(eg, it's okay to drop the AccessShareLock on pg_rewrite a few lines
above this). The reason for the distinction is that we want to be
sure that the user relation won't get DROPped by someone else before
we've committed our changes. (If someone else did try to drop it in
that interval, they'd not delete the pg_description row we just added,
because they couldn't see it.) On the other hand, system catalogs such
as pg_rewrite are not going to go away, by definition, and so it's okay
to drop their locks early. The only reason we lock system catalogs at
all is to allow VACUUM FULL to nail down exclusive access to a catalog
while it vacuums it.
regards, tom lane