On Wed, Oct 15, 2014 at 9:34 PM, Robert Haas <robertmh...@gmail.com> wrote: > On Wed, Oct 15, 2014 at 10:04 AM, Tom Lane <t...@sss.pgh.pa.us> wrote: > > Amit Kapila <amit.kapil...@gmail.com> writes: > >> I have observed that for renaming some of the objects > >> AccessExclusiveLock is taken on object whereas for > >> other kind of objects no lock is taken on object before > >> renaming the object. > > > > The usual theory for DDL updates of all types (not just rename) > > is that an explicit lock is only needed for objects whose catalog > > representation comprises more than one row. Otherwise, the implicit > > locking involved in updating that row is sufficient to serialize > > different updates.
I am not sure if this rule is followed for all DDL's, as an example, I tried to compare for FUNCTION and SCHEMA. Function has entries in pg_proc, pg_depend (schema, language, returntype, etc.), so by above theory any update should take explicit lock which I think holds good whereas if we see for Schema, it has entries in pg_namespace, pg_depend (owner), but it doesn't take explicit lock during Rename. Yet another anomaly is for "Comment on <Object> .." there is only one row in pg_description, however it still takes explicit lock to avoid concurrent activity which looks right to me. > That's an interesting point that I hadn't considered, but I'm willing > to believe that at least some of the differences might also be > haphazard. Yeah, I also think so, is it important enough that we spend energy to find all such differences and fix them. With Regards, Amit Kapila. EnterpriseDB: http://www.enterprisedb.com