1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-14 18:42:34 +03:00

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.
This commit is contained in:
Robert Haas
2012-04-24 09:20:53 -04:00
parent e4f06b70c9
commit 3ce7f18e92
3 changed files with 17 additions and 0 deletions

View File

@ -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;