aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_coerce.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/parser/parse_coerce.c')
-rw-r--r--src/backend/parser/parse_coerce.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c
index 9cfe4391bdc..39ae14ee1fa 100644
--- a/src/backend/parser/parse_coerce.c
+++ b/src/backend/parser/parse_coerce.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.144 2006/10/04 00:29:55 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.145 2006/10/11 20:21:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -129,11 +129,22 @@ coerce_type(ParseState *pstate, Node *node,
return node;
}
if (targetTypeId == ANYOID ||
- targetTypeId == ANYARRAYOID ||
- targetTypeId == ANYELEMENTOID)
+ targetTypeId == ANYELEMENTOID ||
+ (targetTypeId == ANYARRAYOID && inputTypeId != UNKNOWNOID))
{
- /* assume can_coerce_type verified that implicit coercion is okay */
- /* NB: we do NOT want a RelabelType here */
+ /*
+ * Assume can_coerce_type verified that implicit coercion is okay.
+ *
+ * Note: by returning the unmodified node here, we are saying that
+ * it's OK to treat an UNKNOWN constant as a valid input for a
+ * function accepting ANY or ANYELEMENT. This should be all right,
+ * since an UNKNOWN value is still a perfectly valid Datum. However
+ * an UNKNOWN value is definitely *not* an array, and so we mustn't
+ * accept it for ANYARRAY. (Instead, we will call anyarray_in below,
+ * which will produce an error.)
+ *
+ * NB: we do NOT want a RelabelType here.
+ */
return node;
}
if (inputTypeId == UNKNOWNOID && IsA(node, Const))