Re: pgsql: Remove unreachable code in expressionevaluation. - Mailing list pgsql-committers

From Andres Freund
Subject Re: pgsql: Remove unreachable code in expressionevaluation.
Date
Msg-id 20170326042527.mdxsoht5a4actlzz@alap3.anarazel.de
Whole thread Raw
In response to Re: pgsql: Remove unreachable code in expression evaluation.  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-committers
On 2017-03-26 00:14:30 -0400, Tom Lane wrote:
> Andres Freund <andres@anarazel.de> writes:
> > Remove unreachable code in expression evaluation.
> > The previous code still contained expression evaluation time support
> > for CaseExprs without a defresult.  But transformCaseExpr() creates a
> > default expression if necessary.
>
> BTW, now that I think about it, I wonder if a better answer wouldn't
> be to leave the execExpr code as it stood, and remove the code in
> transformCaseExpr that pre-creates a default expression.  You'd end
> up with identical code at runtime, and eliminate some parse/rewrite/plan
> overhead for dealing with that subexpression.
>
> It's possible there's some code somewhere else that expects defresult
> to always be non-null, but I can't think what, or why that would be
> a good thing to assume.

There's some relationship with the type inferrence code in
transformCaseExpr().  I don't think it'd be hard to change, however -
just move resultexprs = lcons(newc->defresult, resultexprs); into the
else branch of if defresult == NULL.

- Andres


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pgsql: Remove unreachable code in expression evaluation.
Next
From: Alvaro Herrera
Date:
Subject: pgsql: Add missing break