Debian Codegraph @

mysql-test/suite/vcol/r/vcol_view_myisam.result

raw
1 SET @@session.default_storage_engine = 'MyISAM';
2 create table t1 (a int not null,
3 b int as (-a),
4 c int as (-a) persistent);
5 insert into t1 (a) values (1), (1), (2), (2), (3);
6 create view v1 (d,e) as select abs(b), abs(c) from t1;
7 select d,e from v1;
8 d e
9 1 1
10 1 1
11 2 2
12 2 2
13 3 3
14 select is_updatable from information_schema.views where table_name='v1';
15 is_updatable
16 NO
17 explain extended select d,e from v1;
18 id select_type table type possible_keys key key_len ref rows filtered Extra
19 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
20 Warnings:
21 Note 1003 select abs(`test`.`t1`.`b`) AS `d`,abs(`test`.`t1`.`c`) AS `e` from `test`.`t1`
22 create algorithm=temptable view v2 (d,e) as select abs(b), abs(c) from t1;
23 show create view v2;
24 View Create View character_set_client collation_connection
25 v2 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select abs(`t1`.`b`) AS `d`,abs(`t1`.`c`) AS `e` from `t1` latin1 latin1_swedish_ci
26 select d,e from v2;
27 d e
28 1 1
29 1 1
30 2 2
31 2 2
32 3 3
33 explain extended select d,e from v2;
34 id select_type table type possible_keys key key_len ref rows filtered Extra
35 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5 100.00
36 2 DERIVED t1 ALL NULL NULL NULL NULL 5 100.00
37 Warnings:
38 Note 1003 /* select#1 */ select `v2`.`d` AS `d`,`v2`.`e` AS `e` from `test`.`v2`
39 create view v3 (d,e) as select d*2, e*2 from v1;
40 select * from v3;
41 d e
42 2 2
43 2 2
44 4 4
45 4 4
46 6 6
47 explain extended select * from v3;
48 id select_type table type possible_keys key key_len ref rows filtered Extra
49 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
50 Warnings:
51 Note 1003 select abs(`test`.`t1`.`b`) * 2 AS `d`,abs(`test`.`t1`.`c`) * 2 AS `e` from `test`.`t1`
52 drop view v1,v2,v3;
53 drop table t1;
54 create table t1 (a int not null,
55 b int as (-a),
56 c int as (-a) persistent);
57 insert into t1 (a) values (1), (2), (3), (1), (2), (3);
58 create view v1 as select distinct b from t1;
59 select * from v1;
60 b
61 -1
62 -2
63 -3
64 explain select * from v1;
65 id select_type table type possible_keys key key_len ref rows Extra
66 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6
67 2 DERIVED t1 ALL NULL NULL NULL NULL 6 Using temporary
68 select * from t1;
69 a b c
70 1 -1 -1
71 2 -2 -2
72 3 -3 -3
73 1 -1 -1
74 2 -2 -2
75 3 -3 -3
76 drop view v1;
77 create view v1 as select distinct c from t1;
78 select * from v1;
79 c
80 -1
81 -2
82 -3
83 explain select * from v1;
84 id select_type table type possible_keys key key_len ref rows Extra
85 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6
86 2 DERIVED t1 ALL NULL NULL NULL NULL 6 Using temporary
87 select * from t1;
88 a b c
89 1 -1 -1
90 2 -2 -2
91 3 -3 -3
92 1 -1 -1
93 2 -2 -2
94 3 -3 -3
95 drop view v1;
96 drop table t1;
97 create table t1 (a int not null,
98 b int as (-a),
99 c int as (-a) persistent);
100 insert into t1 (a) values (1), (2), (3), (4);
101 create view v1 as select b+1 from t1 order by 1 desc limit 2;
102 select * from v1;
103 b+1
104 0
105 -1
106 MariaDB-5.3: the following EXPLAIN produces incorrect #rows for table t1.
107 MariaDB-5.3: this is expected to go away when FROM subquery optimizations are pushed
108 explain select * from v1;
109 id select_type table type possible_keys key key_len ref rows Extra
110 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
111 2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
112 drop view v1;
113 create view v1 as select c+1 from t1 order by 1 desc limit 2;
114 select * from v1;
115 c+1
116 0
117 -1
118 MariaDB-5.3: the following EXPLAIN produces incorrect #rows for table t1.
119 MariaDB-5.3: this is expected to go away when FROM subquery optimizations are pushed
120 explain select * from v1;
121 id select_type table type possible_keys key key_len ref rows Extra
122 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
123 2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
124 drop view v1;
125 drop table t1;
126 create table t1 (a int,
127 b int,
128 c int as (-a),
129 d int as (-a) persistent,
130 primary key(a));
131 insert into t1 (a,b) values (10,2), (20,3), (30,4), (40,5), (50,10);
132 create view v1 (a,e,f,g) as select a, b+1,c+1,d+1 from t1;
133 update v1 set a=a+e;
134 select * from v1;
135 a e f g
136 13 3 -12 -12
137 24 4 -23 -23
138 35 5 -34 -34
139 46 6 -45 -45
140 61 11 -60 -60
141 select * from t1;
142 a b c d
143 13 2 -13 -13
144 24 3 -24 -24
145 35 4 -35 -35
146 46 5 -46 -46
147 61 10 -61 -61
148 delete from v1;
149 select * from v1;
150 a e f g
151 select * from t1;
152 a b c d
153 insert into v1 (a,e) values (60,15);
154 ERROR HY000: The target table v1 of the INSERT is not insertable-into
155 drop table t1;
156 drop view v1;
157 SET @save_optimizer_switch=@@optimizer_switch;
158 SET optimizer_switch='outer_join_with_cache=off';
159 create table t1 (a int,
160 b int as (-a),
161 c int as (-a) persistent,
162 primary key(a));
163 insert into t1 (a) values (1), (2), (3);
164 create view v1 (x,y,z) as select a,b,c from t1 where b < -1;
165 select t1.a, v1.x, v1.y, v1.z from t1 left join v1 on (t1.b= v1.y);
166 a x y z
167 1 NULL NULL NULL
168 2 2 -2 -2
169 3 3 -3 -3
170 drop view v1;
171 create view v1 (x,y,z) as select a,b,c from t1 where c < -1;
172 select t1.a, v1.x, v1.y, v1.z from t1 left join v1 on (t1.c= v1.z);
173 a x y z
174 1 NULL NULL NULL
175 2 2 -2 -2
176 3 3 -3 -3
177 drop view v1;
178 drop table t1;
179 SET optimizer_switch=@save_optimizer_switch;
180 create table t1 (a1 int,
181 b1 int as (-a1),
182 c1 int as (-a1) persistent);
183 create table t2 (a2 int,
184 b2 int as (-a2),
185 c2 int as (-a2) persistent);
186 insert into t1 (a1) values (1), (2);
187 insert into t2 (a2) values (2), (3);
188 create view v1 as select * from t1,t2 union all select * from t1,t2;
189 select * from v1;
190 a1 b1 c1 a2 b2 c2
191 1 -1 -1 2 -2 -2
192 2 -2 -2 2 -2 -2
193 1 -1 -1 3 -3 -3
194 2 -2 -2 3 -3 -3
195 1 -1 -1 2 -2 -2
196 2 -2 -2 2 -2 -2
197 1 -1 -1 3 -3 -3
198 2 -2 -2 3 -3 -3
199 drop view v1;
200 drop table t1, t2;
201 create table t1 (a int,
202 b int as (-a),
203 c int as (-a) persistent);
204 create table t2 like t1;
205 create view v1 as select a,b,c from t1;
206 create view v2 as select a,b,c from t2 where b in (select b from v1);
207 show create view v2;
208 View Create View character_set_client collation_connection
209 v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t2`.`a` AS `a`,`t2`.`b` AS `b`,`t2`.`c` AS `c` from `t2` where `t2`.`b` in (select `v1`.`b` from `v1`) latin1 latin1_swedish_ci
210 drop view v2, v1;
211 drop table t1, t2;
212 create table t1 (a int,
213 b int as (-a),
214 c int as (-a) persistent);
215 insert into t1 (a) values (1),(1),(2),(2),(3),(3);
216 create view v1 as select b from t1;
217 select distinct b from v1;
218 b
219 -1
220 -2
221 -3
222 select distinct b from v1 limit 2;
223 b
224 -1
225 -2
226 select distinct b from t1 limit 2;
227 b
228 -1
229 -2
230 prepare stmt1 from "select distinct b from v1 limit 2";
231 execute stmt1;
232 b
233 -1
234 -2
235 execute stmt1;
236 b
237 -1
238 -2
239 deallocate prepare stmt1;
240 drop view v1;
241 create view v1 as select c from t1;
242 select distinct c from v1;
243 c
244 -1
245 -2
246 -3
247 select distinct c from v1 limit 2;
248 c
249 -1
250 -2
251 select distinct c from t1 limit 2;
252 c
253 -1
254 -2
255 prepare stmt1 from "select distinct c from v1 limit 2";
256 execute stmt1;
257 c
258 -1
259 -2
260 execute stmt1;
261 c
262 -1
263 -2
264 deallocate prepare stmt1;
265 drop view v1;
266 drop table t1;
267 create table t1 (a int,
268 b int as (-a),
269 c int as (-a) persistent);
270 create view v1 as select * from t1 where b > -2 && c >-2 with check option;
271 insert into v1 (a) values (1);
272 insert into v1 (a) values (3);
273 ERROR 44000: CHECK OPTION failed `test`.`v1`
274 insert ignore into v1 (a) values (2),(3),(0);
275 Warnings:
276 Warning 1369 CHECK OPTION failed `test`.`v1`
277 Warning 1369 CHECK OPTION failed `test`.`v1`
278 select * from t1;
279 a b c
280 1 -1 -1
281 0 0 0
282 drop view v1;
283 drop table t1;