Re: jsonb crash - Mailing list pgsql-hackers

From David Rowley
Subject Re: jsonb crash
Date
Msg-id CAHoyFK_g-Q7mC4BwzZJ+ZWjcV+35SN8_8iKLUgth7+aq9QcYTw@mail.gmail.com
Whole thread Raw
In response to Re: jsonb crash  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: jsonb crash  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Thu, 30 Sept 2021 at 10:20, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> David Rowley <dgrowleyml@gmail.com> writes:
> > On Thu, 30 Sept 2021 at 10:09, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >> Um ... it seems to have correctly identified the cache key expressions,
> >> so why isn't it just doing exprType on those?  The jsonb_exists operator
> >> seems entirely irrelevant here.
>
> > This is down to the caching stuff I added to RestrictInfo to minimise
> > the amount of work done during the join search. I cached the hash
> > equal function in RestrictInfo so I didn't have to check what that was
> > each time we consider a join.  The problem is, that I did a bad job of
> > taking inspiration from check_hashjoinable() which just looks at the
> > left type.
>
> I'm still confused.  AFAICS, the top-level operator of the qual clause has
> exactly nada to do with the cache keys, as this example makes plain.

You're right that it does not. The lateral join condition could be
anything.  We just need to figure out the hash function and which
equality function so that we can properly find any cached tuples when
we're probing the hash table.  We need the equal function too as we
can't just return any old cache tuples that match the same hash value.

Maybe recording the operator is not the best thing to do. Maybe I
should have just recorded the regproc's Oid for the equal function.
That would save from calling get_opcode() in ExecInitMemoize().

David



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: prevent immature WAL streaming
Next
From: Alvaro Herrera
Date:
Subject: Re: prevent immature WAL streaming