aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/functioncmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands/functioncmds.c')
-rw-r--r--src/backend/commands/functioncmds.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index e6fcfc23b93..1f820c93e96 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -1526,6 +1526,8 @@ CreateCast(CreateCastStmt *stmt)
char sourcetyptype;
char targettyptype;
Oid funcid;
+ Oid incastid = InvalidOid;
+ Oid outcastid = InvalidOid;
int nargs;
char castcontext;
char castmethod;
@@ -1603,7 +1605,9 @@ CreateCast(CreateCastStmt *stmt)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("cast function must take one to three arguments")));
- if (!IsBinaryCoercible(sourcetypeid, procstruct->proargtypes.values[0]))
+ if (!IsBinaryCoercibleWithCast(sourcetypeid,
+ procstruct->proargtypes.values[0],
+ &incastid))
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("argument of cast function must match or be binary-coercible from source data type")));
@@ -1617,7 +1621,9 @@ CreateCast(CreateCastStmt *stmt)
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("third argument of cast function must be type %s",
"boolean")));
- if (!IsBinaryCoercible(procstruct->prorettype, targettypeid))
+ if (!IsBinaryCoercibleWithCast(procstruct->prorettype,
+ targettypeid,
+ &outcastid))
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("return data type of cast function must match or be binary-coercible to target data type")));
@@ -1756,8 +1762,8 @@ CreateCast(CreateCastStmt *stmt)
break;
}
- myself = CastCreate(sourcetypeid, targettypeid, funcid, castcontext,
- castmethod, DEPENDENCY_NORMAL);
+ myself = CastCreate(sourcetypeid, targettypeid, funcid, incastid, outcastid,
+ castcontext, castmethod, DEPENDENCY_NORMAL);
return myself;
}