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

Commitc9e2e2d

Browse files
committed
Partially restore comments discussing enum renumbering hazards.
As noted by Tom Lane, commit813fb03was overly optimistic about how safe it is to concurrently changeenumsortorder values under MVCC catalog scan semantics. Restoresome of the previous text, with hopefully-correct adjustments forthe new state of play.
1 parentda85fb4 commitc9e2e2d

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

‎src/backend/catalog/pg_enum.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,22 @@ AddEnumLabel(Oid enumTypeOid,
462462
*Renumber existing enum elements to have sort positions 1..n.
463463
*
464464
* We avoid doing this unless absolutely necessary; in most installations
465-
* it will never happen. Before we had MVCC catalog scans, this function
466-
* posed various concurrency hazards. It no longer does, but it's still
467-
* extra work, so we don't do it unless it's needed.
465+
* it will never happen. The reason is that updating existing pg_enum
466+
* entries creates hazards for other backends that are concurrently reading
467+
* pg_enum. Although system catalog scans now use MVCC semantics, the
468+
* syscache machinery might read different pg_enum entries under different
469+
* snapshots, so some other backend might get confused about the proper
470+
* ordering if a concurrent renumbering occurs.
471+
*
472+
* We therefore make the following choices:
473+
*
474+
* 1. Any code that is interested in the enumsortorder values MUST read
475+
* all the relevant pg_enum entries with a single MVCC snapshot, or else
476+
* acquire lock on the enum type to prevent concurrent execution of
477+
* AddEnumLabel().
478+
*
479+
* 2. Code that is not examining enumsortorder can use a syscache
480+
* (for example, enum_in and enum_out do so).
468481
*/
469482
staticvoid
470483
RenumberEnumType(Relationpg_enum,HeapTuple*existing,intnelems)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp