[MDEV-30443] Wrong result (OFFSET is ignored) with DISTINCT Created: 2023-01-21  Updated: 2023-11-28

Status: Open
Project: MariaDB Server
Component/s: Server
Affects Version/s: 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11
Fix Version/s: 10.5, 10.6, 10.11

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: 11.0-sel


 Description   

CREATE TABLE t1 (a int) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1);
 
CREATE TABLE t2 (b int) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1),(2),(3);
 
SELECT DISTINCT t1.a FROM t1 JOIN t2 ORDER BY a LIMIT 10 OFFSET 10;
 
# Cleanup
DROP TABLE t1, t2;

10.5 eeb8ebb1

SELECT DISTINCT t1.a FROM t1 JOIN t2 ORDER BY a LIMIT 10 OFFSET 10;
a
1

The expected result is an empty set.

The failure started happening after this commit in 10.5.0:

commit eb0804ef5e7eeb059bb193c3c6787e8a4188d34d
Author: Oleksandr Byelkin
Date:   Thu Sep 26 09:49:50 2019 +0200
 
    MDEV-18553: MDEV-16327 pre-requisits part 1: isolation of LIMIT/OFFSET handling



 Comments   
Comment by Elena Stepanova [ 2023-02-07 ]

A simpler test case:

--source include/have_sequence.inc
select distinct 1 from seq_1_to_10 limit 10 offset 5;
+---+
| 1 |
+---+
| 1 |
+---+

Generated at Thu Feb 08 10:16:17 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.