Commit 942702a4 authored by Heikki Linnakangas's avatar Heikki Linnakangas

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.
parent 5e75f679
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.248 2009/11/09 02:36:56 tgl Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.249 2009/11/13 16:09:10 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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment