Re: BUG #15471: psql 11 array concatenation in CASE takes on values from the CASE expression when using enum_range - Mailing list pgsql-bugs

From Andrew Gierth
Subject Re: BUG #15471: psql 11 array concatenation in CASE takes on values from the CASE expression when using enum_range
Date
Msg-id 87efc77gh2.fsf@news-spur.riddles.org.uk
Whole thread Raw
In response to Re: BUG #15471: psql 11 array concatenation in CASE takes on values from the CASE expression when using enum_range  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #15471: psql 11 array concatenation in CASE takes on values from the CASE expression when using enum_range  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
>>>>> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> writes:

 >> Below is an example .sql file that replicates the problem. Put
 >> simply, when we array concat with enum_range in the result of a CASE
 >> statement the concatenation takes the expression from the CASE
 >> statement, not the enum range.

 Tom> Wow, that's ... bizarre. I'm thinking that we probably did
 Tom> something silly in the big expression-execution rewrite, but it's
 Tom> not clear exactly where. Anyway, will look into it if Andres
 Tom> doesn't beat me to it.

I took a look, and what I'm seeing suggests that commit 3decd150a2d
might possibly be relevant here (at least to explain why it breaks in 11
but not 10).

What's going on in eval_const_expressions_mutator is that
context->case_val is set when recursing into the elemexpr in the
ArrayCoerceExpr case, so when that sees a CaseTestExpr inside that, it
replaces it (incorrectly).

-- 
Andrew (irc:RhodiumToad)


pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #15471: psql 11 array concatenation in CASE takes on values from the CASE expression when using enum_range
Next
From: Andrew Gierth
Date:
Subject: Re: BUG #15467: The database subdirectory "pg_tblspc/1932420460/PG_10_201707211/16400" is missing.