[MDEV-641] LP:1002108 - Wrong result (or crash) from a query with duplicated field in the group list and a limit clause Created: 2012-05-21  Updated: 2013-02-01  Resolved: 2013-02-01

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.5.30, 5.1.73, 5.3.13

Type: Bug Priority: Minor
Reporter: Igor Babaev Assignee: Timour Katchaounov (Inactive)
Resolution: Fixed Votes: 0
Labels: Launchpad

Attachments: XML File LPexportBug1002108.xml    

 Description   

The following test case gives us a wrong result in MariaDB 5.2/5.3/5.5:

CREATE TABLE t1(
col1 int,
UNIQUE INDEX idx (col1)
);

INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);

SELECT SQL_BIG_RESULT tbl1.col1 AS field1, tbl2.col1 AS field2
FROM t1 as tbl1, t1 as tbl2
GROUP BY field1, field2
LIMIT 3;

(see also bug #53534 in bugs.mysql.com)



 Comments   
Comment by Rasmus Johansson (Inactive) [ 2012-05-21 ]

Launchpad bug id: 1002108

Comment by Timour Katchaounov (Inactive) [ 2013-01-17 ]

Investigation of the bug on various versions, using the following test case (based on the one in MySQL 5.6):
CREATE TABLE t1m(col1 int, UNIQUE INDEX idx (col1)) engine=myisam;

INSERT INTO t1m VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),
(11),(12),(13),(14),(15),(16),(17),(18),(19),(20);

EXPLAIN
SELECT SQL_BIG_RESULT col1 AS field1, col1 AS field2
FROM t1m GROUP BY field1, field2;

SELECT SQL_BIG_RESULT col1 AS field1, col1 AS field2
FROM t1m GROUP BY field1, field2;

  • MariaDB 5.3 - wrong result
  • MariaDB 5.5 - crash in debug mode - failed assert DBUG_ASSERT(inited==INDEX)
    in ha_index_end() called from QUICK_GROUP_MIN_MAX_SELECT::~QUICK_GROUP_MIN_MAX_SELECT
  • MySQL 5.5 - wrong result
  • MySQL 5.6 - fixed
Comment by Timour Katchaounov (Inactive) [ 2013-01-17 ]

MySQL's fix looks like an optimization that hides the real problem. Investigating.

Comment by Timour Katchaounov (Inactive) [ 2013-01-31 ]

The situation described in this bug is quite uncommon, therefore the solution is to make loose scan analysis take into account that there may be duplicate columns. Since there cannot be an index with duplicate columns, loose scan will become inapplicable to group by queries with duplicate group columns.

This limitation will be lifted in 10.0 by MDEV-4119.

Comment by Timour Katchaounov (Inactive) [ 2013-02-01 ]

Moved fix to 5.1, test, push

Generated at Thu Feb 08 06:30:15 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.