1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

MDEV-6794 XtraDB no longer using UNIQUE as clustered index when PK missing

try the first unique key as a surrogate PK *before* disabling extended
keys because of missing PK
This commit is contained in:
Sergei Golubchik
2014-11-18 22:26:14 +01:00
parent 79c76400a6
commit c417da24a3
3 changed files with 71 additions and 36 deletions

View File

@ -0,0 +1,20 @@
create table t1 (c1 int not null, c2 int, unique index(c1), index (c2)) engine=innodb;
insert into t1 (c1, c2) select 1, round(rand()*100);
insert into t1 (c1, c2) select (select max(c1) from t1) + c1, c1*93563%100 from t1;
insert into t1 (c1, c2) select (select max(c1) from t1) + c1, c1*93563%100 from t1;
insert into t1 (c1, c2) select (select max(c1) from t1) + c1, c1*93563%100 from t1;
select count(*) from t1;
count(*)
8
explain select * from t1 where c2 = 1 order by c1;
id 1
select_type SIMPLE
table t1
type ref
possible_keys c2
key c2
key_len 5
ref const
rows 1
Extra Using where; Using index
drop table t1;

View File

@ -0,0 +1,15 @@
#
# MDEV-6794 XtraDB no longer using UNIQUE as clustered index when PK missing
#
--source include/have_innodb.inc
create table t1 (c1 int not null, c2 int, unique index(c1), index (c2)) engine=innodb;
insert into t1 (c1, c2) select 1, round(rand()*100);
insert into t1 (c1, c2) select (select max(c1) from t1) + c1, c1*93563%100 from t1;
insert into t1 (c1, c2) select (select max(c1) from t1) + c1, c1*93563%100 from t1;
insert into t1 (c1, c2) select (select max(c1) from t1) + c1, c1*93563%100 from t1;
select count(*) from t1;
--query_vertical explain select * from t1 where c2 = 1 order by c1
drop table t1;