BUG #19049: Assert failure when using skip arrays on an index key with DESC order - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #19049: Assert failure when using skip arrays on an index key with DESC order
Date
Msg-id 19049-b7df801e71de41b2@postgresql.org
Whole thread Raw
Responses Re: BUG #19049: Assert failure when using skip arrays on an index key with DESC order
Re: BUG #19049: Assert failure when using skip arrays on an index key with DESC order
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      19049
Logged by:          Natalya Aksman
Email address:      natalya@timescale.com
PostgreSQL version: 18rc1
Operating system:   Ubuntu 24.04
Description:

Reproducer:

-- Set up a table with >=2 DESC index keys
create table mv (t1 int, t2 int, s0 int, s1 int);
create index on mv(s0, s1, t1 desc, t2 desc);
insert into mv select f.t,  f.t, 1 s0, 1 s1 from generate_series(1, 2 *
pow(10, 4)::int) f(t);
analyze mv;

-- Make sure index is used
set enable_seqscan=0;
explain (costs off) select distinct on(s0, s1) * from mv where t2 >= -1 and
t1 < 10 order by s0, s1, t1 desc, t2 desc;
                        QUERY PLAN
-----------------------------------------------------------
 Unique
   ->  Index Only Scan using mv_s0_s1_t1_t2_idx on mv
         Index Cond: ((t1 < 10) AND (t2 >= '-1'::integer))
(3 rows)

-- 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)));

The problem is "array->low_compare" changing "t1<10" to "t1>10" because t1
order is DESC.


pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #19048: PostgreSQL Windows Turkish Search Problem
Next
From: PG Bug reporting form
Date:
Subject: BUG #19050: psql: could not find digest for NID UNDEF