On Mon, 2008-10-06 at 18:57 -0400, Tom Lane wrote: > Simon Riggs <[EMAIL PROTECTED]> writes: > > It seems possible to change some DDL commands/subcommands to use a > > ShareLock rather than an AccessExclusiveLock. Enclosed patch implements > > this reduction for CREATE TRIGGER, CREATE RULE and ALTER TABLE. > > What happens when two transactions try to do one of these things > concurrently to the same table?
It should be very similar to CREATE INDEX. If they hold ShareLocks then their locks do not conflict at relation level. Updates of their pg_class entry should be handled non-transactionally, just as they are with CREATE INDEX. This is the reason for the change from reltriggers being an exact count to being a boolean, i.e. it is actually now relhastriggers = true | false. Multiple updaters will then change the value to the same thing. It was an excellent question because that aspect isn't handled correctly in the enclosed patch for subcommands, other than index-creating constraints. My main focus is on these commands * CREATE TRIGGER * ALTER TABLE .. ADD PRIMARY KEY * ALTER TABLE .. ADD FOREIGN KEY because those are the most painful ones. We could make it work against more, but we'd need to rewrite lots and lots of catalog update code. So I'll make CreateTrigger() use index_update_stats() so we get the atomic update correct. -- Simon Riggs www.2ndQuadrant.com PostgreSQL Training, Services and Support -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers