summaryrefslogtreecommitdiff
path: root/src/backend/commands/alter.c
diff options
context:
space:
mode:
authorTom Lane2024-05-09 16:19:43 +0000
committerTom Lane2024-05-09 16:19:52 +0000
commit9effc4608e1f6d19546a0e0f64320f4b0dd10c3c (patch)
treeb0c4d38060d95ee3b4a7cd12368b531520e9d433 /src/backend/commands/alter.c
parentd82ab9fc31aa62d94c26d7df98e65c6ceaadb01f (diff)
Repair ALTER EXTENSION ... SET SCHEMA.
It turns out that we broke this in commit e5bc9454e, because the code was assuming that no dependent types would appear among the extension's direct dependencies, and now they do. This isn't terribly hard to fix: just skip dependent types, expecting that we will recurse to them when we process the parent object (which should also be among the direct dependencies). But a little bit of refactoring is needed so that we can avoid duplicating logic about what is a dependent type. Although there is some testing of ALTER EXTENSION SET SCHEMA, it failed to cover interesting cases, so add more tests. Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/backend/commands/alter.c')
-rw-r--r--src/backend/commands/alter.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index 12802b9d3fd..4f99ebb4470 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -598,16 +598,16 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt,
/*
* Change an object's namespace given its classOid and object Oid.
*
- * Objects that don't have a namespace should be ignored.
+ * Objects that don't have a namespace should be ignored, as should
+ * dependent types such as array types.
*
* This function is currently used only by ALTER EXTENSION SET SCHEMA,
- * so it only needs to cover object types that can be members of an
- * extension, and it doesn't have to deal with certain special cases
- * such as not wanting to process array types --- those should never
- * be direct members of an extension anyway.
+ * so it only needs to cover object kinds that can be members of an
+ * extension, and it can silently ignore dependent types --- we assume
+ * those will be moved when their parent object is moved.
*
* Returns the OID of the object's previous namespace, or InvalidOid if
- * object doesn't have a schema.
+ * object doesn't have a schema or was ignored due to being a dependent type.
*/
Oid
AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid,
@@ -631,7 +631,7 @@ AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid,
}
case TypeRelationId:
- oldNspOid = AlterTypeNamespace_oid(objid, nspOid, objsMoved);
+ oldNspOid = AlterTypeNamespace_oid(objid, nspOid, true, objsMoved);
break;
case ProcedureRelationId: