Re: Pg18 Recursive Crash

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Nathan Bossart <nathandbossart(at)gmail(dot)com>, Paul Ramsey <pramsey(at)cleverelephant(dot)ca>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Pg18 Recursive Crash
Date: 2024-12-18 10:45:40
Message-ID: CAApHDvpki1oHgMKw+beUhkPMAafznUQAyVAyqyz7918RMeAt2A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 18 Dec 2024 at 22:29, Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
> Should we be concerned about passing a NULL TupleTableSlotOps in
> nodeRecursiveUnion.c?

I made it pass NULL on purpose because the slot type on the recursive
union can be different on the inner and outer sides. Do you see issues
with that?

> The query below triggers the same assert
> failure: the slot is expected to be TTSOpsMinimalTuple, but it is
> TTSOpsBufferHeapTuple.
>
> create table t (a int);
> insert into t values (1), (1);
>
> with recursive cte (a) as (select a from t union select a from cte)
> select a from cte;

That's a good find. I tested as far back as REL_13_STABLE and it's
failing the same Assert there too.

Maybe we need to backpatch passing NULL instead of &TTSOpsMinimalTuple
to ExecBuildGroupingEqual() in BuildTupleHashTableExt(). Something
like the attached patch.

As far as I see it, there's no downside to this as
ExecComputeSlotInfo() will return true anyway for the
EEOP_INNER_FETCHSOME step in ExecBuildGroupingEqual() due to minimal
tuples needing deformation anyway. For master, we could just do what
Tom proposed above so that any callers that always use virtual slots
can benefit from the elimination of the EEOP_INNER_FETCHSOME step.

David

Attachment Content-Type Size
fix_incorrect_slot_type.patch application/octet-stream 699 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2024-12-18 10:49:40 Re: Question about behavior of deletes with REPLICA IDENTITY NOTHING
Previous Message John Naylor 2024-12-18 10:42:07 Re: Shave a few cycles off our ilog10 implementation