mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-11-27 07:21:09 +08:00
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.
This commit is contained in:
parent
b40b3306fa
commit
f758097c6d
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.112 2003/11/29 19:51:52 pgsql Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.113 2003/12/17 19:49:39 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;
|
||||
@ -395,6 +384,17 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *target_typeids,
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
|
Loading…
Reference in New Issue
Block a user