1#
2# Bug 1617586 (SELECT DISTINCT x...ORDER BY y LIMIT N,N crashes server)
3#
4# Loading data
5SHOW CREATE TABLE t1;
6Table	Create Table
7t1	CREATE TABLE `t1` (
8  `id` int(11) NOT NULL AUTO_INCREMENT,
9  `field1` varchar(255) DEFAULT NULL,
10  `field2` int(11) DEFAULT NULL,
11  `field3` datetime DEFAULT NULL,
12  `field4` varchar(255) DEFAULT NULL,
13  `field5` int(11) DEFAULT NULL,
14  PRIMARY KEY (`id`),
15  KEY `index_audits_on_field2` (`field2`),
16  KEY `on_field4` (`field4`),
17  KEY `index_audits_on_field1` (`field1`),
18  KEY `index_audits_on_field4_and_field5_and_field3` (`field4`,`field5`,`field3`),
19  KEY `idx_on_field4_and_field5_and_field2` (`field4`,`field5`,`field2`)
20) ENGINE=InnoDB AUTO_INCREMENT=8000000 DEFAULT CHARSET=latin1
21ANALYZE TABLE t1;
22Table	Op	Msg_type	Msg_text
23test.t1	analyze	status	OK
24SELECT DISTINCT field2 FROM t1
25WHERE (field4 IS NULL AND field5 = 233 AND field1 = 'c6bb07f8b5')
26ORDER BY field3 LIMIT 1;
27field2
282272669
29DROP TABLE t1;
30