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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
Cc: pg(at)mattyw(dot)net, pgsql-bugs(at)lists(dot)postgresql(dot)org, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: BUG #15471: psql 11 array concatenation in CASE takes on values from the CASE expression when using enum_range
Date: 2018-10-30 13:30:54
Message-ID: 15342.1540906254@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> writes:
> "Tom" == Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
> 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).

Good guess but I don't think that changed anything. It looks to me
like the culprit is commit c12d570fa, so it's my bug not Andres' :-(.
Before that, we weren't abusing CaseTestExpr as part of ArrayCoerceExpr.

Probably, the fix is to have eval_const_expressions be sure to
save/clear/restore context->case_val when dealing with ArrayCoerceExpr's
elemexpr. That possibly does mean that we have to undo the generic
processing of ArrayCoerceExpr, but it was already broken before that
transformation.

This is all some more fuel for the idea that we need a less messy
substitute for CaseTestExpr. As it happens, I was just fooling with
that yesterday, and hope to have something to post soon. But it'll
be too invasive to back-patch. I'll try to fix this particular
problem more locally.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Devrim Gündüz 2018-10-30 13:35:57 Re: BUG #15469: bucardo-5.4.1-1.rhel7.1.noarch.rpm bug
Previous Message tsuraan 2018-10-30 13:26:10 Re: BUG #15467: The database subdirectory "pg_tblspc/1932420460/PG_10_201707211/16400" is missing.