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

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

From: Tom Lane <tgl@sss.pgh.pa.us>
To: natalya@timescale.com
Cc: pgsql-bugs@lists.postgresql.org, Peter Geoghegan <pg@bowt.ie>
Date: 2025-09-11T15:49:45Z
Lists: pgsql-bugs

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Always commute strategy when preprocessing DESC keys.

  2. Avoid extra index searches through preprocessing.

PG Bug reporting form <noreply@postgresql.org> writes:
> -- This query crashes with an Assert
>  select distinct on(s0, s1) * from mv where t2 >= -1 and t1 < 10 order by
> s0, s1, t1 desc, t2 desc;

> Assert is:
>                 if (ScanDirectionIsForward(dir) && array->low_compare)
> Assert(DatumGetBool(FunctionCall2Coll(&array->low_compare->sk_func,
> array->low_compare->sk_collation, tupdatum, array->low_compare->sk_argument)));

Indeed.  "git bisect" says this started at

b3f1a13f22f9e28842ee5fbd08b7ec805e27aaac is the first bad commit
commit b3f1a13f22f9e28842ee5fbd08b7ec805e27aaac
Author: Peter Geoghegan <pg@bowt.ie>
Date:   Fri Apr 4 14:14:08 2025 -0400

    Avoid extra index searches through preprocessing.

Peter, you want to take a look?

			regards, tom lane