~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

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