1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-10 17:42:29 +03:00

Pass atttypmod to CoerceTargetExpr, so that it can pass it on to

coerce_type, so that the right things happen when coercing a previously-
unknown constant to a destination data type.
This commit is contained in:
Tom Lane
2000-01-17 02:04:16 +00:00
parent ceca03600e
commit ac4878a060
7 changed files with 27 additions and 24 deletions

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.48 1999/12/17 14:47:35 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.49 2000/01/17 02:04:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -757,7 +757,7 @@ transformUnionClause(List *unionClause, List *targetlist)
Node *expr;
expr = ((TargetEntry *) lfirst(next_target))->expr;
expr = CoerceTargetExpr(NULL, expr, itype, otype);
expr = CoerceTargetExpr(NULL, expr, itype, otype, -1);
if (expr == NULL)
{
elog(ERROR, "Unable to transform %s to %s"

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.65 2000/01/17 00:14:48 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.66 2000/01/17 02:04:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -792,8 +792,8 @@ parser_typecast_expression(ParseState *pstate,
if (inputType != targetType)
{
expr = CoerceTargetExpr(pstate, expr,
inputType, targetType);
expr = CoerceTargetExpr(pstate, expr, inputType,
targetType, typename->typmod);
if (expr == NULL)
elog(ERROR, "Cannot cast type '%s' to '%s'",
typeidTypeName(inputType),

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.35 2000/01/15 02:59:32 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.36 2000/01/17 02:04:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -319,8 +319,8 @@ transformArraySubscripts(ParseState *pstate,
{
subexpr = transformExpr(pstate, ai->lidx, EXPR_COLUMN_FIRST);
/* If it's not int4 already, try to coerce */
subexpr = CoerceTargetExpr(pstate, subexpr,
exprType(subexpr), INT4OID);
subexpr = CoerceTargetExpr(pstate, subexpr, exprType(subexpr),
INT4OID, -1);
if (subexpr == NULL)
elog(ERROR, "array index expressions must be integers");
}
@@ -339,8 +339,8 @@ transformArraySubscripts(ParseState *pstate,
}
subexpr = transformExpr(pstate, ai->uidx, EXPR_COLUMN_FIRST);
/* If it's not int4 already, try to coerce */
subexpr = CoerceTargetExpr(pstate, subexpr,
exprType(subexpr), INT4OID);
subexpr = CoerceTargetExpr(pstate, subexpr, exprType(subexpr),
INT4OID, -1);
if (subexpr == NULL)
elog(ERROR, "array index expressions must be integers");
upperIndexpr = lappend(upperIndexpr, subexpr);
@@ -358,8 +358,10 @@ transformArraySubscripts(ParseState *pstate,
{
if (typesource != typeneeded)
{
/* XXX fixme: need to get the array's atttypmod? */
assignFrom = CoerceTargetExpr(pstate, assignFrom,
typesource, typeneeded);
typesource, typeneeded,
-1);
if (assignFrom == NULL)
elog(ERROR, "Array assignment requires type '%s'"
" but expression is of type '%s'"

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.52 2000/01/17 00:14:48 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.53 2000/01/17 02:04:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -229,8 +229,8 @@ updateTargetListEntry(ParseState *pstate,
{
if (type_id != attrtype)
{
tle->expr = CoerceTargetExpr(pstate, tle->expr,
type_id, attrtype);
tle->expr = CoerceTargetExpr(pstate, tle->expr, type_id,
attrtype, attrtypmod);
if (tle->expr == NULL)
elog(ERROR, "Attribute '%s' is of type '%s'"
" but expression is of type '%s'"
@@ -264,10 +264,11 @@ Node *
CoerceTargetExpr(ParseState *pstate,
Node *expr,
Oid type_id,
Oid attrtype)
Oid attrtype,
int32 attrtypmod)
{
if (can_coerce_type(1, &type_id, &attrtype))
expr = coerce_type(pstate, expr, type_id, attrtype, -1);
expr = coerce_type(pstate, expr, type_id, attrtype, attrtypmod);
#ifndef DISABLE_STRING_HACKS
@@ -283,7 +284,7 @@ CoerceTargetExpr(ParseState *pstate,
{
}
else if (can_coerce_type(1, &type_id, &text_id))
expr = coerce_type(pstate, expr, type_id, text_id, -1);
expr = coerce_type(pstate, expr, type_id, text_id, attrtypmod);
else
expr = NULL;
}