summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2003-12-17 19:49:52 +0000
committerTom Lane2003-12-17 19:49:52 +0000
commit5129070dfde66d5d899920b4c75372af102ea449 (patch)
tree20f36ae2542fcf9ca62d5f466a467315b549c777
parentea27e96dd004a21dbc1435949e5bb859b3724cd0 (diff)
Reorder tests in parse_coerce so that ANY/ANYELEMENT/ANYARRAY coercion
does not affect UNKNOWN-type literals or Params. This fixes the recent complaint about count('x') being broken, and improves consistency in a few other respects too.
-rw-r--r--src/backend/parser/parse_coerce.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c
index 570ddf86eff..82b47eaaeb0 100644
--- a/src/backend/parser/parse_coerce.c
+++ b/src/backend/parser/parse_coerce.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.111 2003/09/29 00:05:25 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.111.2.1 2003/12/17 19:49:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -153,6 +153,14 @@ coerce_type(ParseState *pstate, Node *node,
/* no conversion needed */
return node;
}
+ if (targetTypeId == ANYOID ||
+ targetTypeId == ANYARRAYOID ||
+ targetTypeId == ANYELEMENTOID)
+ {
+ /* assume can_coerce_type verified that implicit coercion is okay */
+ /* NB: we do NOT want a RelabelType here */
+ return node;
+ }
if (inputTypeId == UNKNOWNOID && IsA(node, Const))
{
/*
@@ -260,14 +268,6 @@ coerce_type(ParseState *pstate, Node *node,
param->paramtype = targetTypeId;
return (Node *) param;
}
- if (targetTypeId == ANYOID ||
- targetTypeId == ANYARRAYOID ||
- targetTypeId == ANYELEMENTOID)
- {
- /* assume can_coerce_type verified that implicit coercion is okay */
- /* NB: we do NOT want a RelabelType here */
- return node;
- }
if (find_coercion_pathway(targetTypeId, inputTypeId, ccontext,
&funcId))
{
@@ -372,17 +372,6 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *target_typeids,
if (!typeidIsValid(targetTypeId))
return false;
- /*
- * If input is an untyped string constant, assume we can convert
- * it to anything except a class type.
- */
- if (inputTypeId == UNKNOWNOID)
- {
- if (ISCOMPLEX(targetTypeId))
- return false;
- continue;
- }
-
/* accept if target is ANY */
if (targetTypeId == ANYOID)
continue;
@@ -396,6 +385,17 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *target_typeids,
}
/*
+ * If input is an untyped string constant, assume we can convert
+ * it to anything except a class type.
+ */
+ if (inputTypeId == UNKNOWNOID)
+ {
+ if (ISCOMPLEX(targetTypeId))
+ return false;
+ continue;
+ }
+
+ /*
* If pg_cast shows that we can coerce, accept. This test now
* covers both binary-compatible and coercion-function cases.
*/