Re: BUG #15471: psql 11 array concatenation in CASE takes on values from the CASE expression when using enum_range
Andrew Gierth <andrew@tao11.riddles.org.uk>
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pg@mattyw.net, pgsql-bugs@lists.postgresql.org,
Andres Freund <andres@anarazel.de>
Date: 2018-10-30T12:49:25Z
Lists: 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)
Commits
-
Fix interaction of CASE and ArrayCoerceExpr.
- 2bd6dcdeff09 11.1 landed
- 14a158f9bff1 12.0 landed
-
Teach eval_const_expressions() to handle some more cases.
- 3decd150a2d5 11.0 cited
-
Support arrays over domains.
- c12d570fa147 11.0 cited