aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_expr.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2009-11-13 16:09:10 +0000
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2009-11-13 16:09:10 +0000
commit942702a496c3c45f5f8205ebd59a2827678bed25 (patch)
treeee0031ca37b67714ded2028908f429663a6bb4a9 /src/backend/parser/parse_expr.c
parent5e75f6790c6abc3bb5954ea380fb92e40f867d5e (diff)
downloadpostgresql-942702a496c3c45f5f8205ebd59a2827678bed25.tar.gz
postgresql-942702a496c3c45f5f8205ebd59a2827678bed25.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.
Diffstat (limited to 'src/backend/parser/parse_expr.c')
-rw-r--r--src/backend/parser/parse_expr.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c
index bae5c7fafad..8e0172d256e 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.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;
}