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

Commit1c612bc

Browse files
committed
Lock the extension during ALTER EXTENSION ADD/DROP.
Although we were careful to lock the object being added or dropped,we failed to get any sort of lock on the extension itself. Thisallowed the ALTER to proceed in parallel with a DROP EXTENSION,which is problematic for a couple of reasons. If both commandssucceeded we'd be left with a dangling link in pg_depend, whichwould cause problems later. Also, if the ALTER failed for somereason, it might try to print the extension's name, and that couldresult in a crash or (in older branches) a silly error messagecomplaining about extension "(null)".Per bug #17098 from Alexander Lakhin. Back-patch to allsupported branches.Discussion:https://postgr.es/m/17098-b960f3616c861f83@postgresql.org
1 parentedd9a2b commit1c612bc

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

‎src/backend/commands/extension.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3282,9 +3282,17 @@ ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *stmt,
32823282
Relationrelation;
32833283
OidoldExtension;
32843284

3285-
extension.classId=ExtensionRelationId;
3286-
extension.objectId=get_extension_oid(stmt->extname, false);
3287-
extension.objectSubId=0;
3285+
/*
3286+
* Find the extension and acquire a lock on it, to ensure it doesn't get
3287+
* dropped concurrently. A sharable lock seems sufficient: there's no
3288+
* reason not to allow other sorts of manipulations, such as add/drop of
3289+
* other objects, to occur concurrently. Concurrently adding/dropping the
3290+
* *same* object would be bad, but we prevent that by using a non-sharable
3291+
* lock on the individual object, below.
3292+
*/
3293+
extension=get_object_address(OBJECT_EXTENSION,
3294+
(Node*)makeString(stmt->extname),
3295+
&relation,AccessShareLock, false);
32883296

32893297
/* Permission check: must own extension */
32903298
if (!pg_extension_ownercheck(extension.objectId,GetUserId()))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp