Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 2CB6B633112 for ; Tue, 12 May 2009 13:43:35 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 88164-04 for ; Tue, 12 May 2009 13:43:32 -0300 (ADT) Received: from cvs.postgresql.org (cvs.postgresql.org [217.196.146.206]) by mail.postgresql.org (Postfix) with ESMTP id D99906324B5 for ; Tue, 12 May 2009 13:43:33 -0300 (ADT) Received: by cvs.postgresql.org (Postfix, from userid 1007) id BFC1575407D; Tue, 12 May 2009 16:43:32 +0000 (UTC) MIME-Version: 1.0 To: pgsql-committers@postgresql.org Subject: pgsql: Fix LOCK TABLE to eliminate the race condition that could make it X-Mailer: activitymail 1.24, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain Message-Id: <20090512164332.BFC1575407D@cvs.postgresql.org> Date: Tue, 12 May 2009 16:43:32 +0000 (UTC) From: tgl@postgresql.org (Tom Lane) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200905/211 X-Sequence-Number: 37041 Log Message: ----------- Fix LOCK TABLE to eliminate the race condition that could make it give weird errors when tables are concurrently dropped. To do this we must take lock on each relation before we check its privileges. The old code was trying to do that the other way around, which is a bit pointless when there are lots of other commands that lock relations before checking privileges. I did keep it checking each relation's privilege before locking the next relation, which is a detail that ALTER TABLE isn't too picky about. Modified Files: -------------- pgsql/src/backend/access/heap: heapam.c (r1.274 -> r1.275) (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/heap/heapam.c?r1=1.274&r2=1.275) pgsql/src/backend/commands: lockcmds.c (r1.23 -> r1.24) (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/lockcmds.c?r1=1.23&r2=1.24) pgsql/src/include/access: heapam.h (r1.141 -> r1.142) (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/access/heapam.h?r1=1.141&r2=1.142)