2014-01-02 14:51:02 +01:00
|
|
|
set @save_ext_key_optimizer_switch=@@optimizer_switch;
|
2013-01-14 14:05:05 +01:00
|
|
|
#
|
|
|
|
# MDEV-3992 Server crash or valgrind errors in test_if_skip_sort_order/test_if_cheaper_ordering
|
|
|
|
# on GROUP BY with indexes on InnoDB table
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
pk INT PRIMARY KEY,
|
|
|
|
a VARCHAR(1) NOT NULL,
|
|
|
|
KEY (pk)
|
|
|
|
) ENGINE=InnoDB;
|
2014-01-02 14:51:02 +01:00
|
|
|
set optimizer_switch='extended_keys=on';
|
2013-01-14 14:05:05 +01:00
|
|
|
INSERT INTO t1 VALUES (1,'a'),(2,'b');
|
|
|
|
EXPLAIN
|
|
|
|
SELECT COUNT(*), pk field1, pk AS field2
|
|
|
|
FROM t1 WHERE a = 'r' OR pk = 183
|
|
|
|
GROUP BY field1, field2;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2014-01-02 14:51:02 +01:00
|
|
|
1 SIMPLE t1 index PRIMARY,pk PRIMARY 4 NULL 2 Using where
|
2013-01-14 14:05:05 +01:00
|
|
|
SELECT COUNT(*), pk field1, pk AS field2
|
|
|
|
FROM t1 WHERE a = 'r' OR pk = 183
|
|
|
|
GROUP BY field1, field2;
|
|
|
|
COUNT(*) field1 field2
|
|
|
|
EXPLAIN
|
|
|
|
SELECT COUNT(*), pk field1 FROM t1
|
|
|
|
WHERE a = 'r' OR pk = 183 GROUP BY field1, field1;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2014-01-02 14:51:02 +01:00
|
|
|
1 SIMPLE t1 index PRIMARY,pk PRIMARY 4 NULL 2 Using where
|
2013-01-14 14:05:05 +01:00
|
|
|
SELECT COUNT(*), pk field1 FROM t1
|
|
|
|
WHERE a = 'r' OR pk = 183 GROUP BY field1, field1;
|
|
|
|
COUNT(*) field1
|
|
|
|
drop table t1;
|
|
|
|
End of 5.5 tests
|
2014-01-02 14:51:02 +01:00
|
|
|
set optimizer_switch=@save_ext_key_optimizer_switch;
|