Debian Codegraph @

mysql-test/suite/gcol_ndb/t/gcol_stored_index.test

raw
1 ################################################################################
2 #
3 # Test GENERATED ALWAYS AS ... STORED with index
4 # access by unique index on generated column
5 # access by ordered index on generated column
6 #
7 # "j generated ... stored unique" has both unique and ordered indexes
8 ################################################################################
9
10 --source include/have_ndb.inc
11
12 create table test_gcol_index (
13 i int not null primary key,
14 j int generated always as (100+mod(i,10)) stored unique
15 ) engine = 'ndbcluster';
16
17 insert into test_gcol_index
18 values
19 (1, default),
20 (2, default),
21 (3, default),
22 (4, default),
23 (5, default),
24 (6, default),
25 (7, default),
26 (8, default),
27 (9, default);
28
29 # Access by primary key
30 select * from test_gcol_index where i = 4;
31
32 # Index read access
33 select * from test_gcol_index where j = 104;
34 explain select * from test_gcol_index where j = 104;
35
36 # Scan with pushed condition
37 select * from test_gcol_index where j > 106 order by j;
38 explain select * from test_gcol_index where j > 106;
39
40 # DUPLICATE KEY ERROR on the unique index
41 --error 1062
42 insert into test_gcol_index values(13, default);
43
44 drop table test_gcol_index;