Skip to content

Commit 022b163

Browse files
vuvovamariadb-SachinSetiya
authored andcommitted
Add tests for system and completely invisible columns
debug only
1 parent 8472690 commit 022b163

File tree

5 files changed

+509
-3
lines changed

5 files changed

+509
-3
lines changed
Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,285 @@
1+
set @old_debug= @@debug_dbug;
2+
set debug_dbug= "+d,test_pseudo_invisible";
3+
create table t1(a int);
4+
set debug_dbug=@old_debug;
5+
desc t1;
6+
Field Type Null Key Default Extra
7+
a int(11) YES NULL
8+
show create table t1;
9+
Table Create Table
10+
t1 CREATE TABLE `t1` (
11+
`a` int(11) DEFAULT NULL
12+
) ENGINE=MyISAM DEFAULT CHARSET=latin1
13+
insert into t1 values(1);
14+
select * from t1;
15+
a
16+
1
17+
select invisible ,a from t1;
18+
invisible a
19+
9 1
20+
drop table t1;
21+
set debug_dbug= "+d,test_completely_invisible";
22+
create table t1(a int);
23+
set debug_dbug=@old_debug;
24+
desc t1;
25+
Field Type Null Key Default Extra
26+
a int(11) YES NULL
27+
show create table t1;
28+
Table Create Table
29+
t1 CREATE TABLE `t1` (
30+
`a` int(11) DEFAULT NULL
31+
) ENGINE=MyISAM DEFAULT CHARSET=latin1
32+
insert into t1 values(1);
33+
select * from t1;
34+
a
35+
1
36+
select invisible ,a from t1;
37+
ERROR 42S22: Unknown column 'invisible' in 'field list'
38+
set debug_dbug= "+d,test_completely_invisible";
39+
select invisible ,a from t1;
40+
invisible a
41+
9 1
42+
set debug_dbug=@old_debug;
43+
drop table t1;
44+
set debug_dbug= "+d,test_pseudo_invisible";
45+
create table t1(a int);
46+
set debug_dbug=@old_debug;
47+
desc t1;
48+
Field Type Null Key Default Extra
49+
a int(11) YES NULL
50+
insert into t1 values(1);
51+
select * from t1;
52+
a
53+
1
54+
select invisible ,a from t1;
55+
invisible a
56+
9 1
57+
ALTER table t1 change invisible b int;
58+
ERROR 42S22: Unknown column 'invisible' in 't1'
59+
select * from t1;
60+
a
61+
1
62+
select invisible ,a from t1;
63+
invisible a
64+
9 1
65+
ALTER table t1 modify invisible char;
66+
ERROR 42S22: Unknown column 'invisible' in 't1'
67+
select * from t1;
68+
a
69+
1
70+
select invisible ,a from t1;
71+
invisible a
72+
9 1
73+
ALTER table t1 drop invisible;
74+
ERROR 42000: Can't DROP COLUMN `invisible`; check that it exists
75+
select * from t1;
76+
a
77+
1
78+
select invisible ,a from t1;
79+
invisible a
80+
9 1
81+
ALTER table t1 add invisible int;
82+
ERROR 42S21: Duplicate column name 'invisible'
83+
select * from t1;
84+
a
85+
1
86+
select invisible ,a from t1;
87+
invisible a
88+
9 1
89+
ALTER table t1 add invisible2 int default 2;
90+
select * from t1;
91+
a invisible2
92+
1 2
93+
select invisible ,a from t1;
94+
invisible a
95+
9 1
96+
drop table t1;
97+
set debug_dbug= "+d,test_completely_invisible";
98+
create table t1(a int);
99+
desc t1;
100+
Field Type Null Key Default Extra
101+
a int(11) YES NULL
102+
insert into t1 values(1);
103+
select * from t1;
104+
a
105+
1
106+
select invisible ,a from t1;
107+
invisible a
108+
9 1
109+
ALTER table t1 change invisible b int;
110+
ERROR 42S22: Unknown column 'invisible' in 't1'
111+
select * from t1;
112+
a
113+
1
114+
select invisible ,a from t1;
115+
invisible a
116+
9 1
117+
ALTER table t1 modify invisible char;
118+
ERROR 42S22: Unknown column 'invisible' in 't1'
119+
select * from t1;
120+
a
121+
1
122+
select invisible ,a from t1;
123+
invisible a
124+
9 1
125+
ALTER table t1 drop invisible;
126+
ERROR 42000: Can't DROP COLUMN `invisible`; check that it exists
127+
select * from t1;
128+
a
129+
1
130+
select invisible ,a from t1;
131+
invisible a
132+
9 1
133+
ALTER table t1 add invisible int;
134+
select * from t1;
135+
a invisible
136+
1 NULL
137+
select invisible1, invisible ,a from t1;
138+
invisible1 invisible a
139+
9 NULL 1
140+
ALTER table t1 add hid int default 2;
141+
set debug_dbug= "+d,test_completely_invisible";
142+
select * from t1;
143+
a invisible hid
144+
1 NULL 2
145+
select invisible ,a from t1;
146+
invisible a
147+
NULL 1
148+
drop table t1;
149+
set debug_dbug=@old_debug;
150+
Create table t1( a int default(99) invisible, b int);
151+
insert into t1 values(1);
152+
insert into t1 values(2);
153+
insert into t1 values(3);
154+
insert into t1 values(4);
155+
select * from t1 order by b;
156+
b
157+
1
158+
2
159+
3
160+
4
161+
alter table t1 add index(a);
162+
alter table t1 add index(a,b);
163+
show index from t1;
164+
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
165+
t1 1 a 1 a A NULL NULL NULL YES BTREE
166+
t1 1 a_2 1 a A NULL NULL NULL YES BTREE
167+
t1 1 a_2 2 b A NULL NULL NULL YES BTREE
168+
drop table t1;
169+
set debug_dbug= "+d,test_pseudo_invisible";
170+
Create table t1( a int default(99) invisible, b int);
171+
Create table t2( a int default(99) invisible, b int, unique(invisible));
172+
ERROR 42000: Key column 'invisible' doesn't exist in table
173+
set debug_dbug=@old_debug;
174+
insert into t1 values(1);
175+
insert into t1 values(2);
176+
insert into t1 values(3);
177+
insert into t1 values(4);
178+
select * from t1 order by b;
179+
b
180+
1
181+
2
182+
3
183+
4
184+
select invisible, a, b from t1 order by b;
185+
invisible a b
186+
9 99 1
187+
9 99 2
188+
9 99 3
189+
9 99 4
190+
alter table t1 add index(invisible);
191+
ERROR 42000: Key column 'invisible' doesn't exist in table
192+
alter table t1 add index(b,invisible);
193+
ERROR 42000: Key column 'invisible' doesn't exist in table
194+
show index from t1;
195+
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
196+
drop table t1;
197+
set debug_dbug= "+d,test_completely_invisible";
198+
Create table t1( a int default(99) invisible, b int);
199+
Create table t2( a int default(99) invisible, b int, unique(invisible));
200+
ERROR 42000: Key column 'invisible' doesn't exist in table
201+
insert into t1 values(1);
202+
insert into t1 values(2);
203+
insert into t1 values(3);
204+
insert into t1 values(4);
205+
select * from t1 order by b;
206+
b
207+
1
208+
2
209+
3
210+
4
211+
select invisible, a, b from t1 order by b;
212+
invisible a b
213+
9 99 1
214+
9 99 2
215+
9 99 3
216+
9 99 4
217+
set debug_dbug=@old_debug;
218+
alter table t1 add index(invisible);
219+
ERROR 42000: Key column 'invisible' doesn't exist in table
220+
alter table t1 add index(b,invisible);
221+
ERROR 42000: Key column 'invisible' doesn't exist in table
222+
show index from t1;
223+
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
224+
drop table t1;
225+
set debug_dbug= "+d,test_completely_invisible,test_invisible_index";
226+
Create table t1( a int default(99) , b int,c int, index(b));
227+
set debug_dbug=@old_debug;
228+
Show index from t1;
229+
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
230+
t1 1 b 1 b A NULL NULL NULL YES BTREE
231+
select * from INFORMATION_SCHEMA.STATISTICS where TABLE_SCHEMA ='test' and table_name='t1';
232+
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT
233+
def test t1 1 test b 1 b A NULL NULL NULL YES BTREE
234+
show create table t1;
235+
Table Create Table
236+
t1 CREATE TABLE `t1` (
237+
`a` int(11) DEFAULT 99,
238+
`b` int(11) DEFAULT NULL,
239+
`c` int(11) DEFAULT NULL,
240+
KEY `b` (`b`)
241+
) ENGINE=MyISAM DEFAULT CHARSET=latin1
242+
insert into t1 values(1,1,1);
243+
insert into t1 values(2,2,2);
244+
insert into t1 values(3,3,3);
245+
insert into t1 values(4,4,4);
246+
set debug_dbug= "+d,test_completely_invisible,test_invisible_index";
247+
select invisible, a ,b from t1 order by b;
248+
invisible a b
249+
9 1 1
250+
9 2 2
251+
9 3 3
252+
9 4 4
253+
explain select * from t1 where invisible =9;
254+
id select_type table type possible_keys key key_len ref rows Extra
255+
1 SIMPLE t1 ref invisible invisible 5 const 3
256+
alter table t1 add x int default 3;
257+
select invisible, a ,b from t1;
258+
invisible a b
259+
9 1 1
260+
9 2 2
261+
9 3 3
262+
9 4 4
263+
set debug_dbug=@old_debug;
264+
Show index from t1;
265+
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
266+
t1 1 b 1 b A NULL NULL NULL YES BTREE
267+
create index a1 on t1(invisible);
268+
ERROR 42000: Key column 'invisible' doesn't exist in table
269+
set debug_dbug= "+d,test_completely_invisible,test_invisible_index";
270+
drop index invisible on t1;
271+
ERROR 42000: Can't DROP INDEX `invisible`; check that it exists
272+
explain select * from t1 where invisible =9;
273+
id select_type table type possible_keys key key_len ref rows Extra
274+
1 SIMPLE t1 ref invisible invisible 5 const 3
275+
create index invisible on t1(c);
276+
explain select * from t1 where invisible =9;
277+
id select_type table type possible_keys key key_len ref rows Extra
278+
1 SIMPLE t1 ref invisible_2 invisible_2 5 const 3
279+
show indexes in t1;
280+
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
281+
t1 1 b 1 b A NULL NULL NULL YES BTREE
282+
t1 1 invisible 1 c A NULL NULL NULL YES BTREE
283+
t1 1 invisible_2 1 invisible A NULL NULL NULL YES BTREE
284+
drop table t1;
285+
set @old_debug= @@debug_dbug;

0 commit comments

Comments
 (0)