PageRenderTime 60ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/mysql-server/mysql/mysql-test/r/sp-error.result

http://isiworld.googlecode.com/
Unknown | 2010 lines | 1997 code | 13 blank | 0 comment | 0 complexity | 532cbd4fcefcd300d695ded6ca9a46f4 MD5 | raw file
Possible License(s): GPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. drop table if exists t1, t2;
  2. SELECT * FROM mysql.proc INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/proc.txt';
  3. delete from mysql.proc;
  4. create procedure syntaxerror(t int)|
  5. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
  6. create procedure syntaxerror(t int)|
  7. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
  8. create procedure syntaxerror(t int)|
  9. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
  10. drop table if exists t3|
  11. create table t3 ( x int )|
  12. insert into t3 values (2), (3)|
  13. create procedure bad_into(out param int)
  14. select x from t3 into param|
  15. call bad_into(@x)|
  16. ERROR 42000: Result consisted of more than one row
  17. drop procedure bad_into|
  18. drop table t3|
  19. create procedure proc1()
  20. set @x = 42|
  21. create function func1() returns int
  22. return 42|
  23. create procedure foo()
  24. create procedure bar() set @x=3|
  25. ERROR 2F003: Can't create a PROCEDURE from within another stored routine
  26. create procedure foo()
  27. create function bar() returns double return 2.3|
  28. ERROR 2F003: Can't create a FUNCTION from within another stored routine
  29. create procedure proc1()
  30. set @x = 42|
  31. ERROR 42000: PROCEDURE proc1 already exists
  32. create function func1() returns int
  33. return 42|
  34. ERROR 42000: FUNCTION func1 already exists
  35. drop procedure proc1|
  36. drop function func1|
  37. alter procedure foo|
  38. ERROR 42000: PROCEDURE test.foo does not exist
  39. alter function foo|
  40. ERROR 42000: FUNCTION test.foo does not exist
  41. drop procedure foo|
  42. ERROR 42000: PROCEDURE test.foo does not exist
  43. drop function foo|
  44. ERROR 42000: FUNCTION test.foo does not exist
  45. call foo()|
  46. ERROR 42000: PROCEDURE test.foo does not exist
  47. drop procedure if exists foo|
  48. Warnings:
  49. Note 1305 PROCEDURE test.foo does not exist
  50. show create procedure foo|
  51. ERROR 42000: PROCEDURE foo does not exist
  52. show create function foo|
  53. ERROR 42000: FUNCTION foo does not exist
  54. create procedure foo()
  55. foo: loop
  56. leave bar;
  57. end loop|
  58. ERROR 42000: LEAVE with no matching label: bar
  59. create procedure foo()
  60. foo: loop
  61. iterate bar;
  62. end loop|
  63. ERROR 42000: ITERATE with no matching label: bar
  64. create procedure foo()
  65. foo: begin
  66. iterate foo;
  67. end|
  68. ERROR 42000: ITERATE with no matching label: foo
  69. create procedure foo()
  70. foo: loop
  71. foo: loop
  72. set @x=2;
  73. end loop foo;
  74. end loop foo|
  75. ERROR 42000: Redefining label foo
  76. create procedure foo()
  77. foo: loop
  78. set @x=2;
  79. end loop bar|
  80. ERROR 42000: End-label bar without match
  81. create procedure foo()
  82. return 42|
  83. ERROR 42000: RETURN is only allowed in a FUNCTION
  84. create procedure p(x int)
  85. set @x = x|
  86. create function f(x int) returns int
  87. return x+42|
  88. call p()|
  89. ERROR 42000: Incorrect number of arguments for PROCEDURE test.p; expected 1, got 0
  90. call p(1, 2)|
  91. ERROR 42000: Incorrect number of arguments for PROCEDURE test.p; expected 1, got 2
  92. select f()|
  93. ERROR 42000: Incorrect number of arguments for FUNCTION test.f; expected 1, got 0
  94. select f(1, 2)|
  95. ERROR 42000: Incorrect number of arguments for FUNCTION test.f; expected 1, got 2
  96. drop procedure p|
  97. drop function f|
  98. create procedure p(val int, out res int)
  99. begin
  100. declare x int default 0;
  101. declare continue handler for foo set x = 1;
  102. insert into test.t1 values (val);
  103. if (x) then
  104. set res = 0;
  105. else
  106. set res = 1;
  107. end if;
  108. end|
  109. ERROR 42000: Undefined CONDITION: foo
  110. create procedure p(val int, out res int)
  111. begin
  112. declare x int default 0;
  113. declare foo condition for 1146;
  114. declare continue handler for bar set x = 1;
  115. insert into test.t1 values (val);
  116. if (x) then
  117. set res = 0;
  118. else
  119. set res = 1;
  120. end if;
  121. end|
  122. ERROR 42000: Undefined CONDITION: bar
  123. create function f(val int) returns int
  124. begin
  125. declare x int;
  126. set x = val+3;
  127. end|
  128. ERROR 42000: No RETURN found in FUNCTION test.f
  129. create function f(val int) returns int
  130. begin
  131. declare x int;
  132. set x = val+3;
  133. if x < 4 then
  134. return x;
  135. end if;
  136. end|
  137. select f(10)|
  138. ERROR 2F005: FUNCTION f ended without RETURN
  139. drop function f|
  140. create procedure p()
  141. begin
  142. declare c cursor for insert into test.t1 values ("foo", 42);
  143. open c;
  144. close c;
  145. end|
  146. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'insert into test.t1 values ("foo", 42);
  147. open c;
  148. close c;
  149. end' at line 3
  150. create procedure p()
  151. begin
  152. declare x int;
  153. declare c cursor for select * into x from test.t limit 1;
  154. open c;
  155. close c;
  156. end|
  157. ERROR 42000: Cursor SELECT must not have INTO
  158. create procedure p()
  159. begin
  160. declare c cursor for select * from test.t;
  161. open cc;
  162. close c;
  163. end|
  164. ERROR 42000: Undefined CURSOR: cc
  165. drop table if exists t1|
  166. create table t1 (val int)|
  167. create procedure p()
  168. begin
  169. declare c cursor for select * from test.t1;
  170. open c;
  171. open c;
  172. close c;
  173. end|
  174. call p()|
  175. ERROR 24000: Cursor is already open
  176. drop procedure p|
  177. create procedure p()
  178. begin
  179. declare c cursor for select * from test.t1;
  180. open c;
  181. close c;
  182. close c;
  183. end|
  184. call p()|
  185. ERROR 24000: Cursor is not open
  186. drop procedure p|
  187. alter procedure bar3 sql security invoker|
  188. ERROR 42000: PROCEDURE test.bar3 does not exist
  189. drop table t1|
  190. drop table if exists t1|
  191. create table t1 (val int, x float)|
  192. insert into t1 values (42, 3.1), (19, 1.2)|
  193. create procedure p()
  194. begin
  195. declare x int;
  196. declare c cursor for select * from t1;
  197. open c;
  198. fetch c into x, y;
  199. close c;
  200. end|
  201. ERROR 42000: Undeclared variable: y
  202. create procedure p()
  203. begin
  204. declare x int;
  205. declare c cursor for select * from t1;
  206. open c;
  207. fetch c into x;
  208. close c;
  209. end|
  210. call p()|
  211. ERROR HY000: Incorrect number of FETCH variables
  212. drop procedure p|
  213. create procedure p()
  214. begin
  215. declare x int;
  216. declare y float;
  217. declare z int;
  218. declare c cursor for select * from t1;
  219. open c;
  220. fetch c into x, y, z;
  221. close c;
  222. end|
  223. call p()|
  224. ERROR HY000: Incorrect number of FETCH variables
  225. drop procedure p|
  226. create procedure p(in x int, x char(10))
  227. begin
  228. end|
  229. ERROR 42000: Duplicate parameter: x
  230. create function p(x int, x char(10))
  231. begin
  232. end|
  233. ERROR 42000: Duplicate parameter: x
  234. create procedure p()
  235. begin
  236. declare x float;
  237. declare x int;
  238. end|
  239. ERROR 42000: Duplicate variable: x
  240. create procedure p()
  241. begin
  242. declare c condition for 1064;
  243. declare c condition for 1065;
  244. end|
  245. ERROR 42000: Duplicate condition: c
  246. create procedure p()
  247. begin
  248. declare c cursor for select * from t1;
  249. declare c cursor for select field from t1;
  250. end|
  251. ERROR 42000: Duplicate cursor: c
  252. create procedure u()
  253. use sptmp|
  254. ERROR 0A000: USE is not allowed in stored procedures
  255. create procedure p()
  256. begin
  257. declare c cursor for select * from t1;
  258. declare x int;
  259. end|
  260. ERROR 42000: Variable or condition declaration after cursor or handler declaration
  261. create procedure p()
  262. begin
  263. declare x int;
  264. declare continue handler for sqlstate '42S99' set x = 1;
  265. declare foo condition for sqlstate '42S99';
  266. end|
  267. ERROR 42000: Variable or condition declaration after cursor or handler declaration
  268. create procedure p()
  269. begin
  270. declare x int;
  271. declare continue handler for sqlstate '42S99' set x = 1;
  272. declare c cursor for select * from t1;
  273. end|
  274. ERROR 42000: Cursor declaration after handler declaration
  275. drop procedure if exists p|
  276. create procedure p(in x int, inout y int, out z int)
  277. begin
  278. set y = x+y;
  279. set z = x+y;
  280. end|
  281. set @tmp_x = 42|
  282. set @tmp_y = 3|
  283. set @tmp_z = 0|
  284. call p(@tmp_x, @tmp_y, @tmp_z)|
  285. select @tmp_x, @tmp_y, @tmp_z|
  286. @tmp_x @tmp_y @tmp_z
  287. 42 45 87
  288. call p(42, 43, @tmp_z)|
  289. ERROR 42000: OUT or INOUT argument 2 for routine test.p is not a variable or NEW pseudo-variable in BEFORE trigger
  290. call p(42, @tmp_y, 43)|
  291. ERROR 42000: OUT or INOUT argument 3 for routine test.p is not a variable or NEW pseudo-variable in BEFORE trigger
  292. drop procedure p|
  293. create procedure p() begin end|
  294. lock table t1 read|
  295. call p()|
  296. unlock tables|
  297. drop procedure p|
  298. lock tables t1 read, mysql.proc write|
  299. ERROR HY000: You can't combine write-locking of system tables with other tables or lock types
  300. lock tables mysql.proc write, mysql.user write|
  301. ERROR HY000: You can't combine write-locking of system tables with other tables or lock types
  302. lock tables t1 read, mysql.proc read|
  303. unlock tables|
  304. lock tables mysql.proc write|
  305. unlock tables|
  306. drop function if exists f1|
  307. create function f1(i int) returns int
  308. begin
  309. insert into t1 (val) values (i);
  310. return 0;
  311. end|
  312. select val, f1(val) from t1|
  313. ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
  314. select val, f1(val) from t1 as tab|
  315. ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
  316. select * from t1|
  317. val x
  318. 42 3.1
  319. 19 1.2
  320. update t1 set val= f1(val)|
  321. ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
  322. select * from t1|
  323. val x
  324. 42 3.1
  325. 19 1.2
  326. select f1(17)|
  327. f1(17)
  328. 0
  329. select * from t1|
  330. val x
  331. 42 3.1
  332. 19 1.2
  333. 17 NULL
  334. delete from t1 where val= 17|
  335. drop function f1|
  336. create procedure bug1965()
  337. begin
  338. declare c cursor for select val from t1 order by valname;
  339. open c;
  340. close c;
  341. end|
  342. call bug1965()|
  343. ERROR 42S22: Unknown column 'valname' in 'order clause'
  344. drop procedure bug1965|
  345. select 1 into a|
  346. ERROR 42000: Undeclared variable: a
  347. drop table if exists t3|
  348. create table t3 (column_1_0 int)|
  349. create procedure bug1653()
  350. update t3 set column_1 = 0|
  351. call bug1653()|
  352. ERROR 42S22: Unknown column 'column_1' in 'field list'
  353. drop table t3|
  354. create table t3 (column_1 int)|
  355. call bug1653()|
  356. drop procedure bug1653|
  357. drop table t3|
  358. create procedure bug2259()
  359. begin
  360. declare v1 int;
  361. declare c1 cursor for select s1 from t1;
  362. fetch c1 into v1;
  363. end|
  364. call bug2259()|
  365. ERROR 24000: Cursor is not open
  366. drop procedure bug2259|
  367. create procedure bug2272()
  368. begin
  369. declare v int;
  370. update t1 set v = 42;
  371. end|
  372. insert into t1 values (666, 51.3)|
  373. call bug2272()|
  374. ERROR 42S22: Unknown column 'v' in 'field list'
  375. truncate table t1|
  376. drop procedure bug2272|
  377. create procedure bug2329_1()
  378. begin
  379. declare v int;
  380. insert into t1 (v) values (5);
  381. end|
  382. create procedure bug2329_2()
  383. begin
  384. declare v int;
  385. replace t1 set v = 5;
  386. end|
  387. call bug2329_1()|
  388. ERROR 42S22: Unknown column 'v' in 'field list'
  389. call bug2329_2()|
  390. ERROR 42S22: Unknown column 'v' in 'field list'
  391. drop procedure bug2329_1|
  392. drop procedure bug2329_2|
  393. create function bug3287() returns int
  394. begin
  395. declare v int default null;
  396. case
  397. when v is not null then return 1;
  398. end case;
  399. return 2;
  400. end|
  401. select bug3287()|
  402. ERROR 20000: Case not found for CASE statement
  403. drop function bug3287|
  404. create procedure bug3287(x int)
  405. case x
  406. when 0 then
  407. insert into test.t1 values (x, 0.1);
  408. when 1 then
  409. insert into test.t1 values (x, 1.1);
  410. end case|
  411. call bug3287(2)|
  412. ERROR 20000: Case not found for CASE statement
  413. drop procedure bug3287|
  414. drop table if exists t3|
  415. create table t3 (s1 int, primary key (s1))|
  416. insert into t3 values (5),(6)|
  417. create procedure bug3279(out y int)
  418. begin
  419. declare x int default 0;
  420. begin
  421. declare exit handler for sqlexception set x = x+1;
  422. insert into t3 values (5);
  423. end;
  424. if x < 2 then
  425. set x = x+1;
  426. insert into t3 values (6);
  427. end if;
  428. set y = x;
  429. end|
  430. set @x = 0|
  431. call bug3279(@x)|
  432. ERROR 23000: Duplicate entry '6' for key 'PRIMARY'
  433. select @x|
  434. @x
  435. 0
  436. drop procedure bug3279|
  437. drop table t3|
  438. create procedure nodb.bug3339() begin end|
  439. ERROR 42000: Unknown database 'nodb'
  440. create procedure bug2653_1(a int, out b int)
  441. set b = aa|
  442. create procedure bug2653_2(a int, out b int)
  443. begin
  444. if aa < 0 then
  445. set b = - a;
  446. else
  447. set b = a;
  448. end if;
  449. end|
  450. call bug2653_1(1, @b)|
  451. ERROR 42S22: Unknown column 'aa' in 'field list'
  452. call bug2653_2(2, @b)|
  453. ERROR 42S22: Unknown column 'aa' in 'field list'
  454. drop procedure bug2653_1|
  455. drop procedure bug2653_2|
  456. create procedure bug4344() drop procedure bug4344|
  457. ERROR HY000: Can't drop or alter a PROCEDURE from within another stored routine
  458. create procedure bug4344() drop function bug4344|
  459. ERROR HY000: Can't drop or alter a FUNCTION from within another stored routine
  460. drop procedure if exists bug3294|
  461. create procedure bug3294()
  462. begin
  463. declare continue handler for sqlexception drop table t5;
  464. drop table t5;
  465. drop table t5;
  466. end|
  467. create table t5 (x int)|
  468. call bug3294()|
  469. ERROR 42S02: Unknown table 't5'
  470. drop procedure bug3294|
  471. drop procedure if exists bug8776_1|
  472. drop procedure if exists bug8776_2|
  473. drop procedure if exists bug8776_3|
  474. drop procedure if exists bug8776_4|
  475. create procedure bug8776_1()
  476. begin
  477. declare continue handler for sqlstate '42S0200test' begin end;
  478. begin end;
  479. end|
  480. ERROR 42000: Bad SQLSTATE: '42S0200test'
  481. create procedure bug8776_2()
  482. begin
  483. declare continue handler for sqlstate '4200' begin end;
  484. begin end;
  485. end|
  486. ERROR 42000: Bad SQLSTATE: '4200'
  487. create procedure bug8776_3()
  488. begin
  489. declare continue handler for sqlstate '420000' begin end;
  490. begin end;
  491. end|
  492. ERROR 42000: Bad SQLSTATE: '420000'
  493. create procedure bug8776_4()
  494. begin
  495. declare continue handler for sqlstate '42x00' begin end;
  496. begin end;
  497. end|
  498. ERROR 42000: Bad SQLSTATE: '42x00'
  499. create procedure bug6600()
  500. check table t1|
  501. ERROR 0A000: CHECK is not allowed in stored procedures
  502. create procedure bug6600()
  503. lock table t1 read|
  504. ERROR 0A000: LOCK is not allowed in stored procedures
  505. create procedure bug6600()
  506. unlock table t1|
  507. ERROR 0A000: UNLOCK is not allowed in stored procedures
  508. drop procedure if exists bug9566|
  509. create procedure bug9566()
  510. begin
  511. select * from t1;
  512. end|
  513. lock table t1 read|
  514. alter procedure bug9566 comment 'Some comment'|
  515. ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
  516. unlock tables|
  517. drop procedure bug9566|
  518. drop procedure if exists bug7299|
  519. create procedure bug7299()
  520. begin
  521. declare v int;
  522. declare c cursor for select val from t1;
  523. declare exit handler for sqlexception select 'Error!';
  524. open c;
  525. fetch c into v;
  526. end|
  527. truncate table t1|
  528. call bug7299()|
  529. ERROR 02000: No data - zero rows fetched, selected, or processed
  530. drop procedure bug7299|
  531. create procedure bug9073()
  532. begin
  533. declare continue handler for sqlexception select 1;
  534. declare continue handler for sqlexception select 2;
  535. end|
  536. ERROR 42000: Duplicate handler declared in the same block
  537. create procedure bug9073()
  538. begin
  539. declare condname1 condition for 1234;
  540. declare continue handler for condname1 select 1;
  541. declare exit handler for condname1 select 2;
  542. end|
  543. ERROR 42000: Duplicate handler declared in the same block
  544. create procedure bug9073()
  545. begin
  546. declare condname1 condition for sqlstate '42000';
  547. declare condname2 condition for sqlstate '42000';
  548. declare exit handler for condname1 select 1;
  549. declare continue handler for condname2 select 2;
  550. end|
  551. ERROR 42000: Duplicate handler declared in the same block
  552. create procedure bug9073()
  553. begin
  554. declare condname1 condition for sqlstate '42000';
  555. declare exit handler for condname1 select 1;
  556. declare exit handler for sqlstate '42000' select 2;
  557. end|
  558. ERROR 42000: Duplicate handler declared in the same block
  559. drop procedure if exists bug9073|
  560. create procedure bug9073()
  561. begin
  562. declare condname1 condition for sqlstate '42000';
  563. declare continue handler for condname1 select 1;
  564. begin
  565. declare exit handler for sqlstate '42000' select 2;
  566. begin
  567. declare continue handler for sqlstate '42000' select 3;
  568. end;
  569. end;
  570. end|
  571. drop procedure bug9073|
  572. create procedure bug7047()
  573. alter procedure bug7047|
  574. ERROR HY000: Can't drop or alter a PROCEDURE from within another stored routine
  575. create function bug7047() returns int
  576. begin
  577. alter function bug7047;
  578. return 0;
  579. end|
  580. ERROR HY000: Can't drop or alter a FUNCTION from within another stored routine
  581. create function bug8408() returns int
  582. begin
  583. select * from t1;
  584. return 0;
  585. end|
  586. ERROR 0A000: Not allowed to return a result set from a function
  587. create function bug8408() returns int
  588. begin
  589. show warnings;
  590. return 0;
  591. end|
  592. ERROR 0A000: Not allowed to return a result set from a function
  593. create function bug8408(a int) returns int
  594. begin
  595. declare b int;
  596. select b;
  597. return b;
  598. end|
  599. ERROR 0A000: Not allowed to return a result set from a function
  600. drop function if exists bug8408_f|
  601. drop procedure if exists bug8408_p|
  602. create function bug8408_f() returns int
  603. begin
  604. call bug8408_p();
  605. return 0;
  606. end|
  607. create procedure bug8408_p()
  608. select * from t1|
  609. call bug8408_p()|
  610. val x
  611. select bug8408_f()|
  612. ERROR 0A000: Not allowed to return a result set from a function
  613. drop procedure bug8408_p|
  614. drop function bug8408_f|
  615. create function bug8408() returns int
  616. begin
  617. declare n int default 0;
  618. select count(*) into n from t1;
  619. return n;
  620. end|
  621. insert into t1 value (2, 2.7), (3, 3.14), (7, 7.0)|
  622. select *,bug8408() from t1|
  623. val x bug8408()
  624. 2 2.7 3
  625. 3 3.14 3
  626. 7 7 3
  627. drop function bug8408|
  628. truncate table t1|
  629. drop procedure if exists bug10537|
  630. create procedure bug10537()
  631. load data local infile '/tmp/somefile' into table t1|
  632. ERROR 0A000: LOAD DATA is not allowed in stored procedures
  633. drop function if exists bug8409|
  634. create function bug8409()
  635. returns int
  636. begin
  637. flush tables;
  638. return 5;
  639. end|
  640. ERROR 0A000: FLUSH is not allowed in stored function or trigger
  641. create function bug8409() returns int begin reset query cache;
  642. return 1; end|
  643. ERROR 0A000: RESET is not allowed in stored function or trigger
  644. create function bug8409() returns int begin reset master;
  645. return 1; end|
  646. ERROR 0A000: RESET is not allowed in stored function or trigger
  647. create function bug8409() returns int begin reset slave;
  648. return 1; end|
  649. ERROR 0A000: RESET is not allowed in stored function or trigger
  650. create function bug8409() returns int begin flush hosts;
  651. return 1; end|
  652. ERROR 0A000: FLUSH is not allowed in stored function or trigger
  653. create function bug8409() returns int begin flush privileges;
  654. return 1; end|
  655. ERROR 0A000: FLUSH is not allowed in stored function or trigger
  656. create function bug8409() returns int begin flush tables with read lock;
  657. return 1; end|
  658. ERROR 0A000: FLUSH is not allowed in stored function or trigger
  659. create function bug8409() returns int begin flush tables;
  660. return 1; end|
  661. ERROR 0A000: FLUSH is not allowed in stored function or trigger
  662. create function bug8409() returns int begin flush logs;
  663. return 1; end|
  664. ERROR 0A000: FLUSH is not allowed in stored function or trigger
  665. create function bug8409() returns int begin flush status;
  666. return 1; end|
  667. ERROR 0A000: FLUSH is not allowed in stored function or trigger
  668. create function bug8409() returns int begin flush slave;
  669. return 1; end|
  670. ERROR 0A000: FLUSH is not allowed in stored function or trigger
  671. create function bug8409() returns int begin flush master;
  672. return 1; end|
  673. ERROR 0A000: FLUSH is not allowed in stored function or trigger
  674. create function bug8409() returns int begin flush des_key_file;
  675. return 1; end|
  676. ERROR 0A000: FLUSH is not allowed in stored function or trigger
  677. create function bug8409() returns int begin flush user_resources;
  678. return 1; end|
  679. ERROR 0A000: FLUSH is not allowed in stored function or trigger
  680. create procedure bug9529_901234567890123456789012345678901234567890123456789012345()
  681. begin
  682. end|
  683. ERROR 42000: Identifier name 'bug9529_901234567890123456789012345678901234567890123456789012345' is too long
  684. drop procedure if exists bug17015_0123456789012345678901234567890123456789012345678901234|
  685. create procedure bug17015_0123456789012345678901234567890123456789012345678901234()
  686. begin
  687. end|
  688. show procedure status like 'bug17015%'|
  689. Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
  690. test bug17015_0123456789012345678901234567890123456789012345678901234 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
  691. drop procedure bug17015_0123456789012345678901234567890123456789012345678901234|
  692. drop procedure if exists bug10969|
  693. create procedure bug10969()
  694. begin
  695. declare s1 int default 0;
  696. select default(s1) from t30;
  697. end|
  698. ERROR 42000: Incorrect column name 's1'
  699. create procedure bug10969()
  700. begin
  701. declare s1 int default 0;
  702. select default(t30.s1) from t30;
  703. end|
  704. drop procedure bug10969|
  705. drop table t1|
  706. create table t1(f1 int);
  707. create table t2(f1 int);
  708. CREATE PROCEDURE SP001()
  709. P1: BEGIN
  710. DECLARE ENDTABLE INT DEFAULT 0;
  711. DECLARE TEMP_NUM INT;
  712. DECLARE TEMP_SUM INT;
  713. DECLARE C1 CURSOR FOR SELECT F1 FROM t1;
  714. DECLARE C2 CURSOR FOR SELECT F1 FROM t2;
  715. DECLARE CONTINUE HANDLER FOR NOT FOUND SET ENDTABLE = 1;
  716. SET ENDTABLE=0;
  717. SET TEMP_SUM=0;
  718. SET TEMP_NUM=0;
  719. OPEN C1;
  720. FETCH C1 INTO TEMP_NUM;
  721. WHILE ENDTABLE = 0 DO
  722. SET TEMP_SUM=TEMP_NUM+TEMP_SUM;
  723. FETCH C1 INTO TEMP_NUM;
  724. END WHILE;
  725. SELECT TEMP_SUM;
  726. CLOSE C1;
  727. CLOSE C1;
  728. SELECT 'end of proc';
  729. END P1|
  730. call SP001();
  731. TEMP_SUM
  732. 0
  733. ERROR 24000: Cursor is not open
  734. drop procedure SP001;
  735. drop table t1, t2;
  736. drop function if exists bug11394|
  737. drop function if exists bug11394_1|
  738. drop function if exists bug11394_2|
  739. drop procedure if exists bug11394|
  740. create function bug11394(i int) returns int
  741. begin
  742. if i <= 0 then
  743. return 0;
  744. else
  745. return (i in (100, 200, bug11394(i-1), 400));
  746. end if;
  747. end|
  748. select bug11394(2)|
  749. ERROR HY000: Recursive stored functions and triggers are not allowed.
  750. drop function bug11394|
  751. create function bug11394_1(i int) returns int
  752. begin
  753. if i <= 0 then
  754. return 0;
  755. else
  756. return (select bug11394_1(i-1));
  757. end if;
  758. end|
  759. select bug11394_1(2)|
  760. ERROR HY000: Recursive stored functions and triggers are not allowed.
  761. drop function bug11394_1|
  762. create function bug11394_2(i int) returns int return i|
  763. select bug11394_2(bug11394_2(10))|
  764. bug11394_2(bug11394_2(10))
  765. 10
  766. drop function bug11394_2|
  767. create procedure bug11394(i int, j int)
  768. begin
  769. if i > 0 then
  770. call bug11394(i - 1,(select 1));
  771. end if;
  772. end|
  773. call bug11394(2, 1)|
  774. ERROR HY000: Recursive limit 0 (as set by the max_sp_recursion_depth variable) was exceeded for routine bug11394
  775. set @@max_sp_recursion_depth=10|
  776. call bug11394(2, 1)|
  777. set @@max_sp_recursion_depth=default|
  778. drop procedure bug11394|
  779. CREATE PROCEDURE BUG_12490() HELP CONTENTS;
  780. ERROR 0A000: HELP is not allowed in stored procedures
  781. CREATE FUNCTION BUG_12490() RETURNS INT HELP CONTENTS;
  782. ERROR 0A000: HELP is not allowed in stored procedures
  783. CREATE TABLE t_bug_12490(a int);
  784. CREATE TRIGGER BUG_12490 BEFORE UPDATE ON t_bug_12490 FOR EACH ROW HELP CONTENTS;
  785. ERROR 0A000: HELP is not allowed in stored procedures
  786. DROP TABLE t_bug_12490;
  787. drop function if exists bug11834_1;
  788. drop function if exists bug11834_2;
  789. create function bug11834_1() returns int return 10;
  790. create function bug11834_2() returns int return bug11834_1();
  791. prepare stmt from "select bug11834_2()";
  792. execute stmt;
  793. bug11834_2()
  794. 10
  795. execute stmt;
  796. bug11834_2()
  797. 10
  798. drop function bug11834_1;
  799. execute stmt;
  800. ERROR 42000: FUNCTION test.bug11834_1 does not exist
  801. deallocate prepare stmt;
  802. drop function bug11834_2;
  803. DROP FUNCTION IF EXISTS bug12953|
  804. CREATE FUNCTION bug12953() RETURNS INT
  805. BEGIN
  806. OPTIMIZE TABLE t1;
  807. RETURN 1;
  808. END|
  809. ERROR 0A000: Not allowed to return a result set from a function
  810. DROP FUNCTION IF EXISTS bug12995|
  811. CREATE FUNCTION bug12995() RETURNS INT
  812. BEGIN
  813. HANDLER t1 OPEN;
  814. RETURN 1;
  815. END|
  816. ERROR 0A000: HANDLER is not allowed in stored procedures
  817. CREATE FUNCTION bug12995() RETURNS INT
  818. BEGIN
  819. HANDLER t1 READ FIRST;
  820. RETURN 1;
  821. END|
  822. ERROR 0A000: HANDLER is not allowed in stored procedures
  823. CREATE FUNCTION bug12995() RETURNS INT
  824. BEGIN
  825. HANDLER t1 CLOSE;
  826. RETURN 1;
  827. END|
  828. ERROR 0A000: HANDLER is not allowed in stored procedures
  829. SELECT bug12995()|
  830. ERROR 42000: FUNCTION test.bug12995 does not exist
  831. drop procedure if exists bug12712;
  832. drop function if exists bug12712;
  833. create procedure bug12712()
  834. set session autocommit = 0;
  835. select @@autocommit;
  836. @@autocommit
  837. 1
  838. set @au = @@autocommit;
  839. call bug12712();
  840. select @@autocommit;
  841. @@autocommit
  842. 0
  843. set session autocommit = @au;
  844. create function bug12712()
  845. returns int
  846. begin
  847. call bug12712();
  848. return 0;
  849. end|
  850. set @x = bug12712()|
  851. ERROR HY000: Not allowed to set autocommit from a stored function or trigger
  852. drop procedure bug12712|
  853. drop function bug12712|
  854. create function bug12712()
  855. returns int
  856. begin
  857. set session autocommit = 0;
  858. return 0;
  859. end|
  860. ERROR HY000: Not allowed to set autocommit from a stored function or trigger
  861. create function bug12712()
  862. returns int
  863. begin
  864. set @@autocommit = 0;
  865. return 0;
  866. end|
  867. ERROR HY000: Not allowed to set autocommit from a stored function or trigger
  868. create function bug12712()
  869. returns int
  870. begin
  871. set local autocommit = 0;
  872. return 0;
  873. end|
  874. ERROR HY000: Not allowed to set autocommit from a stored function or trigger
  875. create trigger bug12712
  876. before insert on t1 for each row set session autocommit = 0;
  877. ERROR HY000: Not allowed to set autocommit from a stored function or trigger
  878. drop procedure if exists bug13510_1|
  879. drop procedure if exists bug13510_2|
  880. drop procedure if exists bug13510_3|
  881. drop procedure if exists bug13510_4|
  882. create procedure bug13510_1()
  883. begin
  884. declare password varchar(10);
  885. set password = 'foo1';
  886. select password;
  887. end|
  888. ERROR 42000: Variable 'password' must be quoted with `...`, or renamed
  889. set names='foo2'|
  890. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
  891. create procedure bug13510_2()
  892. begin
  893. declare names varchar(10);
  894. set names = 'foo2';
  895. select names;
  896. end|
  897. ERROR 42000: Variable 'names' must be quoted with `...`, or renamed
  898. create procedure bug13510_3()
  899. begin
  900. declare password varchar(10);
  901. set `password` = 'foo3';
  902. select password;
  903. end|
  904. create procedure bug13510_4()
  905. begin
  906. declare names varchar(10);
  907. set `names` = 'foo4';
  908. select names;
  909. end|
  910. call bug13510_3()|
  911. password
  912. foo3
  913. call bug13510_4()|
  914. names
  915. foo4
  916. drop procedure bug13510_3|
  917. drop procedure bug13510_4|
  918. drop function if exists bug_13627_f|
  919. CREATE TABLE t1 (a int)|
  920. CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN DROP TRIGGER test1; END |
  921. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  922. CREATE FUNCTION bug_13627_f() returns int BEGIN DROP TRIGGER test1; return 1; END |
  923. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  924. CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN create table t2 (a int); END |
  925. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  926. CREATE FUNCTION bug_13627_f() returns int BEGIN create table t2 (a int); return 1; END |
  927. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  928. CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN create index t1_i on t1 (a); END |
  929. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  930. CREATE FUNCTION bug_13627_f() returns int BEGIN create index t1_i on t1 (a); return 1; END |
  931. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  932. CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN alter table t1 add column b int; END |
  933. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  934. CREATE FUNCTION bug_13627_f() returns int BEGIN alter table t1 add column b int; return 1; END |
  935. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  936. CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN rename table t1 to t2; END |
  937. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  938. CREATE FUNCTION bug_13627_f() returns int BEGIN rename table t1 to t2; return 1; END |
  939. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  940. CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN truncate table t1; END |
  941. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  942. CREATE FUNCTION bug_13627_f() returns int BEGIN truncate table t1; return 1; END |
  943. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  944. CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN drop table t1; END |
  945. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  946. CREATE FUNCTION bug_13627_f() returns int BEGIN drop table t1; return 1; END |
  947. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  948. CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN drop index t1_i on t1; END |
  949. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  950. CREATE FUNCTION bug_13627_f() returns int BEGIN drop index t1_i on t1; return 1; END |
  951. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  952. CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN unlock tables; END |
  953. ERROR 0A000: UNLOCK is not allowed in stored procedures
  954. CREATE FUNCTION bug_13627_f() returns int BEGIN unlock tables; return 1; END |
  955. ERROR 0A000: UNLOCK is not allowed in stored procedures
  956. CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN LOCK TABLE t1 READ; END |
  957. ERROR 0A000: LOCK is not allowed in stored procedures
  958. CREATE FUNCTION bug_13627_f() returns int BEGIN LOCK TABLE t1 READ; return 1; END |
  959. ERROR 0A000: LOCK is not allowed in stored procedures
  960. CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN create database mysqltest; END |
  961. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  962. CREATE FUNCTION bug_13627_f() returns int BEGIN create database mysqltest; return 1; END |
  963. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  964. CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN drop database mysqltest; END |
  965. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  966. CREATE FUNCTION bug_13627_f() returns int BEGIN drop database mysqltest; return 1; END |
  967. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  968. CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN create user 'mysqltest_1'; END |
  969. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  970. CREATE FUNCTION bug_13627_f() returns int BEGIN create user 'mysqltest_1'; return 1; END |
  971. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  972. CREATE TRIGGER bug21975 BEFORE INSERT ON t1 FOR EACH ROW BEGIN grant select on t1 to 'mysqltest_1'; END |
  973. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  974. CREATE FUNCTION bug21975() returns int BEGIN grant select on t1 to 'mysqltest_1'; return 1; END |
  975. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  976. CREATE TRIGGER bug21975 BEFORE INSERT ON t1 FOR EACH ROW BEGIN revoke select on t1 from 'mysqltest_1'; END |
  977. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  978. CREATE FUNCTION bug21975() returns int BEGIN revoke select on t1 from 'mysqltest_1'; return 1; END |
  979. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  980. CREATE TRIGGER bug21975 BEFORE INSERT ON t1 FOR EACH ROW BEGIN revoke all privileges on *.* from 'mysqltest_1'; END |
  981. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  982. CREATE FUNCTION bug21975() returns int BEGIN revoke all privileges on *.* from 'mysqltest_1'; return 1; END |
  983. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  984. CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN drop user 'mysqltest_1'; END |
  985. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  986. CREATE FUNCTION bug_13627_f() returns int BEGIN drop user 'mysqltest_1'; return 1; END |
  987. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  988. CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN rename user 'mysqltest_2' to 'mysqltest_1'; END |
  989. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  990. CREATE FUNCTION bug_13627_f() returns int BEGIN rename user 'mysqltest_2' to 'mysqltest_1'; return 1; END |
  991. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  992. CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN create view v1 as select 1; END |
  993. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  994. CREATE FUNCTION bug_13627_f() returns int BEGIN create view v1 as select 1; return 1; END |
  995. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  996. CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN alter view v1 as select 1; END |
  997. ERROR 0A000: ALTER VIEW is not allowed in stored procedures
  998. CREATE FUNCTION bug_13627_f() returns int BEGIN alter view v1 as select 1; return 1; END |
  999. ERROR 0A000: ALTER VIEW is not allowed in stored procedures
  1000. CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN drop view v1; END |
  1001. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  1002. CREATE FUNCTION bug_13627_f() returns int BEGIN drop view v1; return 1; END |
  1003. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  1004. CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN create trigger tr2 before insert on t1 for each row do select 1; END |
  1005. ERROR 2F003: Can't create a TRIGGER from within another stored routine
  1006. CREATE FUNCTION bug_13627_f() returns int BEGIN create trigger tr2 before insert on t1 for each row do select 1; return 1; END |
  1007. ERROR 2F003: Can't create a TRIGGER from within another stored routine
  1008. CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN drop function bug_13627_f; END |
  1009. ERROR HY000: Can't drop or alter a FUNCTION from within another stored routine
  1010. CREATE FUNCTION bug_13627_f() returns int BEGIN drop function bug_13627_f; return 1; END |
  1011. ERROR HY000: Can't drop or alter a FUNCTION from within another stored routine
  1012. CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN create function f2 () returns int return 1; END |
  1013. ERROR 2F003: Can't create a FUNCTION from within another stored routine
  1014. CREATE FUNCTION bug_13627_f() returns int BEGIN create function f2 () returns int return 1; return 1; END |
  1015. ERROR 2F003: Can't create a FUNCTION from within another stored routine
  1016. CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW
  1017. BEGIN
  1018. CREATE TEMPORARY TABLE t2 (a int);
  1019. DROP TEMPORARY TABLE t2;
  1020. END |
  1021. CREATE FUNCTION bug_13627_f() returns int
  1022. BEGIN
  1023. CREATE TEMPORARY TABLE t2 (a int);
  1024. DROP TEMPORARY TABLE t2;
  1025. return 1;
  1026. END |
  1027. drop table t1|
  1028. drop function bug_13627_f|
  1029. drop function if exists bug12329;
  1030. Warnings:
  1031. Note 1305 FUNCTION test.bug12329 does not exist
  1032. create table t1 as select 1 a;
  1033. create table t2 as select 1 a;
  1034. create function bug12329() returns int return (select a from t1);
  1035. prepare stmt1 from 'select bug12329()';
  1036. execute stmt1;
  1037. bug12329()
  1038. 1
  1039. drop function bug12329;
  1040. create function bug12329() returns int return (select a+100 from t2);
  1041. select bug12329();
  1042. bug12329()
  1043. 101
  1044. execute stmt1;
  1045. bug12329()
  1046. 101
  1047. deallocate prepare stmt1;
  1048. drop function bug12329;
  1049. drop table t1, t2;
  1050. create database mysqltest1;
  1051. use mysqltest1;
  1052. drop database mysqltest1;
  1053. create function f1() returns int return 1;
  1054. ERROR 3D000: No database selected
  1055. create procedure p1(out param1 int)
  1056. begin
  1057. select count(*) into param1 from t3;
  1058. end|
  1059. ERROR 3D000: No database selected
  1060. use test;
  1061. DROP PROCEDURE IF EXISTS bug13037_p1;
  1062. DROP PROCEDURE IF EXISTS bug13037_p2;
  1063. DROP PROCEDURE IF EXISTS bug13037_p3;
  1064. CREATE PROCEDURE bug13037_p1()
  1065. BEGIN
  1066. IF bug13037_foo THEN
  1067. SELECT 1;
  1068. END IF;
  1069. END|
  1070. CREATE PROCEDURE bug13037_p2()
  1071. BEGIN
  1072. SET @bug13037_foo = bug13037_bar;
  1073. END|
  1074. CREATE PROCEDURE bug13037_p3()
  1075. BEGIN
  1076. SELECT bug13037_foo;
  1077. END|
  1078. CALL bug13037_p1();
  1079. ERROR 42S22: Unknown column 'bug13037_foo' in 'field list'
  1080. CALL bug13037_p2();
  1081. ERROR 42S22: Unknown column 'bug13037_bar' in 'field list'
  1082. CALL bug13037_p3();
  1083. ERROR 42S22: Unknown column 'bug13037_foo' in 'field list'
  1084. CALL bug13037_p1();
  1085. ERROR 42S22: Unknown column 'bug13037_foo' in 'field list'
  1086. CALL bug13037_p2();
  1087. ERROR 42S22: Unknown column 'bug13037_bar' in 'field list'
  1088. CALL bug13037_p3();
  1089. ERROR 42S22: Unknown column 'bug13037_foo' in 'field list'
  1090. DROP PROCEDURE bug13037_p1;
  1091. DROP PROCEDURE bug13037_p2;
  1092. DROP PROCEDURE bug13037_p3;
  1093. create database mysqltest1;
  1094. create database mysqltest2;
  1095. use mysqltest1;
  1096. drop database mysqltest1;
  1097. create procedure mysqltest2.p1() select version();
  1098. create procedure p2() select version();
  1099. ERROR 3D000: No database selected
  1100. use mysqltest2;
  1101. show procedure status;
  1102. Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
  1103. mysqltest2 p1 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
  1104. drop database mysqltest2;
  1105. use test;
  1106. DROP FUNCTION IF EXISTS bug13012|
  1107. CREATE FUNCTION bug13012() RETURNS INT
  1108. BEGIN
  1109. REPAIR TABLE t1;
  1110. RETURN 1;
  1111. END|
  1112. ERROR 0A000: Not allowed to return a result set from a function
  1113. create table t1 (a int)|
  1114. CREATE PROCEDURE bug13012_1() REPAIR TABLE t1|
  1115. CREATE FUNCTION bug13012_2() RETURNS INT
  1116. BEGIN
  1117. CALL bug13012_1();
  1118. RETURN 1;
  1119. END|
  1120. SELECT bug13012_2()|
  1121. ERROR 0A000: Not allowed to return a result set from a function
  1122. drop table t1|
  1123. drop procedure bug13012_1|
  1124. drop function bug13012_2|
  1125. drop function if exists bug11555_1;
  1126. drop function if exists bug11555_2;
  1127. drop view if exists v1, v2, v3, v4;
  1128. create function bug11555_1() returns int return (select max(i) from t1);
  1129. create function bug11555_2() returns int return bug11555_1();
  1130. create view v1 as select bug11555_1();
  1131. drop view v1;
  1132. create view v2 as select bug11555_2();
  1133. drop view v2;
  1134. create table t1 (i int);
  1135. create view v1 as select bug11555_1();
  1136. create view v2 as select bug11555_2();
  1137. create view v3 as select * from v1;
  1138. drop table t1;
  1139. select * from v1;
  1140. ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
  1141. select * from v2;
  1142. ERROR HY000: View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
  1143. select * from v3;
  1144. ERROR HY000: View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
  1145. create view v4 as select * from v1;
  1146. drop view v1, v2, v3, v4;
  1147. drop function bug11555_1;
  1148. drop function bug11555_2;
  1149. create table t1 (i int);
  1150. create table t2 (i int);
  1151. create trigger t1_ai after insert on t1 for each row insert into t2 values (new.i);
  1152. create view v1 as select * from t1;
  1153. drop table t2;
  1154. insert into v1 values (1);
  1155. ERROR 42S02: Table 'test.t2' doesn't exist
  1156. drop trigger t1_ai;
  1157. create function bug11555_1() returns int return (select max(i) from t2);
  1158. create trigger t1_ai after insert on t1 for each row set @a:=bug11555_1();
  1159. insert into v1 values (2);
  1160. ERROR 42S02: Table 'test.t2' doesn't exist
  1161. drop function bug11555_1;
  1162. drop table t1;
  1163. drop view v1;
  1164. drop procedure if exists ` bug15658`;
  1165. create procedure ``() select 1;
  1166. ERROR 42000: Incorrect routine name ''
  1167. create procedure ` `() select 1;
  1168. ERROR 42000: Incorrect routine name ' '
  1169. create procedure `bug15658 `() select 1;
  1170. ERROR 42000: Incorrect routine name 'bug15658 '
  1171. create procedure ``.bug15658() select 1;
  1172. ERROR 42000: Incorrect database name ''
  1173. create procedure `x `.bug15658() select 1;
  1174. ERROR 42000: Incorrect database name 'x '
  1175. create procedure ` bug15658`() select 1;
  1176. call ` bug15658`();
  1177. 1
  1178. 1
  1179. show procedure status;
  1180. Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
  1181. test bug15658 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
  1182. drop procedure ` bug15658`;
  1183. drop function if exists bug14270;
  1184. drop table if exists t1;
  1185. create table t1 (s1 int primary key);
  1186. create function bug14270() returns int
  1187. begin
  1188. load index into cache t1;
  1189. return 1;
  1190. end|
  1191. ERROR 0A000: Not allowed to return a result set from a function
  1192. create function bug14270() returns int
  1193. begin
  1194. cache index t1 key (`primary`) in keycache1;
  1195. return 1;
  1196. end|
  1197. ERROR 0A000: Not allowed to return a result set from a function
  1198. drop table t1;
  1199. drop procedure if exists bug15091;
  1200. create procedure bug15091()
  1201. begin
  1202. declare selectstr varchar(6000) default ' ';
  1203. declare conditionstr varchar(5000) default '';
  1204. set selectstr = concat(selectstr,
  1205. ' and ',
  1206. c.operatorid,
  1207. 'in (',conditionstr, ')');
  1208. end|
  1209. call bug15091();
  1210. ERROR 42S02: Unknown table 'c' in field list
  1211. drop procedure bug15091;
  1212. drop function if exists bug16896;
  1213. create aggregate function bug16896() returns int return 1;
  1214. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '() returns int return 1' at line 1
  1215. DROP PROCEDURE IF EXISTS bug14702;
  1216. CREATE IF NOT EXISTS PROCEDURE bug14702()
  1217. BEGIN
  1218. END;
  1219. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF NOT EXISTS PROCEDURE bug14702()
  1220. BEGIN
  1221. END' at line 1
  1222. CREATE PROCEDURE IF NOT EXISTS bug14702()
  1223. BEGIN
  1224. END;
  1225. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF NOT EXISTS bug14702()
  1226. BEGIN
  1227. END' at line 1
  1228. DROP TABLE IF EXISTS t1;
  1229. CREATE TABLE t1 (i INT);
  1230. CREATE PROCEDURE bug20953() CREATE VIEW v AS SELECT 1 INTO @a;
  1231. ERROR HY000: View's SELECT contains a 'INTO' clause
  1232. CREATE PROCEDURE bug20953() CREATE VIEW v AS SELECT 1 INTO DUMPFILE "file";
  1233. ERROR HY000: View's SELECT contains a 'INTO' clause
  1234. CREATE PROCEDURE bug20953() CREATE VIEW v AS SELECT 1 INTO OUTFILE "file";
  1235. ERROR HY000: View's SELECT contains a 'INTO' clause
  1236. CREATE PROCEDURE bug20953()
  1237. CREATE VIEW v AS SELECT i FROM t1 PROCEDURE ANALYSE();
  1238. ERROR HY000: View's SELECT contains a 'PROCEDURE' clause
  1239. CREATE PROCEDURE bug20953() CREATE VIEW v AS SELECT 1 FROM (SELECT 1) AS d1;
  1240. ERROR HY000: View's SELECT contains a subquery in the FROM clause
  1241. CREATE PROCEDURE bug20953(i INT) CREATE VIEW v AS SELECT i;
  1242. ERROR HY000: View's SELECT contains a variable or parameter
  1243. CREATE PROCEDURE bug20953()
  1244. BEGIN
  1245. DECLARE i INT;
  1246. CREATE VIEW v AS SELECT i;
  1247. END |
  1248. ERROR HY000: View's SELECT contains a variable or parameter
  1249. PREPARE stmt FROM "CREATE VIEW v AS SELECT ?";
  1250. ERROR HY000: View's SELECT contains a variable or parameter
  1251. DROP TABLE t1;
  1252. drop tables if exists t1;
  1253. drop procedure if exists bug24491;
  1254. create table t1 (id int primary key auto_increment, value varchar(10));
  1255. insert into t1 (id, value) values (1, 'FIRST'), (2, 'SECOND'), (3, 'THIRD');
  1256. create procedure bug24491()
  1257. insert into t1 (id, value) select * from (select 4 as i, 'FOURTH' as v) as y on duplicate key update v = 'DUP';
  1258. call bug24491();
  1259. ERROR 42S22: Unknown column 'v' in 'field list'
  1260. call bug24491();
  1261. ERROR 42S22: Unknown column 'v' in 'field list'
  1262. drop procedure bug24491;
  1263. create procedure bug24491()
  1264. insert into t1 (id, value) select * from (select 4 as id, 'FOURTH' as value) as y on duplicate key update y.value = 'DUP';
  1265. call bug24491();
  1266. ERROR 42S22: Unknown column 'y.value' in 'field list'
  1267. call bug24491();
  1268. ERROR 42S22: Unknown column 'y.value' in 'field list'
  1269. drop procedure bug24491;
  1270. drop tables t1;
  1271. DROP FUNCTION IF EXISTS bug18914_f1;
  1272. DROP FUNCTION IF EXISTS bug18914_f2;
  1273. DROP PROCEDURE IF EXISTS bug18914_p1;
  1274. DROP PROCEDURE IF EXISTS bug18914_p2;
  1275. DROP TABLE IF EXISTS t1, t2;
  1276. CREATE TABLE t1 (i INT);
  1277. CREATE PROCEDURE bug18914_p1() CREATE TABLE t2 (i INT);
  1278. CREATE PROCEDURE bug18914_p2() DROP TABLE IF EXISTS no_such_table;
  1279. CREATE FUNCTION bug18914_f1() RETURNS INT
  1280. BEGIN
  1281. CALL bug18914_p1();
  1282. RETURN 1;
  1283. END |
  1284. CREATE FUNCTION bug18914_f2() RETURNS INT
  1285. BEGIN
  1286. CALL bug18914_p2();
  1287. RETURN 1;
  1288. END |
  1289. CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
  1290. CALL bug18914_p1();
  1291. INSERT INTO t1 VALUES (1);
  1292. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  1293. SELECT bug18914_f1();
  1294. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  1295. SELECT bug18914_f2();
  1296. ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
  1297. SELECT * FROM t2;
  1298. ERROR 42S02: Table 'test.t2' doesn't exist
  1299. DROP FUNCTION bug18914_f1;
  1300. DROP FUNCTION bug18914_f2;
  1301. DROP PROCEDURE bug18914_p1;
  1302. DROP PROCEDURE bug18914_p2;
  1303. DROP TABLE t1;
  1304. drop table if exists bogus_table_20713;
  1305. drop function if exists func_20713_a;
  1306. drop function if exists func_20713_b;
  1307. create table bogus_table_20713( id int(10) not null primary key);
  1308. insert into bogus_table_20713 values (1), (2), (3);
  1309. create function func_20713_a() returns int(11)
  1310. begin
  1311. declare id int;
  1312. declare continue handler for sqlexception set id=null;
  1313. set @in_func := 1;
  1314. set id = (select id from bogus_table_20713 where id = 3);
  1315. set @in_func := 2;
  1316. return id;
  1317. end//
  1318. create function func_20713_b() returns int(11)
  1319. begin
  1320. declare id int;
  1321. declare continue handler for sqlstate value '42S02' set id=null;
  1322. set @in_func := 1;
  1323. set id = (select id from bogus_table_20713 where id = 3);
  1324. set @in_func := 2;
  1325. return id;
  1326. end//
  1327. set @in_func := 0;
  1328. select func_20713_a();
  1329. func_20713_a()
  1330. NULL
  1331. select @in_func;
  1332. @in_func
  1333. 2
  1334. set @in_func := 0;
  1335. select func_20713_b();
  1336. func_20713_b()
  1337. NULL
  1338. select @in_func;
  1339. @in_func
  1340. 2
  1341. drop table bogus_table_20713;
  1342. set @in_func := 0;
  1343. select func_20713_a();
  1344. func_20713_a()
  1345. NULL
  1346. Warnings:
  1347. Error 1146 Table 'test.bogus_table_20713' doesn't exist
  1348. select @in_func;
  1349. @in_func
  1350. 2
  1351. set @in_func := 0;
  1352. select func_20713_b();
  1353. func_20713_b()
  1354. NULL
  1355. Warnings:
  1356. Error 1146 Table 'test.bogus_table_20713' doesn't exist
  1357. select @in_func;
  1358. @in_func
  1359. 2
  1360. drop function if exists func_20713_a;
  1361. drop function if exists func_20713_b;
  1362. drop table if exists table_25345_a;
  1363. drop table if exists table_25345_b;
  1364. drop procedure if exists proc_25345;
  1365. drop function if exists func_25345;
  1366. drop function if exists func_25345_b;
  1367. create table table_25345_a (a int);
  1368. create table table_25345_b (b int);
  1369. create procedure proc_25345()
  1370. begin
  1371. declare c1 cursor for select a from table_25345_a;
  1372. declare c2 cursor for select b from table_25345_b;
  1373. select 1 as result;
  1374. end ||
  1375. create function func_25345() returns int(11)
  1376. begin
  1377. call proc_25345();
  1378. return 1;
  1379. end ||
  1380. create function func_25345_b() returns int(11)
  1381. begin
  1382. declare c1 cursor for select a from table_25345_a;
  1383. declare c2 cursor for select b from table_25345_b;
  1384. return 1;
  1385. end ||
  1386. call proc_25345();
  1387. result
  1388. 1
  1389. select func_25345();
  1390. ERROR 0A000: Not allowed to return a result set from a function
  1391. select func_25345_b();
  1392. func_25345_b()
  1393. 1
  1394. drop table table_25345_a;
  1395. call proc_25345();
  1396. result
  1397. 1
  1398. select func_25345();
  1399. ERROR 0A000: Not allowed to return a result set from a function
  1400. select func_25345_b();
  1401. func_25345_b()
  1402. 1
  1403. drop table table_25345_b;
  1404. drop procedure proc_25345;
  1405. drop function func_25345;
  1406. drop function func_25345_b;
  1407. End of 5.0 tests
  1408. drop function if exists bug16164;
  1409. create function bug16164() returns int
  1410. begin
  1411. show authors;
  1412. return 42;
  1413. end|
  1414. ERROR 0A000: Not allowed to return a result set from a function
  1415. drop function if exists bug20701;
  1416. create function bug20701() returns varchar(25) binary return "test";
  1417. ERROR 42000: This version of MySQL doesn't yet support 'return value collation'
  1418. create function bug20701() returns varchar(25) return "test";
  1419. drop function bug20701;
  1420. create procedure proc_26503_error_1()
  1421. begin
  1422. retry:
  1423. repeat
  1424. begin
  1425. declare continue handler for sqlexception
  1426. begin
  1427. iterate retry;
  1428. end
  1429. select "do something";
  1430. end
  1431. until true end repeat retry;
  1432. end//
  1433. ERROR 42000: ITERATE with no matching label: retry
  1434. create procedure proc_26503_error_2()
  1435. begin
  1436. retry:
  1437. repeat
  1438. begin
  1439. declare continue handler for sqlexception
  1440. iterate retry;
  1441. select "do something";
  1442. end
  1443. until true end repeat retry;
  1444. end//
  1445. ERROR 42000: ITERATE with no matching label: retry
  1446. create procedure proc_26503_error_3()
  1447. begin
  1448. retry:
  1449. repeat
  1450. begin
  1451. declare continue handler for sqlexception
  1452. begin
  1453. leave retry;
  1454. end
  1455. select "do something";
  1456. end
  1457. until true end repeat retry;
  1458. end//
  1459. ERROR 42000: LEAVE with no matching label: retry
  1460. create procedure proc_26503_error_4()
  1461. begin
  1462. retry:
  1463. repeat
  1464. begin
  1465. declare continue handler for sqlexception
  1466. leave retry;
  1467. select "do something";
  1468. end
  1469. until true end repeat retry;
  1470. end//
  1471. ERROR 42000: LEAVE with no matching label: retry
  1472. drop procedure if exists proc_28360;
  1473. drop function if exists func_28360;
  1474. CREATE PROCEDURE proc_28360()
  1475. BEGIN
  1476. ALTER DATABASE `#mysql50#upgrade-me` UPGRADE DATA DIRECTORY NAME;
  1477. END//
  1478. ERROR HY000: Can't drop or alter a DATABASE from within another stored routine
  1479. CREATE FUNCTION func_28360() RETURNS int
  1480. BEGIN
  1481. ALTER DATABASE `#mysql50#upgrade-me` UPGRADE DATA DIRECTORY NAME;
  1482. RETURN 0;
  1483. END//
  1484. ERROR HY000: Can't drop or alter a DATABASE from within another stored routine
  1485. DROP PROCEDURE IF EXISTS p1;
  1486. CREATE PROCEDURE p1()
  1487. BEGIN
  1488. DECLARE c char(100);
  1489. DECLARE cur1 CURSOR FOR SHOW TABLES;
  1490. OPEN cur1;
  1491. FETCH cur1 INTO c;
  1492. select c;
  1493. CLOSE cur1;
  1494. END|
  1495. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SHOW TABLES;
  1496. OPEN cur1;
  1497. FETCH cur1 INTO c;
  1498. select c;
  1499. CLOSE cur1;
  1500. END' at line 4
  1501. DROP DATABASE IF EXISTS mysqltest;
  1502. CREATE DATABASE mysqltest;
  1503. USE mysqltest;
  1504. DROP DATABASE mysqltest;
  1505. SELECT inexistent(), 1 + ,;
  1506. ERROR 42000: FUNCTION inexistent does not exist
  1507. SELECT inexistent();
  1508. ERROR 42000: FUNCTION inexistent does not exist
  1509. SELECT .inexistent();
  1510. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '()' at line 1
  1511. SELECT ..inexistent();
  1512. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.inexistent()' at line 1
  1513. USE test;
  1514. create function f1() returns int
  1515. begin
  1516. set @test = 1, password = password('foo');
  1517. return 1;
  1518. end|
  1519. ERROR HY000: Not allowed to set autocommit from a stored function or trigger
  1520. create trigger t1
  1521. before insert on t2 for each row set password = password('foo');|
  1522. ERROR HY000: Not allowed to set autocommit from a stored function or trigger
  1523. drop function if exists f1;
  1524. drop function if exists f2;
  1525. drop table if exists t1, t2;
  1526. create function f1() returns int
  1527. begin
  1528. drop temporary table t1;
  1529. return 1;
  1530. end|
  1531. create temporary table t1 as select f1();
  1532. ERROR HY000: Can't reopen table: 't1'
  1533. create function f2() returns int
  1534. begin
  1535. create temporary table t2 as select f1();
  1536. return 1;
  1537. end|
  1538. create temporary table t1 as select f2();
  1539. ERROR HY000: Can't reopen table: 't1'
  1540. drop function f1;
  1541. drop function f2;
  1542. create function f1() returns int
  1543. begin
  1544. drop temporary table t2,t1;
  1545. return 1;
  1546. end|
  1547. create function f2() returns int
  1548. begin
  1549. create temporary table t2 as select f1();
  1550. return 1;
  1551. end|
  1552. create t

Large files files are truncated, but you can click here to view the full file