Skip to content

[2.3.232] Regression in ORDER BY ... DESC with WHERE ... IN and OR clauses #4144

@lbl-dev

Description

@lbl-dev

Hello,

After upgrading H2 from 2.2.224 to 2.3.232, we encountered a regression in how order by ... desc works. The following query unexpectedly returns results in ascending order, despite the explicit order by id desc:

create table my_table
(
    id number,
    primary key (id)
);

create index idx_my_table on my_table (id);

insert into my_table (id) values (0);
insert into my_table (id) values (1);

select * from my_table where id in (0, 1) order by id desc;

results in

0
1

instead of

1
0

The issue also occurs when replacing the where ... in clause with an or condition:

select * from my_table where id = 0 or id = 1 order by id desc;

The issue does not occur when either the primary key (id) constraint or the index idx_my_table is removed.

Potentially linked to #4079, also present in 2.3.230

Thank you for your amazing work 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions