Re: BUG #17985: Inconsistent results of SELECT comparing two CASE WHEN clause

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: zuming.jiang@inf.ethz.ch
Cc: pgsql-bugs@lists.postgresql.org
Date: 2023-06-20T20:59:50Z
Lists: pgsql-bugs

Attachments

I wrote:
> One way to fix it is as attached.  I wonder though if this isn't
> telling us that there's a bug in the planner's assignment of
> allParams bits for Hash nodes.  The dangerous Param is present
> in the Hash node's hashkeys field, so why isn't the existing
> chgParam test adequate?

Yeah, so looking at that, the planner is just ignoring Hash.hashkeys,
apparently figuring that incorporating Param IDs from HashJoin.hashclauses
into the allParams for the parent HashJoin is sufficient.  But as we
see here, it isn't.  The attached seems like a better fix.

			regards, tom lane

Commits

  1. Fix hash join when inner hashkey expressions contain Params.

  2. Don't include outer join relids in lateral_relids bitmapsets.

  3. Small performance improvement for hash joins and hash aggregation: