1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-27382: OFFSET is ignored when combined with DISTINCT

A query in form

  SELECT DISTINCT expr_that_is_inferred_to_be_const LIMIT 0 OFFSET n

produces one row when it should produce none. The issue was in
JOIN_TAB::remove_duplicates() in the piece of logic that tried to
avoid duplicate removal for such cases but didn't account for possible
"LIMIT 0".

Fixed by making Select_limit_counters::set_limit() change OFFSET to 0
when LIMIT is 0.
This commit is contained in:
Sergei Petrunia
2022-01-13 15:53:44 +03:00
parent be8113861c
commit 7259b299a5
3 changed files with 76 additions and 0 deletions

View File

@ -35,6 +35,8 @@ class Select_limit_counters
void set_limit(ha_rows limit, ha_rows offset)
{
if (limit == 0)
offset= 0;
offset_limit_cnt= offset;
select_limit_cnt= limit;
if (select_limit_cnt + offset_limit_cnt >=