| 1 |
create table test_gcol_index ( |
| 2 |
i int not null primary key, |
| 3 |
j int generated always as (100+mod(i,10)) stored unique |
| 4 |
) engine = 'ndbcluster'; |
| 5 |
insert into test_gcol_index |
| 6 |
values |
| 7 |
(1, default), |
| 8 |
(2, default), |
| 9 |
(3, default), |
| 10 |
(4, default), |
| 11 |
(5, default), |
| 12 |
(6, default), |
| 13 |
(7, default), |
| 14 |
(8, default), |
| 15 |
(9, default); |
| 16 |
select * from test_gcol_index where i = 4; |
| 17 |
i j |
| 18 |
4 104 |
| 19 |
select * from test_gcol_index where j = 104; |
| 20 |
i j |
| 21 |
4 104 |
| 22 |
explain select * from test_gcol_index where j = 104; |
| 23 |
id select_type table partitions type possible_keys key key_len ref rows filtered Extra |
| 24 |
1 SIMPLE test_gcol_index p0,p1,p2,p3,p4,p5,p6,p7 eq_ref j j 5 const 1 100.00 NULL |
| 25 |
Warnings: |
| 26 |
Note 1003 /* select#1 */ select `test`.`test_gcol_index`.`i` AS `i`,`test`.`test_gcol_index`.`j` AS `j` from `test`.`test_gcol_index` where (`test`.`test_gcol_index`.`j` = 104) |
| 27 |
select * from test_gcol_index where j > 106 order by j; |
| 28 |
i j |
| 29 |
7 107 |
| 30 |
8 108 |
| 31 |
9 109 |
| 32 |
explain select * from test_gcol_index where j > 106; |
| 33 |
id select_type table partitions type possible_keys key key_len ref rows filtered Extra |
| 34 |
1 SIMPLE test_gcol_index p0,p1,p2,p3,p4,p5,p6,p7 range j j 5 NULL 3 100.00 Using pushed condition (`test`.`test_gcol_index`.`j` > 106); Using MRR |
| 35 |
Warnings: |
| 36 |
Note 1003 /* select#1 */ select `test`.`test_gcol_index`.`i` AS `i`,`test`.`test_gcol_index`.`j` AS `j` from `test`.`test_gcol_index` where (`test`.`test_gcol_index`.`j` > 106) |
| 37 |
insert into test_gcol_index values(13, default); |
| 38 |
ERROR 23000: Duplicate entry '103' for key 'test_gcol_index.j' |
| 39 |
drop table test_gcol_index; |