diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2008-07-11 07:02:43 +0000 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2008-07-11 07:02:43 +0000 |
commit | e3afbb3504c7dbf4b1fdd90dcb4eaac0ad084333 (patch) | |
tree | 6bc6f2e7f6bbaedffbf04b834a0372052d6757c0 /src/backend/commands/functioncmds.c | |
parent | 110147653aebe8eba9a42559e3737ac0d48d107f (diff) | |
download | postgresql-e3afbb3504c7dbf4b1fdd90dcb4eaac0ad084333.tar.gz postgresql-e3afbb3504c7dbf4b1fdd90dcb4eaac0ad084333.zip |
Allow binary-coercible types for cast function arguments and return types.
Document return type of cast functions.
Also change documentation to prefer the term "binary coercible" in its
present sense instead of the previous term "binary compatible".
Diffstat (limited to 'src/backend/commands/functioncmds.c')
-rw-r--r-- | src/backend/commands/functioncmds.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index 68d3a65db57..abb2e6eca88 100644 --- a/src/backend/commands/functioncmds.c +++ b/src/backend/commands/functioncmds.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.93 2008/06/19 00:46:04 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.94 2008/07/11 07:02:43 petere Exp $ * * DESCRIPTION * These routines take the parse tree and pick out the @@ -48,6 +48,7 @@ #include "commands/defrem.h" #include "commands/proclang.h" #include "miscadmin.h" +#include "parser/parse_coerce.h" #include "parser/parse_func.h" #include "parser/parse_type.h" #include "utils/acl.h" @@ -1403,10 +1404,10 @@ CreateCast(CreateCastStmt *stmt) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), errmsg("cast function must take one to three arguments"))); - if (procstruct->proargtypes.values[0] != sourcetypeid) + if (!IsBinaryCoercible(sourcetypeid, procstruct->proargtypes.values[0])) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("argument of cast function must match source data type"))); + errmsg("argument of cast function must match or be binary-compatible with source data type"))); if (nargs > 1 && procstruct->proargtypes.values[1] != INT4OID) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), @@ -1415,10 +1416,10 @@ CreateCast(CreateCastStmt *stmt) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), errmsg("third argument of cast function must be type boolean"))); - if (procstruct->prorettype != targettypeid) + if (!IsBinaryCoercible(procstruct->prorettype, targettypeid)) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("return data type of cast function must match target data type"))); + errmsg("return data type of cast function must match or be binary-compatible with target data type"))); /* * Restricting the volatility of a cast function may or may not be a |