Re: Case expression pushdown - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Case expression pushdown
Date
Msg-id 1005527.1627660129@sss.pgh.pa.us
Whole thread Raw
In response to Re: Case expression pushdown  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
I wrote:
> Alexander Pyhalov <a.pyhalov@postgrespro.ru> writes:
>> Do we we need to inspect only case_arg_cxt->state? Can we assert that 
>> collation == case_arg_cxt->collation?

> Perhaps, but:
> ...

Oh, actually there's a third point: the shakiest part of this logic
is the assumption that we've correctly matched a CaseTestExpr to
its source CaseExpr.  Seeing that inlining and constant-folding can
mash things to the point where a WHEN expression doesn't look like
"CaseTestExpr = RHS", it's a little nervous-making to assume there
couldn't be another CASE in between.  While there's not known problems
of this sort, if it did happen I'd prefer this code to react as
"don't push down", not as "assertion failure".

(There's been speculation in the past about whether we could find
a more bulletproof representation of this kind of CaseExpr.  We've
not succeeded at that yet though.)

            regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Segment fault when excuting SPI function On PG with commit 41c6a5be
Next
From: Tom Lane
Date:
Subject: Re: Unbounded %s in sscanf