Skip to content

Commit a29f7ed

Browse files
committed
Get rid of COERCE_DONTCARE.
We don't need this hack any more.
1 parent 427fd88 commit a29f7ed

File tree

7 files changed

+16
-18
lines changed

7 files changed

+16
-18
lines changed

src/backend/executor/functions.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList,
15721572
rettype,
15731573
-1,
15741574
get_typcollation(rettype),
1575-
COERCE_DONTCARE);
1575+
COERCE_IMPLICIT_CAST);
15761576
/* Relabel is dangerous if TLE is a sort/group or setop column */
15771577
if (tle->ressortgroupref != 0 || parse->setOperations)
15781578
*modifyTargetList = true;
@@ -1618,7 +1618,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList,
16181618
rettype,
16191619
-1,
16201620
get_typcollation(rettype),
1621-
COERCE_DONTCARE);
1621+
COERCE_IMPLICIT_CAST);
16221622
/* Relabel is dangerous if sort/group or setop column */
16231623
if (tle->ressortgroupref != 0 || parse->setOperations)
16241624
*modifyTargetList = true;
@@ -1722,7 +1722,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList,
17221722
atttype,
17231723
-1,
17241724
get_typcollation(atttype),
1725-
COERCE_DONTCARE);
1725+
COERCE_IMPLICIT_CAST);
17261726
/* Relabel is dangerous if sort/group or setop column */
17271727
if (tle->ressortgroupref != 0 || parse->setOperations)
17281728
*modifyTargetList = true;

src/backend/nodes/nodeFuncs.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,7 @@ exprIsLengthCoercion(const Node *expr, int32 *coercedTypmod)
554554
*
555555
* This is primarily intended to be used during planning. Therefore, it
556556
* strips any existing RelabelType nodes to maintain the planner's invariant
557-
* that there are not adjacent RelabelTypes, and it uses COERCE_DONTCARE
558-
* which would typically be inappropriate earlier.
557+
* that there are not adjacent RelabelTypes.
559558
*/
560559
Node *
561560
relabel_to_typmod(Node *expr, int32 typmod)
@@ -569,7 +568,7 @@ relabel_to_typmod(Node *expr, int32 typmod)
569568

570569
/* Apply new typmod, preserving the previous exposed type and collation */
571570
return (Node *) makeRelabelType((Expr *) expr, type, typmod, coll,
572-
COERCE_DONTCARE);
571+
COERCE_EXPLICIT_CAST);
573572
}
574573

575574
/*

src/backend/optimizer/path/equivclass.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -431,13 +431,13 @@ canonicalize_ec_expression(Expr *expr, Oid req_type, Oid req_collation)
431431
req_type,
432432
-1,
433433
req_collation,
434-
COERCE_DONTCARE);
434+
COERCE_IMPLICIT_CAST);
435435
else if (exprCollation((Node *) expr) != req_collation)
436436
expr = (Expr *) makeRelabelType(expr,
437437
req_type,
438438
exprTypmod((Node *) expr),
439439
req_collation,
440-
COERCE_DONTCARE);
440+
COERCE_IMPLICIT_CAST);
441441
}
442442

443443
return expr;

src/backend/optimizer/prep/prepunion.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ generate_setop_tlist(List *colTypes, List *colCollations,
982982
exprType(expr),
983983
exprTypmod(expr),
984984
colColl,
985-
COERCE_DONTCARE);
985+
COERCE_IMPLICIT_CAST);
986986
}
987987

988988
tle = makeTargetEntry((Expr *) expr,

src/backend/optimizer/util/clauses.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -2789,7 +2789,7 @@ eval_const_expressions_mutator(Node *node,
27892789
relabel->resulttype = exprType(arg);
27902790
relabel->resulttypmod = exprTypmod(arg);
27912791
relabel->resultcollid = collate->collOid;
2792-
relabel->relabelformat = COERCE_DONTCARE;
2792+
relabel->relabelformat = COERCE_IMPLICIT_CAST;
27932793
relabel->location = collate->location;
27942794

27952795
/* Don't create stacked RelabelTypes */
@@ -3625,7 +3625,7 @@ simplify_function(Oid funcid, Oid result_type, int32 result_typmod,
36253625
fexpr.funcid = funcid;
36263626
fexpr.funcresulttype = result_type;
36273627
fexpr.funcretset = func_form->proretset;
3628-
fexpr.funcformat = COERCE_DONTCARE;
3628+
fexpr.funcformat = COERCE_EXPLICIT_CALL;
36293629
fexpr.funccollid = result_collid;
36303630
fexpr.inputcollid = input_collid;
36313631
fexpr.args = args;
@@ -3959,7 +3959,7 @@ evaluate_function(Oid funcid, Oid result_type, int32 result_typmod,
39593959
newexpr->funcid = funcid;
39603960
newexpr->funcresulttype = result_type;
39613961
newexpr->funcretset = false;
3962-
newexpr->funcformat = COERCE_DONTCARE; /* doesn't matter */
3962+
newexpr->funcformat = COERCE_EXPLICIT_CALL; /* doesn't matter */
39633963
newexpr->funccollid = result_collid; /* doesn't matter */
39643964
newexpr->inputcollid = input_collid;
39653965
newexpr->args = args;
@@ -4089,7 +4089,7 @@ inline_function(Oid funcid, Oid result_type, Oid result_collid,
40894089
fexpr->funcid = funcid;
40904090
fexpr->funcresulttype = result_type;
40914091
fexpr->funcretset = false;
4092-
fexpr->funcformat = COERCE_DONTCARE; /* doesn't matter */
4092+
fexpr->funcformat = COERCE_EXPLICIT_CALL; /* doesn't matter */
40934093
fexpr->funccollid = result_collid; /* doesn't matter */
40944094
fexpr->inputcollid = input_collid;
40954095
fexpr->args = args;

src/backend/parser/parse_agg.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ build_aggregate_fnexprs(Oid *agg_input_types,
10011001
args,
10021002
InvalidOid,
10031003
agg_input_collation,
1004-
COERCE_DONTCARE);
1004+
COERCE_EXPLICIT_CALL);
10051005

10061006
/* see if we have a final function */
10071007
if (!OidIsValid(finalfn_oid))
@@ -1027,5 +1027,5 @@ build_aggregate_fnexprs(Oid *agg_input_types,
10271027
args,
10281028
InvalidOid,
10291029
agg_input_collation,
1030-
COERCE_DONTCARE);
1030+
COERCE_EXPLICIT_CALL);
10311031
}

src/include/nodes/primnodes.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ typedef enum CoercionContext
316316
} CoercionContext;
317317

318318
/*
319-
* CoercionForm - information showing how to display a function-call node
319+
* CoercionForm - how to display a node that could have come from a cast
320320
*
321321
* NB: equal() ignores CoercionForm fields, therefore this *must* not carry
322322
* any semantically significant information. We need that behavior so that
@@ -328,8 +328,7 @@ typedef enum CoercionForm
328328
{
329329
COERCE_EXPLICIT_CALL, /* display as a function call */
330330
COERCE_EXPLICIT_CAST, /* display as an explicit cast */
331-
COERCE_IMPLICIT_CAST, /* implicit cast, so hide it */
332-
COERCE_DONTCARE /* special case for planner */
331+
COERCE_IMPLICIT_CAST /* implicit cast, so hide it */
333332
} CoercionForm;
334333

335334
/*

0 commit comments

Comments
 (0)