aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/functioncmds.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2012-04-24 09:20:53 -0400
committerRobert Haas <rhaas@postgresql.org>2012-04-24 09:20:53 -0400
commit3ce7f18e92e9687308ed5d9e516eb7e2f0decadb (patch)
treef4a22b79b2e5bd859e1b2c9689da043fa85e11c0 /src/backend/commands/functioncmds.c
parente4f06b70c9ac1473591d705990a8b601915ce4bd (diff)
downloadpostgresql-3ce7f18e92e9687308ed5d9e516eb7e2f0decadb.tar.gz
postgresql-3ce7f18e92e9687308ed5d9e516eb7e2f0decadb.zip
Casts to or from a domain type are ignored; warn and document.
Prohibiting this outright would break dumps taken from older versions that contain such casts, which would create far more pain than is justified here. Per report by Jaime Casanova and subsequent discussion.
Diffstat (limited to 'src/backend/commands/functioncmds.c')
-rw-r--r--src/backend/commands/functioncmds.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index 4125b97e89e..5f1c19eb375 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -1517,6 +1517,17 @@ CreateCast(CreateCastStmt *stmt)
aclcheck_error(aclresult, ACL_KIND_TYPE,
format_type_be(targettypeid));
+ /* Domains are allowed for historical reasons, but we warn */
+ if (sourcetyptype == TYPTYPE_DOMAIN)
+ ereport(WARNING,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("cast will be ignored because the source data type is a domain")));
+
+ else if (targettyptype == TYPTYPE_DOMAIN)
+ ereport(WARNING,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("cast will be ignored because the target data type is a domain")));
+
/* Detemine the cast method */
if (stmt->func != NULL)
castmethod = COERCION_METHOD_FUNCTION;