summaryrefslogtreecommitdiff
path: root/mysql-test/t/invisible_field_debug.test
blob: 3c2febf160684973415a0aa5b893b1aa3a5b792e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
--source include/have_debug.inc
##TEST for invisible coloumn level 2
set @old_debug= @@debug_dbug;
set debug_dbug= "+d,test_pseudo_invisible";
create table t1(a int);
set debug_dbug=@old_debug;

desc t1;
show create table t1;
insert into t1 values(1);
##field should not be resolved in Item_field::set_field
--error ER_BAD_FIELD_ERROR
insert into t1(a, invisible) values(99,99);
--error ER_BAD_FIELD_ERROR
alter table t1 add constraint a check (invisble > 2);
set debug_dbug= "+d,test_pseudo_invisible";
--error ER_BAD_FIELD_ERROR
create table t2(a int, b int as (invisible +2) virtual);
set debug_dbug=@old_debug;
select * from t1;
select invisible ,a from t1;
drop table t1;

##TEST for invisible coloumn level 3

set debug_dbug= "+d,test_completely_invisible";
create table t1(a int);
set debug_dbug=@old_debug;

desc t1;
show create table t1;
insert into t1 values(1);
select * from t1;

--error ER_BAD_FIELD_ERROR
select invisible ,a from t1;

set debug_dbug= "+d,test_completely_invisible";
select invisible ,a from t1;
set debug_dbug=@old_debug;

drop table t1;

##TEST for Alter table for invisibleness level 2

set debug_dbug= "+d,test_pseudo_invisible";
create table t1(a int);
set debug_dbug=@old_debug;

desc t1;
insert into t1 values(1);
select * from t1;
select invisible ,a from t1;

## Alter should not be possible

--error ER_BAD_FIELD_ERROR
ALTER table t1 change invisible b int;
select * from t1;
select invisible ,a from t1;

--error ER_BAD_FIELD_ERROR
ALTER table t1 modify invisible char;
select * from t1;
select invisible ,a from t1;

--error ER_CANT_DROP_FIELD_OR_KEY
ALTER table t1 drop invisible;
select * from t1;
select invisible ,a from t1;

--error ER_DUP_FIELDNAME
ALTER table t1 add invisible int;
select * from t1;
select invisible ,a from t1;

ALTER table t1 add invisible2 int default 2;
select * from t1;
select invisible ,a from t1;

drop table t1;

##TEST for Alter table for invisibleness level 3

set debug_dbug= "+d,test_completely_invisible";
create table t1(a int);

desc t1;
insert into t1 values(1);
select * from t1;
select invisible ,a from t1;

## Alter should not be possible

--error ER_BAD_FIELD_ERROR
ALTER table t1 change invisible b int;
select * from t1;
select invisible ,a from t1;

--error ER_BAD_FIELD_ERROR
ALTER table t1 modify invisible char;
select * from t1;
select invisible ,a from t1;

--error ER_CANT_DROP_FIELD_OR_KEY
ALTER table t1 drop invisible;
select * from t1;
select invisible ,a from t1;

ALTER table t1 add invisible int;
select * from t1;
select invisible1, invisible ,a from t1;

#set debug_dbug=@old_debug;
ALTER table t1 add hid int default 2;
set debug_dbug= "+d,test_completely_invisible";
select * from t1;
select invisible ,a from t1;

drop table t1;
set debug_dbug=@old_debug;

## Test Index on USER_DEFINED_INVISIBLE

Create table t1( a int default(99) invisible, b int);
insert into t1 values(1);
insert into t1 values(2);
insert into t1 values(3);
insert into t1 values(4);
select * from t1 order by b;
alter table t1 add index(a);
alter table t1 add index(a,b);
show index from t1;
drop table t1;

## Test Index on PSEUDO_invisible_INVISIBLE

set debug_dbug= "+d,test_pseudo_invisible";
Create table t1( a int default(99) invisible, b int);

--error ER_KEY_COLUMN_DOES_NOT_EXITS
Create table t2( a int default(99) invisible, b int, unique(invisible));

set debug_dbug=@old_debug;
insert into t1 values(1);
insert into t1 values(2);
insert into t1 values(3);
insert into t1 values(4);
select * from t1 order by b;
select invisible, a, b from t1 order by b;
--error ER_KEY_COLUMN_DOES_NOT_EXITS
alter table t1 add index(invisible);
--error ER_KEY_COLUMN_DOES_NOT_EXITS
alter table t1 add index(b,invisible);
show index from t1;
drop table t1;

## Test Index on COMPLETELY_INVISIBLE

set debug_dbug= "+d,test_completely_invisible";
Create table t1( a int default(99) invisible, b int);

--error ER_KEY_COLUMN_DOES_NOT_EXITS
Create table t2( a int default(99) invisible, b int, unique(invisible));
insert into t1 values(1);
insert into t1 values(2);
insert into t1 values(3);
insert into t1 values(4);
select * from t1 order by b;
select invisible, a, b from t1 order by b;
set debug_dbug=@old_debug;

--error ER_KEY_COLUMN_DOES_NOT_EXITS
alter table t1 add index(invisible);
--error ER_KEY_COLUMN_DOES_NOT_EXITS
alter table t1 add index(b,invisible);
show index from t1;
drop table t1;
## Sytem Generated index on invisible column
set debug_dbug= "+d,test_completely_invisible,test_invisible_index";
## index name will be invisible
Create table t1( a int default(99) , b int,c int, index(b));
set debug_dbug=@old_debug;
Show index from t1;
select * from INFORMATION_SCHEMA.STATISTICS where TABLE_SCHEMA ='test' and table_name='t1';
show create table t1;
insert into t1 values(1,1,1);
insert into t1 values(2,2,2);
insert into t1 values(3,3,3);
insert into t1 values(4,4,4);
set debug_dbug= "+d,test_completely_invisible,test_invisible_index";
select invisible, a ,b from t1 order by b;
explain select * from t1 where invisible =9;
alter table t1 add x int default 3;
select invisible, a ,b from t1;
set debug_dbug=@old_debug;
Show index from t1;
## Sytem Generated Index modification
--error ER_KEY_COLUMN_DOES_NOT_EXITS
create index a1 on t1(invisible);
set debug_dbug= "+d,test_completely_invisible,test_invisible_index";
## index does not exist for user
--error ER_CANT_DROP_FIELD_OR_KEY
drop index invisible on t1;
explain select * from t1 where invisible =9;
## index name will be changed
create index invisible on t1(c);
explain select * from t1 where invisible =9;
show indexes in t1;
drop table t1;
set @old_debug= @@debug_dbug;