diff options
author | Michael Paquier <michael@paquier.xyz> | 2023-07-10 13:08:10 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2023-07-10 13:08:10 +0900 |
commit | 9b286858e3ab1647304c5fbb2b1529de6bead8f7 (patch) | |
tree | 49e054aed70a033106195ce595723e842be52a0d /src/backend/commands/alter.c | |
parent | bd5ddbe8666a11e34ba77e4c1788c4832dcd9a50 (diff) | |
download | postgresql-9b286858e3ab1647304c5fbb2b1529de6bead8f7.tar.gz postgresql-9b286858e3ab1647304c5fbb2b1529de6bead8f7.zip |
Add more sanity checks with callers of changeDependencyFor()
changeDependencyFor() returns the number of pg_depend entries changed,
or 0 if there is a problem. The callers of this routine expect only one
dependency to change, but they did not check for the result returned.
The following code paths gain checks:
- Namespace for extensions.
- Namespace for various object types (see AlterObjectNamespace).
- Planner support function for a function.
Some existing error messages related to all that are reworded to be more
consistent with the project style, and the new error messages added
follow the same style. This change has exposed one bug fixed a bit
earlier with bd5ddbe.
Reviewed-by: Heikki Linnakangas, Akshat Jaimini
Discussion: https://postgr.es/m/ZJzD/rn+UbloKjB7@paquier.xyz
Diffstat (limited to 'src/backend/commands/alter.c')
-rw-r--r-- | src/backend/commands/alter.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c index e95dc31bde3..d64929df558 100644 --- a/src/backend/commands/alter.c +++ b/src/backend/commands/alter.c @@ -847,9 +847,11 @@ AlterObjectNamespace_internal(Relation rel, Oid objid, Oid nspOid) pfree(nulls); pfree(replaces); - /* update dependencies to point to the new schema */ - changeDependencyFor(classId, objid, - NamespaceRelationId, oldNspOid, nspOid); + /* update dependency to point to the new schema */ + if (changeDependencyFor(classId, objid, + NamespaceRelationId, oldNspOid, nspOid) != 1) + elog(ERROR, "could not change schema dependency for object %u", + objid); InvokeObjectPostAlterHook(classId, objid, 0); |