Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2dbbda0

Browse files
Reduce lock levels of CREATE TRIGGER and some ALTER TABLE, CREATE RULE actions.
Avoid hard-coding lockmode used for many altering DDL commands, allowing easier future changes of lock levels. Implementation of initial analysis on DDL sub-commands, so that many lock levels are now at ShareUpdateExclusiveLock or ShareRowExclusiveLock, allowing certain DDL not to block reads/writes. First of number of planned changes in this area; additional docs required when full project complete.
1 parent 133924e commit 2dbbda0

File tree

10 files changed

+426
-232
lines changed

10 files changed

+426
-232
lines changed

doc/src/sgml/mvcc.sgml

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/mvcc.sgml,v 2.75 2010/05/03 15:35:30 alvherre Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/mvcc.sgml,v 2.76 2010/07/28 05:22:24 sriggs Exp $ -->
22

33
<chapter id="mvcc">
44
<title>Concurrency Control</title>
@@ -532,7 +532,7 @@ SELECT SUM(value) FROM mytab WHERE class = 2;
532532
most <productname>PostgreSQL</productname> commands automatically
533533
acquire locks of appropriate modes to ensure that referenced
534534
tables are not dropped or modified in incompatible ways while the
535-
command executes. (For example, <command>ALTER TABLE</> cannot safely be
535+
command executes. (For example, <command>TRUNCATE</> cannot safely be
536536
executed concurrently with other operations on the same table, so it
537537
obtains an exclusive lock on the table to enforce that.)
538538
</para>
@@ -695,8 +695,9 @@ SELECT SUM(value) FROM mytab WHERE class = 2;
695695
</para>
696696

697697
<para>
698-
This lock mode is not automatically acquired by any
699-
<productname>PostgreSQL</productname> command.
698+
Acquired by <command>CREATE TRIGGER</command>,
699+
<command>CREATE RULE</command> (except for <literal>ON SELECT</>
700+
rules) and in some cases <command>ALTER TABLE</command>.
700701
</para>
701702
</listitem>
702703
</varlistentry>
@@ -742,11 +743,12 @@ SELECT SUM(value) FROM mytab WHERE class = 2;
742743
</para>
743744

744745
<para>
745-
Acquired by the <command>ALTER TABLE</command>, <command>DROP
746-
TABLE</command>, <command>TRUNCATE</command>, <command>REINDEX</command>,
746+
Acquired by the <command>DROP TABLE</command>,
747+
<command>TRUNCATE</command>, <command>REINDEX</command>,
747748
<command>CLUSTER</command>, and <command>VACUUM FULL</command>
748-
commands. This is also the default lock mode for <command>LOCK
749-
TABLE</command> statements that do not specify a mode explicitly.
749+
commands, as well as most variants of <command>ALTER TABLE</>.
750+
This is also the default lock mode for <command>LOCK TABLE</command>
751+
statements that do not specify a mode explicitly.
750752
</para>
751753
</listitem>
752754
</varlistentry>

src/backend/catalog/pg_shdepend.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.43 2010/07/06 19:18:56 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.44 2010/07/28 05:22:24 sriggs Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1346,7 +1346,7 @@ shdepReassignOwned(List *roleids, Oid newrole)
13461346
* owned sequences, etc when we happen to visit them
13471347
* before their parent table.
13481348
*/
1349-
ATExecChangeOwner(sdepForm->objid, newrole, true);
1349+
ATExecChangeOwner(sdepForm->objid, newrole, true, AccessExclusiveLock);
13501350
break;
13511351

13521352
case ProcedureRelationId:

src/backend/commands/alter.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/alter.c,v 1.36 2010/06/13 17:43:12 rhaas Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/alter.c,v 1.37 2010/07/28 05:22:24 sriggs Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -190,7 +190,7 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt)
190190
case OBJECT_VIEW:
191191
CheckRelationOwnership(stmt->relation, true);
192192
AlterTableNamespace(stmt->relation, stmt->newschema,
193-
stmt->objectType);
193+
stmt->objectType, AccessExclusiveLock);
194194
break;
195195

196196
case OBJECT_TYPE:

0 commit comments

Comments
 (0)