@@ -2123,7 +2123,8 @@ eval_const_expressions_mutator(Node *node,
2123
2123
if (OidIsValid (prm -> ptype ))
2124
2124
{
2125
2125
/* OK to substitute parameter value? */
2126
- if (context -> estimate || (prm -> pflags & PARAM_FLAG_CONST ))
2126
+ if (context -> estimate ||
2127
+ (prm -> pflags & PARAM_FLAG_CONST ))
2127
2128
{
2128
2129
/*
2129
2130
* Return a Const representing the param value.
@@ -2136,7 +2137,8 @@ eval_const_expressions_mutator(Node *node,
2136
2137
Datum pval ;
2137
2138
2138
2139
Assert (prm -> ptype == param -> paramtype );
2139
- get_typlenbyval (param -> paramtype , & typLen , & typByVal );
2140
+ get_typlenbyval (param -> paramtype ,
2141
+ & typLen , & typByVal );
2140
2142
if (prm -> isnull || typByVal )
2141
2143
pval = prm -> value ;
2142
2144
else
@@ -2192,11 +2194,14 @@ eval_const_expressions_mutator(Node *node,
2192
2194
*/
2193
2195
simple = simplify_function ((Expr * ) expr ,
2194
2196
expr -> funcid ,
2195
- expr -> funcresulttype , exprTypmod (node ),
2197
+ expr -> funcresulttype ,
2198
+ exprTypmod (node ),
2196
2199
expr -> funccollid ,
2197
2200
expr -> inputcollid ,
2198
2201
& args ,
2199
- has_named_args , true, context );
2202
+ has_named_args ,
2203
+ true,
2204
+ context );
2200
2205
if (simple ) /* successfully simplified it */
2201
2206
return (Node * ) simple ;
2202
2207
@@ -2262,7 +2267,8 @@ eval_const_expressions_mutator(Node *node,
2262
2267
if (expr -> opno == BooleanEqualOperator ||
2263
2268
expr -> opno == BooleanNotEqualOperator )
2264
2269
{
2265
- simple = (Expr * ) simplify_boolean_equality (expr -> opno , args );
2270
+ simple = (Expr * ) simplify_boolean_equality (expr -> opno ,
2271
+ args );
2266
2272
if (simple ) /* successfully simplified it */
2267
2273
return (Node * ) simple ;
2268
2274
}
@@ -2395,12 +2401,15 @@ eval_const_expressions_mutator(Node *node,
2395
2401
bool haveNull = false;
2396
2402
bool forceTrue = false;
2397
2403
2398
- newargs = simplify_or_arguments (expr -> args , context ,
2399
- & haveNull , & forceTrue );
2404
+ newargs = simplify_or_arguments (expr -> args ,
2405
+ context ,
2406
+ & haveNull ,
2407
+ & forceTrue );
2400
2408
if (forceTrue )
2401
2409
return makeBoolConst (true, false);
2402
2410
if (haveNull )
2403
- newargs = lappend (newargs , makeBoolConst (false, true));
2411
+ newargs = lappend (newargs ,
2412
+ makeBoolConst (false, true));
2404
2413
/* If all the inputs are FALSE, result is FALSE */
2405
2414
if (newargs == NIL )
2406
2415
return makeBoolConst (false, false);
@@ -2420,12 +2429,15 @@ eval_const_expressions_mutator(Node *node,
2420
2429
bool haveNull = false;
2421
2430
bool forceFalse = false;
2422
2431
2423
- newargs = simplify_and_arguments (expr -> args , context ,
2424
- & haveNull , & forceFalse );
2432
+ newargs = simplify_and_arguments (expr -> args ,
2433
+ context ,
2434
+ & haveNull ,
2435
+ & forceFalse );
2425
2436
if (forceFalse )
2426
2437
return makeBoolConst (false, false);
2427
2438
if (haveNull )
2428
- newargs = lappend (newargs , makeBoolConst (false, true));
2439
+ newargs = lappend (newargs ,
2440
+ makeBoolConst (false, true));
2429
2441
/* If all the inputs are TRUE, result is TRUE */
2430
2442
if (newargs == NIL )
2431
2443
return makeBoolConst (true, false);
@@ -2541,8 +2553,10 @@ eval_const_expressions_mutator(Node *node,
2541
2553
* Note that the coercion functions are assumed not to care
2542
2554
* about input collation, so we just pass InvalidOid for that.
2543
2555
*/
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 );
2546
2560
2547
2561
simple = simplify_function (NULL ,
2548
2562
outfunc ,
@@ -2559,12 +2573,20 @@ eval_const_expressions_mutator(Node *node,
2559
2573
* complain.
2560
2574
*/
2561
2575
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));
2568
2590
2569
2591
simple = simplify_function (NULL ,
2570
2592
infunc ,
@@ -2681,19 +2703,20 @@ eval_const_expressions_mutator(Node *node,
2681
2703
* condition clauses:
2682
2704
* FALSE (or NULL): drop the alternative
2683
2705
* 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).
2688
2710
*
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
2693
2716
* 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
2697
2720
* CASE 0 WHEN x THEN y ELSE z END
2698
2721
* is transformed by the parser to
2699
2722
* CASE 0 WHEN CaseTestExpr = x THEN y ELSE z END
@@ -2723,8 +2746,7 @@ eval_const_expressions_mutator(Node *node,
2723
2746
if (newarg && IsA (newarg , Const ))
2724
2747
{
2725
2748
context -> case_val = newarg ;
2726
- newarg = NULL ; /* not needed anymore, see comment
2727
- * above */
2749
+ newarg = NULL ; /* not needed anymore, see above */
2728
2750
}
2729
2751
else
2730
2752
context -> case_val = NULL ;
@@ -2741,9 +2763,8 @@ eval_const_expressions_mutator(Node *node,
2741
2763
Assert (IsA (oldcasewhen , CaseWhen ));
2742
2764
2743
2765
/* 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 );
2747
2768
2748
2769
/*
2749
2770
* If the test condition is constant FALSE (or NULL), then
@@ -2756,16 +2777,14 @@ eval_const_expressions_mutator(Node *node,
2756
2777
2757
2778
if (const_input -> constisnull ||
2758
2779
!DatumGetBool (const_input -> constvalue ))
2759
- continue ; /* drop alternative with FALSE
2760
- * condition */
2780
+ continue ; /* drop alternative with FALSE cond */
2761
2781
/* Else it's constant TRUE */
2762
2782
const_true_cond = true;
2763
2783
}
2764
2784
2765
2785
/* 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 );
2769
2788
2770
2789
/* If non-constant test condition, emit a new WHEN node */
2771
2790
if (!const_true_cond )
@@ -2790,9 +2809,8 @@ eval_const_expressions_mutator(Node *node,
2790
2809
2791
2810
/* Simplify the default result, unless we replaced it above */
2792
2811
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 );
2796
2814
2797
2815
context -> case_val = save_case_val ;
2798
2816
0 commit comments