diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2017-06-15 10:42:10 +0300 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2017-06-16 11:44:00 +0300 |
commit | 501e6f8b7875a1d7928653d0a0a01b84db6c1257 (patch) | |
tree | 0cbdba334e5d1da53aaa0d07d533d257829e657b /src/backend/commands/functioncmds.c | |
parent | c7e17ce4eed9eb995e7c39f1027498882dcd3bd4 (diff) | |
download | postgresql-501e6f8b7875a1d7928653d0a0a01b84db6c1257.tar.gz postgresql-501e6f8b7875a1d7928653d0a0a01b84db6c1257.zip |
Fix dependency, when changing a function's argument/return type.
When a new base type is created using the old-style procedure of first
creating the input/output functions with "opaque" in place of the base
type, the "opaque" argument/return type is changed to the final base type,
on CREATE TYPE. However, we did not create a pg_depend record when doing
that, so the functions were left not depending on the type.
Fixes bug #14706, reported by Karen Huddleston.
Discussion: https://www.postgresql.org/message-id/20170614232259.1424.82774@wrigleys.postgresql.org
Diffstat (limited to 'src/backend/commands/functioncmds.c')
-rw-r--r-- | src/backend/commands/functioncmds.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index bcc3a883675..aa8c516640e 100644 --- a/src/backend/commands/functioncmds.c +++ b/src/backend/commands/functioncmds.c @@ -1278,6 +1278,8 @@ SetFunctionReturnType(Oid funcOid, Oid newRetType) Relation pg_proc_rel; HeapTuple tup; Form_pg_proc procForm; + ObjectAddress func_address; + ObjectAddress type_address; pg_proc_rel = heap_open(ProcedureRelationId, RowExclusiveLock); @@ -1298,6 +1300,14 @@ SetFunctionReturnType(Oid funcOid, Oid newRetType) CatalogUpdateIndexes(pg_proc_rel, tup); heap_close(pg_proc_rel, RowExclusiveLock); + + /* + * Also update the dependency to the new type. Opaque is a pinned type, so + * there is no old dependency record for it that we would need to remove. + */ + ObjectAddressSet(type_address, TypeRelationId, newRetType); + ObjectAddressSet(func_address, ProcedureRelationId, funcOid); + recordDependencyOn(&func_address, &type_address, DEPENDENCY_NORMAL); } @@ -1312,6 +1322,8 @@ SetFunctionArgType(Oid funcOid, int argIndex, Oid newArgType) Relation pg_proc_rel; HeapTuple tup; Form_pg_proc procForm; + ObjectAddress func_address; + ObjectAddress type_address; pg_proc_rel = heap_open(ProcedureRelationId, RowExclusiveLock); @@ -1333,6 +1345,14 @@ SetFunctionArgType(Oid funcOid, int argIndex, Oid newArgType) CatalogUpdateIndexes(pg_proc_rel, tup); heap_close(pg_proc_rel, RowExclusiveLock); + + /* + * Also update the dependency to the new type. Opaque is a pinned type, so + * there is no old dependency record for it that we would need to remove. + */ + ObjectAddressSet(type_address, TypeRelationId, newArgType); + ObjectAddressSet(func_address, ProcedureRelationId, funcOid); + recordDependencyOn(&func_address, &type_address, DEPENDENCY_NORMAL); } |