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

Commit871dd02

Browse files
committed
Disallow deletion of CurrentExtensionObject while running extension script.
While the deletion in itself wouldn't break things, any further creationof objects in the script would result in dangling pg_depend entries beingadded by recordDependencyOnCurrentExtension(). An example from PhilSorber convinced me that this is just barely likely enough to be worthexpending a couple lines of code to defend against. The resulting errormessage might be confusing, but it's better than leaving corrupted catalogcontents for the user to deal with.
1 parent269755e commit871dd02

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

‎src/backend/commands/extension.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,6 +1577,23 @@ RemoveExtensionById(Oid extId)
15771577
HeapTupletuple;
15781578
ScanKeyDataentry[1];
15791579

1580+
/*
1581+
* Disallow deletion of any extension that's currently open for insertion;
1582+
* else subsequent executions of recordDependencyOnCurrentExtension()
1583+
* could create dangling pg_depend records that refer to a no-longer-valid
1584+
* pg_extension OID. This is needed not so much because we think people
1585+
* might write "DROP EXTENSION foo" in foo's own script files, as because
1586+
* errors in dependency management in extension script files could give
1587+
* rise to cases where an extension is dropped as a result of recursing
1588+
* from some contained object. Because of that, we must test for the case
1589+
* here, not at some higher level of the DROP EXTENSION command.
1590+
*/
1591+
if (extId==CurrentExtensionObject)
1592+
ereport(ERROR,
1593+
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1594+
errmsg("cannot drop extension \"%s\" because it is being modified",
1595+
get_extension_name(extId))));
1596+
15801597
rel=heap_open(ExtensionRelationId,RowExclusiveLock);
15811598

15821599
ScanKeyInit(&entry[0],

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp