diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2009-11-13 16:09:20 +0000 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2009-11-13 16:09:20 +0000 |
commit | 959af88533cf682a2522a78f99056bc8adf0b58c (patch) | |
tree | d0072a5e6637cf55a12444ed6cc601c74ab1c90c | |
parent | 66ad0b3a05fce400dffb5f6f2da2a2e4462897af (diff) | |
download | postgresql-959af88533cf682a2522a78f99056bc8adf0b58c.tar.gz postgresql-959af88533cf682a2522a78f99056bc8adf0b58c.zip |
When you do "ARRAY[...]::domain", where domain is a domain over an array type,
we need to check domain constraints. We used to do it correctly, but 8.4
introduced a separate code path for the "ARRAY[]::arraytype" case to infer
the type of an empty ARRAY construct from the cast target, and forgot to take
domains into account.
Per report from Florian G. Pflug.
-rw-r--r-- | src/backend/parser/parse_expr.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c index d0e568525c6..9899d81df5f 100644 --- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.241.2.2 2009/10/27 17:11:30 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.241.2.3 2009/11/13 16:09:20 heikki Exp $ * *------------------------------------------------------------------------- */ @@ -169,6 +169,20 @@ transformExpr(ParseState *pstate, Node *expr) targetType, elementType, targetTypmod); + + /* + * If the target array type is a domain, we still need + * to check the domain constraint. (coerce_to_domain + * is a no-op if targetType is not a domain) + */ + result = coerce_to_domain(result, + InvalidOid, + -1, + targetType, + COERCE_IMPLICIT_CAST, + tc->location, + false, + true); break; } |