~mordred/drizzle/codestyle

« back to all changes in this revision

Viewing changes to tests/suite/vcol/inc/vcol_keys.inc

  • Committer: Brian Aker
  • Date: 2008-10-13 16:50:30 UTC
  • mfrom: (509.1.4 codestyle)
  • Revision ID: brian@tangent.org-20081013165030-642le57opeglwfdw
Merge from Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
################################################################################
 
2
# inc/vcol_keys.inc                                                            #
 
3
#                                                                              #
 
4
# Purpose:                                                                     #
 
5
#  Testing keys, indexes defined upon virtual columns.                         #
 
6
#                                                                              #
 
7
#                                                                              #
 
8
#                                                                              #
 
9
#------------------------------------------------------------------------------#
 
10
# Original Author: Andrey Zhakov                                               #
 
11
# Original Date: 2008-09-02                                                    #
 
12
# Change Author:                                                               #
 
13
# Change Date:                                                                 #
 
14
# Change:                                                                      #
 
15
################################################################################
 
16
 
 
17
 
 
18
--echo #            - UNIQUE KEY
 
19
--echo #            - INDEX
 
20
--echo #            - FOREIGN INDEX (partially supported)
 
21
--echo #            - CHECK (allowed but not used)
 
22
 
 
23
--echo # UNIQUE
 
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);
 
27
show create table t1;
 
28
describe t1;
 
29
drop table t1;
 
30
 
 
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));
 
34
show create table t1;
 
35
describe t1;
 
36
drop table t1;
 
37
 
 
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);
 
41
drop table t1;
 
42
create table t1 (a int, b virtual int as (a*2) stored);
 
43
alter table t1 add unique key (b);
 
44
drop table t1;
 
45
 
 
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
 
50
 
 
51
--echo # 
 
52
--echo # INDEX
 
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));
 
57
 
 
58
create table t1 (a int, b virtual int as (a*2) stored, index (b));
 
59
show create table t1;
 
60
describe t1;
 
61
drop table t1;
 
62
 
 
63
create table t1 (a int, b virtual int as (a*2) stored, index (a,b));
 
64
show create table t1;
 
65
describe t1;
 
66
drop table t1;
 
67
 
 
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);
 
73
drop table t1;
 
74
 
 
75
create table t1 (a int, b virtual int as (a*2) stored);
 
76
alter table t1 add index (b);
 
77
drop table t1;
 
78
 
 
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;
 
82
drop table t2;
 
83
drop table t1;
 
84
 
 
85
--echo # Testing data manipulation operations involving INDEX
 
86
--echo # on virtual columns can be found in:
 
87
--echo #  - vcol_select.inc
 
88
 
 
89
--echo # FOREIGN KEY
 
90
 
 
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);
 
101
 
 
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;
 
109
drop table t1;
 
110
 
 
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));
 
114
 
 
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);
 
118
drop table t1;
 
119
 
 
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);
 
124
drop table t1;
 
125
create table t1 (a int, b virtual int as (a % 10) stored,
 
126
                 foreign key (b) references t2(a) on update no action);
 
127
drop table t1;
 
128
create table t1 (a int, b virtual int as (a % 10) stored,
 
129
                 foreign key (b) references t2(a) on delete restrict);
 
130
drop table t1;
 
131
create table t1 (a int, b virtual int as (a % 10) stored,
 
132
                 foreign key (b) references t2(a) on delete cascade);
 
133
drop table t1;
 
134
create table t1 (a int, b virtual int as (a % 10) stored,
 
135
                 foreign key (b) references t2(a) on delete no action);
 
136
drop table t1;
 
137
 
 
138
--echo 
 
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
 
143
 
 
144
--echo #
 
145
--echo # TODO: CHECK
 
146