Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 43dc4ad

Browse files
committed
Make some minor formatting improvements to what pgindent did.
Moving the code two full tab stops to the right requires rethinking of cosmetic code layout choices, which pgindent isn't really able to do for us. Whitespace and comment adjustments only, no code changes.
1 parent 871dd02 commit 43dc4ad

File tree

1 file changed

+61
-43
lines changed

1 file changed

+61
-43
lines changed

src/backend/optimizer/util/clauses.c

+61-43
Original file line numberDiff line numberDiff line change
@@ -2123,7 +2123,8 @@ eval_const_expressions_mutator(Node *node,
21232123
if (OidIsValid(prm->ptype))
21242124
{
21252125
/* OK to substitute parameter value? */
2126-
if (context->estimate || (prm->pflags & PARAM_FLAG_CONST))
2126+
if (context->estimate ||
2127+
(prm->pflags & PARAM_FLAG_CONST))
21272128
{
21282129
/*
21292130
* Return a Const representing the param value.
@@ -2136,7 +2137,8 @@ eval_const_expressions_mutator(Node *node,
21362137
Datum pval;
21372138

21382139
Assert(prm->ptype == param->paramtype);
2139-
get_typlenbyval(param->paramtype, &typLen, &typByVal);
2140+
get_typlenbyval(param->paramtype,
2141+
&typLen, &typByVal);
21402142
if (prm->isnull || typByVal)
21412143
pval = prm->value;
21422144
else
@@ -2192,11 +2194,14 @@ eval_const_expressions_mutator(Node *node,
21922194
*/
21932195
simple = simplify_function((Expr *) expr,
21942196
expr->funcid,
2195-
expr->funcresulttype, exprTypmod(node),
2197+
expr->funcresulttype,
2198+
exprTypmod(node),
21962199
expr->funccollid,
21972200
expr->inputcollid,
21982201
&args,
2199-
has_named_args, true, context);
2202+
has_named_args,
2203+
true,
2204+
context);
22002205
if (simple) /* successfully simplified it */
22012206
return (Node *) simple;
22022207

@@ -2262,7 +2267,8 @@ eval_const_expressions_mutator(Node *node,
22622267
if (expr->opno == BooleanEqualOperator ||
22632268
expr->opno == BooleanNotEqualOperator)
22642269
{
2265-
simple = (Expr *) simplify_boolean_equality(expr->opno, args);
2270+
simple = (Expr *) simplify_boolean_equality(expr->opno,
2271+
args);
22662272
if (simple) /* successfully simplified it */
22672273
return (Node *) simple;
22682274
}
@@ -2395,12 +2401,15 @@ eval_const_expressions_mutator(Node *node,
23952401
bool haveNull = false;
23962402
bool forceTrue = false;
23972403

2398-
newargs = simplify_or_arguments(expr->args, context,
2399-
&haveNull, &forceTrue);
2404+
newargs = simplify_or_arguments(expr->args,
2405+
context,
2406+
&haveNull,
2407+
&forceTrue);
24002408
if (forceTrue)
24012409
return makeBoolConst(true, false);
24022410
if (haveNull)
2403-
newargs = lappend(newargs, makeBoolConst(false, true));
2411+
newargs = lappend(newargs,
2412+
makeBoolConst(false, true));
24042413
/* If all the inputs are FALSE, result is FALSE */
24052414
if (newargs == NIL)
24062415
return makeBoolConst(false, false);
@@ -2420,12 +2429,15 @@ eval_const_expressions_mutator(Node *node,
24202429
bool haveNull = false;
24212430
bool forceFalse = false;
24222431

2423-
newargs = simplify_and_arguments(expr->args, context,
2424-
&haveNull, &forceFalse);
2432+
newargs = simplify_and_arguments(expr->args,
2433+
context,
2434+
&haveNull,
2435+
&forceFalse);
24252436
if (forceFalse)
24262437
return makeBoolConst(false, false);
24272438
if (haveNull)
2428-
newargs = lappend(newargs, makeBoolConst(false, true));
2439+
newargs = lappend(newargs,
2440+
makeBoolConst(false, true));
24292441
/* If all the inputs are TRUE, result is TRUE */
24302442
if (newargs == NIL)
24312443
return makeBoolConst(true, false);
@@ -2541,8 +2553,10 @@ eval_const_expressions_mutator(Node *node,
25412553
* Note that the coercion functions are assumed not to care
25422554
* about input collation, so we just pass InvalidOid for that.
25432555
*/
2544-
getTypeOutputInfo(exprType((Node *) arg), &outfunc, &outtypisvarlena);
2545-
getTypeInputInfo(expr->resulttype, &infunc, &intypioparam);
2556+
getTypeOutputInfo(exprType((Node *) arg),
2557+
&outfunc, &outtypisvarlena);
2558+
getTypeInputInfo(expr->resulttype,
2559+
&infunc, &intypioparam);
25462560

25472561
simple = simplify_function(NULL,
25482562
outfunc,
@@ -2559,12 +2573,20 @@ eval_const_expressions_mutator(Node *node,
25592573
* complain.
25602574
*/
25612575
args = list_make3(simple,
2562-
makeConst(OIDOID, -1, InvalidOid, sizeof(Oid),
2563-
ObjectIdGetDatum(intypioparam),
2564-
false, true),
2565-
makeConst(INT4OID, -1, InvalidOid, sizeof(int32),
2566-
Int32GetDatum(-1),
2567-
false, true));
2576+
makeConst(OIDOID,
2577+
-1,
2578+
InvalidOid,
2579+
sizeof(Oid),
2580+
ObjectIdGetDatum(intypioparam),
2581+
false,
2582+
true),
2583+
makeConst(INT4OID,
2584+
-1,
2585+
InvalidOid,
2586+
sizeof(int32),
2587+
Int32GetDatum(-1),
2588+
false,
2589+
true));
25682590

25692591
simple = simplify_function(NULL,
25702592
infunc,
@@ -2681,19 +2703,20 @@ eval_const_expressions_mutator(Node *node,
26812703
* condition clauses:
26822704
* FALSE (or NULL): drop the alternative
26832705
* TRUE: drop all remaining alternatives
2684-
* If the first non-FALSE alternative is a constant TRUE, we can
2685-
* simplify the entire CASE to that alternative's expression.
2686-
* If there are no non-FALSE alternatives, we simplify the entire
2687-
* CASE to the default result (ELSE result).
2706+
* If the first non-FALSE alternative is a constant TRUE,
2707+
* we can simplify the entire CASE to that alternative's
2708+
* expression. If there are no non-FALSE alternatives,
2709+
* we simplify the entire CASE to the default result (ELSE).
26882710
*
2689-
* If we have a simple-form CASE with constant test expression,
2690-
* we substitute the constant value for contained CaseTestExpr
2691-
* placeholder nodes, so that we have the opportunity to reduce
2692-
* constant test conditions. For example this allows
2711+
* If we have a simple-form CASE with constant test
2712+
* expression, we substitute the constant value for contained
2713+
* CaseTestExpr placeholder nodes, so that we have the
2714+
* opportunity to reduce constant test conditions. For
2715+
* example this allows
26932716
* CASE 0 WHEN 0 THEN 1 ELSE 1/0 END
2694-
* to reduce to 1 rather than drawing a divide-by-0 error. Note
2695-
* that when the test expression is constant, we don't have to
2696-
* include it in the resulting CASE; for example
2717+
* to reduce to 1 rather than drawing a divide-by-0 error.
2718+
* Note that when the test expression is constant, we don't
2719+
* have to include it in the resulting CASE; for example
26972720
* CASE 0 WHEN x THEN y ELSE z END
26982721
* is transformed by the parser to
26992722
* CASE 0 WHEN CaseTestExpr = x THEN y ELSE z END
@@ -2723,8 +2746,7 @@ eval_const_expressions_mutator(Node *node,
27232746
if (newarg && IsA(newarg, Const))
27242747
{
27252748
context->case_val = newarg;
2726-
newarg = NULL; /* not needed anymore, see comment
2727-
* above */
2749+
newarg = NULL; /* not needed anymore, see above */
27282750
}
27292751
else
27302752
context->case_val = NULL;
@@ -2741,9 +2763,8 @@ eval_const_expressions_mutator(Node *node,
27412763
Assert(IsA(oldcasewhen, CaseWhen));
27422764

27432765
/* Simplify this alternative's test condition */
2744-
casecond =
2745-
eval_const_expressions_mutator((Node *) oldcasewhen->expr,
2746-
context);
2766+
casecond = eval_const_expressions_mutator((Node *) oldcasewhen->expr,
2767+
context);
27472768

27482769
/*
27492770
* If the test condition is constant FALSE (or NULL), then
@@ -2756,16 +2777,14 @@ eval_const_expressions_mutator(Node *node,
27562777

27572778
if (const_input->constisnull ||
27582779
!DatumGetBool(const_input->constvalue))
2759-
continue; /* drop alternative with FALSE
2760-
* condition */
2780+
continue; /* drop alternative with FALSE cond */
27612781
/* Else it's constant TRUE */
27622782
const_true_cond = true;
27632783
}
27642784

27652785
/* Simplify this alternative's result value */
2766-
caseresult =
2767-
eval_const_expressions_mutator((Node *) oldcasewhen->result,
2768-
context);
2786+
caseresult = eval_const_expressions_mutator((Node *) oldcasewhen->result,
2787+
context);
27692788

27702789
/* If non-constant test condition, emit a new WHEN node */
27712790
if (!const_true_cond)
@@ -2790,9 +2809,8 @@ eval_const_expressions_mutator(Node *node,
27902809

27912810
/* Simplify the default result, unless we replaced it above */
27922811
if (!const_true_cond)
2793-
defresult =
2794-
eval_const_expressions_mutator((Node *) caseexpr->defresult,
2795-
context);
2812+
defresult = eval_const_expressions_mutator((Node *) caseexpr->defresult,
2813+
context);
27962814

27972815
context->case_val = save_case_val;
27982816

0 commit comments

Comments
 (0)