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

Commitd1e0f40

Browse files
committed
Fix ALTER EXTENSION SET SCHEMA with objects outside an extension's schema
As coded, the code would use as a base comparison the namespace OID fromthe first object scanned in pg_depend when switching its namespacedependency entry to the new one, and use it as a base of comparison forany follow-up checks. It would also be used as the old namespace OID toswitch *from* for the extension's pg_depend entry. Hence, if the firstobject scanned has a namespace different than the one stored in theextension, we would finish by:- Not checking that the extension objects map with the extension'sschema.- Not switching the extension -> namespace dependency entry to the newnamespace provided by the user, making ALTER EXTENSION ineffective.This issue exists since this command has been introduced ind9572c4 forrelocatable extension, so backpatch all the way down to 11. The testcase has been provided by Heikki, that I have tweaked a bit to show theeffects on pg_depend for the extension.Reported-by: Heikki LinnakangasAuthor: Michael Paquier, Heikki LinnakangasDiscussion:https://postgr.es/m/20eea594-a05b-4c31-491b-007b6fceef28@iki.fiBackpatch-through: 11
1 parent3883ef3 commitd1e0f40

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

‎src/backend/commands/extension.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2711,7 +2711,7 @@ AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *o
27112711
{
27122712
OidextensionOid;
27132713
OidnspOid;
2714-
OidoldNspOid=InvalidOid;
2714+
OidoldNspOid;
27152715
AclResultaclresult;
27162716
RelationextRel;
27172717
ScanKeyDatakey[2];
@@ -2794,6 +2794,9 @@ AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *o
27942794

27952795
objsMoved=new_object_addresses();
27962796

2797+
/* store the OID of the namespace to-be-changed */
2798+
oldNspOid=extForm->extnamespace;
2799+
27972800
/*
27982801
* Scan pg_depend to find objects that depend directly on the extension,
27992802
* and alter each one's schema.
@@ -2839,12 +2842,6 @@ AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *o
28392842
nspOid,
28402843
objsMoved);
28412844

2842-
/*
2843-
* Remember previous namespace of first object that has one
2844-
*/
2845-
if (oldNspOid==InvalidOid&&dep_oldNspOid!=InvalidOid)
2846-
oldNspOid=dep_oldNspOid;
2847-
28482845
/*
28492846
* If not all the objects had the same old namespace (ignoring any
28502847
* that are not in namespaces), complain.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp