Re: BUG #18252: Assert in CheckOpSlotCompatibility() fails when recursive union filters tuples in non-recursive term

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: exclusion(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: BUG #18252: Assert in CheckOpSlotCompatibility() fails when recursive union filters tuples in non-recursive term
Date: 2024-01-10 07:46:12
Message-ID: CAMbWs49MVPE7-T06gRvFO3KsNrjQt5OywsRyVAO3wawexvWJ2Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Dec 19, 2023 at 7:28 PM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:

> On Tue, Dec 19, 2023 at 12:30 AM PG Bug reporting form <
> noreply(at)postgresql(dot)org> wrote:
>
>> CREATE TABLE t(i int);
>> INSERT INTO t VALUES (1), (1);
>>
>> WITH RECURSIVE rt(i) AS (
>> SELECT * FROM t
>> UNION
>> SELECT * FROM rt
>> )
>> SELECT * FROM rt;
>
>
> Nice catch. The TupleHashTable's tableslot is created as type
> TTSOpsMinimalTuple. The RecursiveUnion's non-recursive term generates
> tuples of type TTSOpsBufferHeapTuple. If the non-recursive term
> produces duplicate tuples, we'd find non-empty bucket when inserting the
> same key into the hashtable. In this case we need to check to see if
> the two tuples match: one is of the hashtable's tableslot
> (TTSOpsMinimalTuple), and the other comes from the non-recursive term
> (TTSOpsBufferHeapTuple). And the incompatible slot type would fail
> CheckOpSlotCompatibility.
>

This Assert was added in 15d8f8312:

commit 15d8f83128e15de97de61430d0b9569f5ebecc26
Author: Andres Freund <andres(at)anarazel(dot)de>
Date: Thu Nov 15 22:00:30 2018 -0800

Verify that expected slot types match returned slot types.

So loop in Andres to have a look.

Thanks
Richard

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2024-01-10 09:12:20 BUG #18279: Duplicate key violation and Deadlock when using ON CONFLICT/DO UPDATE with multiple unique indexes
Previous Message Richard Guo 2024-01-10 07:44:13 Re: BUG #18252: Assert in CheckOpSlotCompatibility() fails when recursive union filters tuples in non-recursive term