~ubuntu-branches/ubuntu/trusty/mariadb-5.5/trusty-proposed

« back to all changes in this revision

Viewing changes to mysql-test/r/sp-dynamic.result

  • Committer: Package Import Robot
  • Author(s): Otto Kekäläinen
  • Date: 2013-12-22 10:27:05 UTC
  • Revision ID: package-import@ubuntu.com-20131222102705-mndw7s12mz0szrcn
Tags: upstream-5.5.32
Import upstream version 5.5.32

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
drop procedure if exists p1|
 
2
drop procedure if exists p2|
 
3
create procedure p1()
 
4
begin
 
5
prepare stmt from "select 1";
 
6
execute stmt;
 
7
execute stmt;
 
8
execute stmt;
 
9
deallocate prepare stmt;
 
10
end|
 
11
call p1()|
 
12
1
 
13
1
 
14
1
 
15
1
 
16
1
 
17
1
 
18
call p1()|
 
19
1
 
20
1
 
21
1
 
22
1
 
23
1
 
24
1
 
25
call p1()|
 
26
1
 
27
1
 
28
1
 
29
1
 
30
1
 
31
1
 
32
drop procedure p1|
 
33
create procedure p1()
 
34
begin
 
35
execute stmt;
 
36
end|
 
37
prepare stmt from "call p1()"|
 
38
set @SAVE_SP_RECURSION_LEVELS=@@max_sp_recursion_depth|
 
39
set @@max_sp_recursion_depth=100|
 
40
execute stmt|
 
41
ERROR HY000: The prepared statement contains a stored routine call that refers to that same statement. It's not allowed to execute a prepared statement in such a recursive manner
 
42
execute stmt|
 
43
ERROR HY000: The prepared statement contains a stored routine call that refers to that same statement. It's not allowed to execute a prepared statement in such a recursive manner
 
44
execute stmt|
 
45
ERROR HY000: The prepared statement contains a stored routine call that refers to that same statement. It's not allowed to execute a prepared statement in such a recursive manner
 
46
call p1()|
 
47
ERROR HY000: The prepared statement contains a stored routine call that refers to that same statement. It's not allowed to execute a prepared statement in such a recursive manner
 
48
call p1()|
 
49
ERROR HY000: The prepared statement contains a stored routine call that refers to that same statement. It's not allowed to execute a prepared statement in such a recursive manner
 
50
call p1()|
 
51
ERROR HY000: The prepared statement contains a stored routine call that refers to that same statement. It's not allowed to execute a prepared statement in such a recursive manner
 
52
set @@max_sp_recursion_depth=@SAVE_SP_RECURSION_LEVELS|
 
53
call p1()|
 
54
ERROR HY000: Recursive limit 0 (as set by the max_sp_recursion_depth variable) was exceeded for routine p1
 
55
call p1()|
 
56
ERROR HY000: Recursive limit 0 (as set by the max_sp_recursion_depth variable) was exceeded for routine p1
 
57
call p1()|
 
58
ERROR HY000: Recursive limit 0 (as set by the max_sp_recursion_depth variable) was exceeded for routine p1
 
59
drop procedure p1|
 
60
create procedure p1()
 
61
begin
 
62
prepare stmt from "create procedure p2() begin select 1; end";
 
63
execute stmt;
 
64
deallocate prepare stmt;
 
65
end|
 
66
call p1()|
 
67
ERROR HY000: This command is not supported in the prepared statement protocol yet
 
68
call p1()|
 
69
ERROR HY000: This command is not supported in the prepared statement protocol yet
 
70
drop procedure p1|
 
71
create procedure p1()
 
72
begin
 
73
prepare stmt from "drop procedure p2";
 
74
execute stmt;
 
75
deallocate prepare stmt;
 
76
end|
 
77
call p1()|
 
78
ERROR HY000: This command is not supported in the prepared statement protocol yet
 
79
call p1()|
 
80
ERROR HY000: This command is not supported in the prepared statement protocol yet
 
81
drop procedure p1|
 
82
create procedure p1()
 
83
begin
 
84
prepare stmt_drop from "drop table if exists t1";
 
85
execute stmt_drop;
 
86
prepare stmt from "create table t1 (a int)";
 
87
execute stmt;
 
88
insert into t1 (a) values (1);
 
89
select * from t1;
 
90
prepare stmt_alter from "alter table t1 add (b int)";
 
91
execute stmt_alter;
 
92
insert into t1 (a,b) values (2,1);
 
93
deallocate prepare stmt_alter;
 
94
deallocate prepare stmt;
 
95
deallocate prepare stmt_drop;
 
96
end|
 
97
call p1()|
 
98
a
 
99
1
 
100
call p1()|
 
101
a
 
102
1
 
103
drop procedure p1|
 
104
create procedure p1()
 
105
begin
 
106
set @tab_name=concat("tab_", replace(curdate(), '-', '_'));
 
107
set @drop_sql=concat("drop table if exists ", @tab_name);
 
108
set @create_sql=concat("create table ", @tab_name, " (a int)");
 
109
set @insert_sql=concat("insert into ", @tab_name, " values (1), (2), (3)");
 
110
set @select_sql=concat("select * from ", @tab_name); 
 
111
select @tab_name;
 
112
select @drop_sql;
 
113
select @create_sql;
 
114
select @insert_sql;
 
115
select @select_sql;
 
116
prepare stmt_drop from @drop_sql;
 
117
execute stmt_drop;
 
118
prepare stmt from @create_sql;
 
119
execute stmt;
 
120
prepare stmt from @insert_sql;
 
121
execute stmt;
 
122
prepare stmt from @select_sql;
 
123
execute stmt;
 
124
execute stmt_drop;
 
125
deallocate prepare stmt;
 
126
deallocate prepare stmt_drop;
 
127
end|
 
128
call p1()|
 
129
call p1()|
 
130
drop procedure p1|
 
131
create procedure p1()
 
132
begin
 
133
prepare stmt_drop from "drop table if exists t1";
 
134
execute stmt_drop;
 
135
prepare stmt from "create table t1 (a int)";
 
136
execute stmt;
 
137
deallocate prepare stmt;
 
138
deallocate prepare stmt_drop;
 
139
end|
 
140
drop function if exists f1|
 
141
create function f1(a int) returns int
 
142
begin
 
143
call p1();
 
144
return 1;
 
145
end|
 
146
select f1(0)|
 
147
ERROR 0A000: Dynamic SQL is not allowed in stored function or trigger
 
148
select f1(f1(0))|
 
149
ERROR 0A000: Dynamic SQL is not allowed in stored function or trigger
 
150
select f1(f1(f1(0)))|
 
151
ERROR 0A000: Dynamic SQL is not allowed in stored function or trigger
 
152
drop function f1|
 
153
drop procedure p1|
 
154
create procedure p1()
 
155
begin
 
156
drop table if exists t1;
 
157
create table t1 (id integer not null primary key,
 
158
name varchar(20) not null);
 
159
insert into t1 (id, name) values (1, 'aaa'), (2, 'bbb'), (3, 'ccc');
 
160
prepare stmt from "select name from t1";
 
161
execute stmt;
 
162
select name from t1;
 
163
execute stmt;
 
164
prepare stmt from
 
165
"select name from t1 where name=(select name from t1 where id=2)";
 
166
execute stmt;
 
167
select name from t1 where name=(select name from t1 where id=2);
 
168
execute stmt;
 
169
end|
 
170
call p1()|
 
171
name
 
172
aaa
 
173
bbb
 
174
ccc
 
175
name
 
176
aaa
 
177
bbb
 
178
ccc
 
179
name
 
180
aaa
 
181
bbb
 
182
ccc
 
183
name
 
184
bbb
 
185
name
 
186
bbb
 
187
name
 
188
bbb
 
189
call p1()|
 
190
name
 
191
aaa
 
192
bbb
 
193
ccc
 
194
name
 
195
aaa
 
196
bbb
 
197
ccc
 
198
name
 
199
aaa
 
200
bbb
 
201
ccc
 
202
name
 
203
bbb
 
204
name
 
205
bbb
 
206
name
 
207
bbb
 
208
drop procedure p1|
 
209
prepare stmt from "select * from t1"|
 
210
create procedure p1()
 
211
begin
 
212
execute stmt;
 
213
deallocate prepare stmt;
 
214
end|
 
215
call p1()|
 
216
id      name
 
217
1       aaa
 
218
2       bbb
 
219
3       ccc
 
220
call p1()|
 
221
ERROR HY000: Unknown prepared statement handler (stmt) given to EXECUTE
 
222
drop procedure p1|
 
223
create procedure p1()
 
224
begin
 
225
declare a char(10);
 
226
set a="sp-variable";
 
227
set @a="mysql-variable";
 
228
prepare stmt from "select 'dynamic sql:', @a, a";
 
229
execute stmt;
 
230
end|
 
231
call p1()|
 
232
ERROR 42S22: Unknown column 'a' in 'field list'
 
233
call p1()|
 
234
ERROR 42S22: Unknown column 'a' in 'field list'
 
235
drop procedure p1|
 
236
create procedure p1()
 
237
begin
 
238
prepare stmt from 'select ? as a';
 
239
execute stmt using @a;
 
240
end|
 
241
set @a=1|
 
242
call p1()|
 
243
a
 
244
1
 
245
call p1()|
 
246
a
 
247
1
 
248
drop procedure p1|
 
249
drop table if exists t1|
 
250
drop table if exists t2|
 
251
Warnings:
 
252
Note    1051    Unknown table 't2'
 
253
create table t1 (id integer primary key auto_increment,
 
254
stmt_text char(35), status varchar(20))|
 
255
insert into t1 (stmt_text) values
 
256
("select 1"), ("flush tables"), ("handler t1 open as ha"), 
 
257
("analyze table t1"), ("check table t1"), ("checksum table t1"),
 
258
("check table t1"), ("optimize table t1"), ("repair table t1"),
 
259
("describe extended select * from t1"),
 
260
("help help"), ("show databases"), ("show tables"),
 
261
("show table status"), ("show open tables"), ("show storage engines"),
 
262
("insert into t1 (id) values (1)"), ("update t1 set status=''"),
 
263
("delete from t1"), ("truncate t1"), ("call p1()"), ("foo bar"),
 
264
("create view v1 as select 1"), ("alter view v1 as select 2"),
 
265
("drop view v1"),("create table t2 (a int)"),("alter table t2 add (b int)"),
 
266
("drop table t2")|
 
267
create procedure p1()
 
268
begin
 
269
declare v_stmt_text varchar(255);
 
270
declare v_id integer;
 
271
declare done int default 0;
 
272
declare c cursor for select id, stmt_text from t1;
 
273
declare continue handler for 1295 -- ER_UNSUPPORTED_PS
 
274
set @status='not supported';
 
275
declare continue handler for 1064 -- ER_SYNTAX_ERROR
 
276
set @status='syntax error';
 
277
declare continue handler for sqlstate '02000' set done = 1;
 
278
prepare update_stmt from "update t1 set status=? where id=?";
 
279
open c;
 
280
repeat
 
281
if not done then
 
282
fetch c into v_id, v_stmt_text;
 
283
set @id=v_id, @stmt_text=v_stmt_text;
 
284
set @status="supported";
 
285
prepare stmt from @stmt_text;
 
286
execute update_stmt using @status, @id;
 
287
end if;
 
288
until done end repeat;
 
289
deallocate prepare update_stmt;
 
290
end|
 
291
call p1()|
 
292
select * from t1|
 
293
id      stmt_text       status
 
294
1       select 1        supported
 
295
2       flush tables    supported
 
296
3       handler t1 open as ha   not supported
 
297
4       analyze table t1        supported
 
298
5       check table t1  not supported
 
299
6       checksum table t1       supported
 
300
7       check table t1  not supported
 
301
8       optimize table t1       supported
 
302
9       repair table t1 supported
 
303
10      describe extended select * from t1      supported
 
304
11      help help       not supported
 
305
12      show databases  supported
 
306
13      show tables     supported
 
307
14      show table status       supported
 
308
15      show open tables        supported
 
309
16      show storage engines    supported
 
310
17      insert into t1 (id) values (1)  supported
 
311
18      update t1 set status='' supported
 
312
19      delete from t1  supported
 
313
20      truncate t1     supported
 
314
21      call p1()       supported
 
315
22      foo bar syntax error
 
316
23      create view v1 as select 1      supported
 
317
24      alter view v1 as select 2       not supported
 
318
25      drop view v1    supported
 
319
26      create table t2 (a int) supported
 
320
27      alter table t2 add (b int)      supported
 
321
28      drop table t2   supported
 
322
drop procedure p1|
 
323
drop table t1|
 
324
prepare stmt from 'select 1'|
 
325
create procedure p1() execute stmt|
 
326
call p1()|
 
327
1
 
328
1
 
329
call p1()|
 
330
1
 
331
1
 
332
drop procedure p1|
 
333
create function f1() returns int
 
334
begin
 
335
deallocate prepare stmt;
 
336
return 1;
 
337
end|
 
338
ERROR 0A000: Dynamic SQL is not allowed in stored function or trigger
 
339
create procedure p1()
 
340
begin
 
341
prepare stmt from 'select 1 A';
 
342
execute stmt;
 
343
end|
 
344
prepare stmt from 'call p1()'|
 
345
execute stmt|
 
346
ERROR HY000: The prepared statement contains a stored routine call that refers to that same statement. It's not allowed to execute a prepared statement in such a recursive manner
 
347
execute stmt|
 
348
ERROR HY000: The prepared statement contains a stored routine call that refers to that same statement. It's not allowed to execute a prepared statement in such a recursive manner
 
349
drop procedure p1|
 
350
drop table if exists t1, t2|
 
351
create procedure p1 (a int) language sql deterministic
 
352
begin
 
353
declare rsql varchar(100);
 
354
drop table if exists t1, t2;
 
355
set @rsql= "create table t1 (a int)";
 
356
select @rsql;
 
357
prepare pst from @rsql;
 
358
execute pst;
 
359
set @rsql= null;
 
360
set @rsql= "create table t2 (a int)";
 
361
select @rsql;
 
362
prepare pst from @rsql;
 
363
execute pst;
 
364
drop table if exists t1, t2;
 
365
end|
 
366
set @a:=0|
 
367
call p1(@a)|
 
368
@rsql
 
369
create table t1 (a int)
 
370
@rsql
 
371
create table t2 (a int)
 
372
select @a|
 
373
@a
 
374
0
 
375
call p1(@a)|
 
376
@rsql
 
377
create table t1 (a int)
 
378
@rsql
 
379
create table t2 (a int)
 
380
select @a|
 
381
@a
 
382
0
 
383
drop procedure if exists p1|