Bug #85533 Incorrect sorting result while substring_index function

Submitted: 20 Mar 2017 9:17 Modified: 20 Mar 2017 11:41
Reporter: Vardan Shahinyan Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.7.16-log, 5.5.54, 5.6.35, 5.7.17 OS:Any
Assigned to: CPU Architecture:Any
Tags: order by, SUBSTRING_INDEX

[20 Mar 2017 9:17] Vardan Shahinyan
Description:
Correct execution result of below query should have `workbench.mysql.com` and  `dev.mysql.com` exchanged by places.

How to repeat:
CREATE TABLE `hostnames` (
  `id` int(11) NOT NULL,
  `hostname` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `hostnames` VALUES (1,'workbench.mysql.com'),(2,'codefights.slack.com'),(3,'codefights.com'),(4,'snarknews.info'),(5,'sololearn.com'),(6,'dev.mysql.com');

SELECT id,hostname 
  FROM hostnames 
  ORDER BY SUBSTRING_INDEX(concat('...',hostname),'.',-1), SUBSTRING_INDEX(concat('...',hostname),'.',-2), hostname;
[20 Mar 2017 11:41] MySQL Verification Team
Hello Vardan,

Thank you for the report and test case.

Thanks,
Umesh

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.050 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.