Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitec1339e

Browse files
committed
Finish disabling reduced-lock-levels-for-DDL feature.
Previous patch only covered the ALTER TABLE changes, not changes in othercommands; and it neglected to revert the documentation changes.
1 parent046d52f commitec1339e

File tree

4 files changed

+24
-32
lines changed

4 files changed

+24
-32
lines changed

‎doc/src/sgml/mvcc.sgml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -878,9 +878,8 @@ ERROR: could not serialize access due to read/write dependencies among transact
878878
</para>
879879

880880
<para>
881-
Acquired by <command>CREATE TRIGGER</command>,
882-
<command>CREATE RULE</command> (except for <literal>ON SELECT</>
883-
rules) and some forms of <command>ALTER TABLE</command>.
881+
This lock mode is not automatically acquired by any
882+
<productname>PostgreSQL</productname> command.
884883
</para>
885884
</listitem>
886885
</varlistentry>
@@ -925,10 +924,10 @@ ERROR: could not serialize access due to read/write dependencies among transact
925924
</para>
926925

927926
<para>
928-
Acquired by the <command>DROP TABLE</command>,
927+
Acquired by the <command>ALTER TABLE</>, <command>DROP TABLE</>,
929928
<command>TRUNCATE</command>, <command>REINDEX</command>,
930929
<command>CLUSTER</command>, and <command>VACUUM FULL</command>
931-
commands, and some forms of <command>ALTER TABLE</>.
930+
commands.
932931
This is also the default lock mode for <command>LOCK TABLE</command>
933932
statements that do not specify a mode explicitly.
934933
</para>

‎src/backend/commands/tablecmds.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3409,14 +3409,12 @@ ATRewriteTables(List **wqueue, LOCKMODE lockmode)
34093409
Relationrefrel;
34103410

34113411
if (rel==NULL)
3412+
{
34123413
/* Long since locked, no need for another */
34133414
rel=heap_open(tab->relid,NoLock);
3415+
}
34143416

3415-
/*
3416-
* We're adding a trigger to both tables, so the lock level
3417-
* here should sensibly reflect that.
3418-
*/
3419-
refrel=heap_open(con->refrelid,ShareRowExclusiveLock);
3417+
refrel=heap_open(con->refrelid,RowShareLock);
34203418

34213419
validateForeignKeyConstraint(fkconstraint->conname,rel,refrel,
34223420
con->refindid,
@@ -5508,7 +5506,14 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel,
55085506
OidindexOid;
55095507
OidconstrOid;
55105508

5511-
pkrel=heap_openrv(fkconstraint->pktable,lockmode);
5509+
/*
5510+
* Grab an exclusive lock on the pk table, so that someone doesn't delete
5511+
* rows out from under us. (Although a lesser lock would do for that
5512+
* purpose, we'll need exclusive lock anyway to add triggers to the pk
5513+
* table; trying to start with a lesser lock will just create a risk of
5514+
* deadlock.)
5515+
*/
5516+
pkrel=heap_openrv(fkconstraint->pktable,AccessExclusiveLock);
55125517

55135518
/*
55145519
* Validity checks (permission checks wait till we have the column

‎src/backend/commands/trigger.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
143143
ObjectAddressmyself,
144144
referenced;
145145

146-
/*
147-
* ShareRowExclusiveLock is sufficient to prevent concurrent write
148-
* activity to the relation, and thus to lock out any operations that
149-
* might want to fire triggers on the relation. If we had ON SELECT
150-
* triggers we would need to take an AccessExclusiveLock to add one of
151-
* those, just as we do with ON SELECT rules.
152-
*/
153-
rel=heap_openrv(stmt->relation,ShareRowExclusiveLock);
146+
rel=heap_openrv(stmt->relation,AccessExclusiveLock);
154147

155148
/*
156149
* Triggers must be on tables or views, and there are additional
@@ -480,7 +473,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
480473
* can skip this for internally generated triggers, since the name
481474
* modification above should be sufficient.
482475
*
483-
* NOTE that this is cool only because we haveShareRowExclusiveLock on
476+
* NOTE that this is cool only because we haveAccessExclusiveLock on
484477
* the relation, so the trigger set won't be changing underneath us.
485478
*/
486479
if (!isInternal)
@@ -1084,14 +1077,11 @@ RemoveTriggerById(Oid trigOid)
10841077
elog(ERROR,"could not find tuple for trigger %u",trigOid);
10851078

10861079
/*
1087-
* Open and lock the relation the trigger belongs to. As in
1088-
* CreateTrigger, this is sufficient to lock out all operations that could
1089-
* fire or add triggers; but it would need to be revisited if we had ON
1090-
* SELECT triggers.
1080+
* Open and exclusive-lock the relation the trigger belongs to.
10911081
*/
10921082
relid= ((Form_pg_trigger)GETSTRUCT(tup))->tgrelid;
10931083

1094-
rel=heap_open(relid,ShareRowExclusiveLock);
1084+
rel=heap_open(relid,AccessExclusiveLock);
10951085

10961086
if (rel->rd_rel->relkind!=RELKIND_RELATION&&
10971087
rel->rd_rel->relkind!=RELKIND_VIEW)

‎src/backend/rewrite/rewriteDefine.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,12 @@ DefineQueryRewrite(char *rulename,
240240
/*
241241
* If we are installing an ON SELECT rule, we had better grab
242242
* AccessExclusiveLock to ensure no SELECTs are currently running on the
243-
* event relation.For other types of rules, it is sufficient to grab
244-
* ShareRowExclusiveLock to lock out insert/update/delete actions and to
245-
* ensure that we lock out current CREATE RULE statements.
243+
* event relation. For other types of rules, it would be sufficient to
244+
* grab ShareRowExclusiveLock to lock out insert/update/delete actions and
245+
* to ensure that we lock out current CREATE RULE statements; but because
246+
* of race conditions in access to catalog entries, we can't do that yet.
246247
*/
247-
if (event_type==CMD_SELECT)
248-
event_relation=heap_open(event_relid,AccessExclusiveLock);
249-
else
250-
event_relation=heap_open(event_relid,ShareRowExclusiveLock);
248+
event_relation=heap_open(event_relid,AccessExclusiveLock);
251249

252250
/*
253251
* Verify relation is of a type that rules can sensibly be applied to.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp