@@ -2123,7 +2123,8 @@ eval_const_expressions_mutator(Node *node,
21232123if (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,
21362137Datum pval ;
21372138
21382139Assert (prm -> ptype == param -> paramtype );
2139- get_typlenbyval (param -> paramtype ,& typLen ,& typByVal );
2140+ get_typlenbyval (param -> paramtype ,
2141+ & typLen ,& typByVal );
21402142if (prm -> isnull || typByVal )
21412143pval = prm -> value ;
21422144else
@@ -2192,11 +2194,14 @@ eval_const_expressions_mutator(Node *node,
21922194 */
21932195simple = simplify_function ((Expr * )expr ,
21942196expr -> funcid ,
2195- expr -> funcresulttype ,exprTypmod (node ),
2197+ expr -> funcresulttype ,
2198+ exprTypmod (node ),
21962199expr -> funccollid ,
21972200expr -> inputcollid ,
21982201& args ,
2199- has_named_args , true,context );
2202+ has_named_args ,
2203+ true,
2204+ context );
22002205if (simple )/* successfully simplified it */
22012206return (Node * )simple ;
22022207
@@ -2262,7 +2267,8 @@ eval_const_expressions_mutator(Node *node,
22622267if (expr -> opno == BooleanEqualOperator ||
22632268expr -> opno == BooleanNotEqualOperator )
22642269{
2265- simple = (Expr * )simplify_boolean_equality (expr -> opno ,args );
2270+ simple = (Expr * )simplify_boolean_equality (expr -> opno ,
2271+ args );
22662272if (simple )/* successfully simplified it */
22672273return (Node * )simple ;
22682274}
@@ -2395,12 +2401,15 @@ eval_const_expressions_mutator(Node *node,
23952401bool haveNull = false;
23962402bool 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 );
24002408if (forceTrue )
24012409return makeBoolConst (true, false);
24022410if (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 */
24052414if (newargs == NIL )
24062415return makeBoolConst (false, false);
@@ -2420,12 +2429,15 @@ eval_const_expressions_mutator(Node *node,
24202429bool haveNull = false;
24212430bool 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 );
24252436if (forceFalse )
24262437return makeBoolConst (false, false);
24272438if (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 */
24302442if (newargs == NIL )
24312443return 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
25472561simple = simplify_function (NULL ,
25482562outfunc ,
@@ -2559,12 +2573,20 @@ eval_const_expressions_mutator(Node *node,
25592573 * complain.
25602574 */
25612575args = 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
25692591simple = simplify_function (NULL ,
25702592infunc ,
@@ -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,
27232746if (newarg && IsA (newarg ,Const ))
27242747{
27252748context -> case_val = newarg ;
2726- newarg = NULL ;/* not needed anymore, see comment
2727- * above */
2749+ newarg = NULL ;/* not needed anymore, see above */
27282750}
27292751else
27302752context -> case_val = NULL ;
@@ -2741,9 +2763,8 @@ eval_const_expressions_mutator(Node *node,
27412763Assert (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
27572778if (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 */
27622782const_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 */
27712790if (!const_true_cond )
@@ -2790,9 +2809,8 @@ eval_const_expressions_mutator(Node *node,
27902809
27912810/* Simplify the default result, unless we replaced it above */
27922811if (!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
27972815context -> case_val = save_case_val ;
27982816