1
################################################################################
5
# Testing keys, indexes defined upon virtual columns. #
9
#------------------------------------------------------------------------------#
10
# Original Author: Andrey Zhakov #
11
# Original Date: 2008-09-02 #
15
################################################################################
20
--echo # - FOREIGN INDEX (partially supported)
21
--echo # - CHECK (allowed but not used)
24
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
25
create table t1 (a int, b virtual int as (a*2) unique);
26
create table t1 (a int, b virtual int as (a*2) stored unique);
31
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
32
create table t1 (a int, b virtual int as (a*2), unique key (b));
33
create table t1 (a int, b virtual int as (a*2) stored, unique (b));
38
create table t1 (a int, b virtual int as (a*2));
39
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
40
alter table t1 add unique key (b);
42
create table t1 (a int, b virtual int as (a*2) stored);
43
alter table t1 add unique key (b);
46
--echo # Testing data manipulation operations involving UNIQUE keys
47
--echo # on virtual columns can be found in:
48
--echo # - vcol_ins_upd.inc
49
--echo # - vcol_select.inc
53
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
54
create table t1 (a int, b virtual int as (a*2), index (b));
55
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
56
create table t1 (a int, b virtual int as (a*2), index (a,b));
58
create table t1 (a int, b virtual int as (a*2) stored, index (b));
63
create table t1 (a int, b virtual int as (a*2) stored, index (a,b));
68
create table t1 (a int, b virtual int as (a*2));
69
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
70
alter table t1 add index (b);
71
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
72
alter table t1 add index (a,b);
75
create table t1 (a int, b virtual int as (a*2) stored);
76
alter table t1 add index (b);
79
create table t1 (a int, b virtual int as (a*2) stored);
80
alter table t1 add index (a,b);
81
create table t2 like t1;
85
--echo # Testing data manipulation operations involving INDEX
86
--echo # on virtual columns can be found in:
87
--echo # - vcol_select.inc
91
--echo # Rejected FK options.
92
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
93
create table t1 (a int, b virtual int as (a+1) stored,
94
foreign key (b) references t2(a) on update set null);
95
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
96
create table t1 (a int, b virtual int as (a+1) stored,
97
foreign key (b) references t2(a) on update cascade);
98
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
99
create table t1 (a int, b virtual int as (a+1) stored,
100
foreign key (b) references t2(a) on delete set null);
102
create table t1 (a int, b virtual int as (a+1) stored);
103
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
104
alter table t1 add foreign key (b) references t2(a) on update set null;
105
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
106
alter table t1 add foreign key (b) references t2(a) on update cascade;
107
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
108
alter table t1 add foreign key (b) references t2(a) on delete set null;
111
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
112
create table t1 (a int, b virtual int as (a+1),
113
foreign key (b) references t2(a));
115
create table t1 (a int, b virtual int as (a+1));
116
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
117
alter table t1 add foreign key (b) references t2(a);
120
--echo # Allowed FK options.
121
create table t2 (a int primary key, b char(5));
122
create table t1 (a int, b virtual int as (a % 10) stored,
123
foreign key (b) references t2(a) on update restrict);
125
create table t1 (a int, b virtual int as (a % 10) stored,
126
foreign key (b) references t2(a) on update no action);
128
create table t1 (a int, b virtual int as (a % 10) stored,
129
foreign key (b) references t2(a) on delete restrict);
131
create table t1 (a int, b virtual int as (a % 10) stored,
132
foreign key (b) references t2(a) on delete cascade);
134
create table t1 (a int, b virtual int as (a % 10) stored,
135
foreign key (b) references t2(a) on delete no action);
139
--echo # Testing data manipulation operations involving FOREIGN KEY
140
--echo # on virtual columns can be found in:
141
--echo # - vcol_ins_upd.inc
142
--echo # - vcol_select.inc