Weird things caused by default sorting

Bug #1507164 reported by Andrey
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MySQL Server
Unknown
Unknown
Percona Server moved to https://jira.percona.com/projects/PS
Status tracked in 5.7
5.5
Invalid
Undecided
Unassigned
5.6
Invalid
High
Unassigned
5.7
Invalid
High
Unassigned

Bug Description

Hello. I've got a table like the attached one.

Then I launch following query:

SELECT id,k1 FROM table1 WHERE id > 3400 ORDER BY k1 DESC LIMIT 0,20 -- getting ids 3405,3406 etc

then I change the limit:

SELECT id,k1 FROM table1 WHERE id > 3400 ORDER BY k1 DESC LIMIT 20,20 -- and I get 3405, 3406 AGAIN in a row set.

reproduced on 5.6.21-70.1 .

Tags: upstream
Revision history for this message
Andrey (ansrd) wrote :
description: updated
Revision history for this message
Nilnandan Joshi (nilnandan-joshi) wrote :

Verified with 5.6.26.

nilnandan@desktop:~$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 55
Server version: 5.6.26-74.0-log Percona Server (GPL), Release 74.0, Revision 32f8dfd

Copyright (c) 2009-2015 Percona LLC and/or its affiliates
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql>
mysql> SELECT id,k1 FROM table1 WHERE id > 3400 ORDER BY k1 DESC LIMIT 0,20;
+------+----+
| id | k1 |
+------+----+
| 3669 | 2 |
| 3543 | 1 |
| 3705 | 1 |
| 3698 | 1 |
| 3421 | 1 |
| 3690 | 1 |
| 3671 | 1 |
| 3407 | 0 |
| 3420 | 0 |
| 3419 | 0 |
| 3418 | 0 |
| 3403 | 0 |
| 3415 | 0 |
| 3414 | 0 |
| 3413 | 0 |
| 3412 | 0 |
| 3405 | 0 |
| 3410 | 0 |
| 3812 | 0 |
| 3406 | 0 |
+------+----+
20 rows in set (0.00 sec)

mysql> SELECT id,k1 FROM table1 WHERE id > 3400 ORDER BY k1 DESC LIMIT 20,20;
+------+----+
| id | k1 |
+------+----+
| 3440 | 0 |
| 3441 | 0 |
| 3425 | 0 |
| 3424 | 0 |
| 3423 | 0 |
| 3405 | 0 |
| 3407 | 0 |
| 3409 | 0 |
| 3410 | 0 |
| 3411 | 0 |
| 3412 | 0 |
| 3413 | 0 |
| 3414 | 0 |
| 3415 | 0 |
| 3417 | 0 |
| 3418 | 0 |
| 3419 | 0 |
| 3420 | 0 |
| 3406 | 0 |
| 3422 | 0 |
+------+----+
20 rows in set (0.00 sec)

mysql> select * from table1 where id = 3405;
+------+----+
| id | k1 |
+------+----+
| 3405 | 0 |
+------+----+
1 row in set (0.00 sec)

mysql> select * from table1 where id = 3406;
+------+----+
| id | k1 |
+------+----+
| 3406 | 0 |
+------+----+
1 row in set (0.00 sec)

mysql>

Changed in percona-server:
status: New → Confirmed
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

Upstream?

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

Reverting to "New" in order to get upstream status checked

tags: added: upstream
Revision history for this message
Nickolay Ihalainen (ihanick) wrote :

Not a Bug in upstream, explanation could be found in earlier bug:
https://bugs.mysql.com/bug.php?id=72076

Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PS-931

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.