Re: BUG #19049: Assert failure when using skip arrays on an index key with DESC order

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: natalya(at)timescale(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19049: Assert failure when using skip arrays on an index key with DESC order
Date: 2025-09-12 01:07:02
Message-ID: CAH2-Wzm6f0fYv5x6Xkg1ggKrKf34ifJTt1mCZFDcVJSrChoGhA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Sep 11, 2025 at 12:48 PM Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
> I'm going to revisit my test coverage for DESC columns in light of
> this issue. I didn't add support for DESC columns in my fuzz testing
> scripts, which now seems like an oversight -- I'd definitely have
> caught this problem myself, had I done that from the start.

Just for the record, I tried this out. Here's what happened:

I found that when I introduced alternating ASC/DESC column orders to
my existing fuzz testing script, it found the same bug in literally a
fraction of a second. I didn't see the same assertion failure that
Natalya's test case ran into, though; the script just detected
discrepancies between results from an index scan, and an equivalent
sequential scan (both for the same randomly generated query).

I also found that with my patch was applied, the same fuzz testing
script correctly executed several million randomly generated test
queries without incident. This includes randomly generated
combinations of equality/inequality operators, IS NULL/IS NOT NULL
conditions, IN() constructs, and skip arrays. All against either one
of a pair of indexes, each with 4 index columns (now with alternating
ASC and DESC column orders) -- there are two indexes to cover
different permutations of NULLS FIRST and NULLS LAST. The fuzz testing
script generates both backwards and forwards scans, for both of these
multicolumn indexes.

Obviously, this doesn't prove the absence of more DESC column related
bugs in the skip scan patchset. But it does make me confident that any
remaining DESC column related bugs are bound to be far more
subtle/hard to hit than this one was.

--
Peter Geoghegan

In response to

Browse pgsql-bugs by date

  From Date Subject
Previous Message Tender Wang 2025-09-12 00:57:27 Re: BUG #19046: Incorrect result when using json_array() with column reference in subquery combined with RIGHT JOIN