Commit c26dafdf authored by unknown's avatar unknown

Merge gbichot@bk-internal:/home/bk/mysql-5.0

into production.mysql.com:/nfstmp1/guilhem/mysql-5.0-prod-gcc

parents 1a260574 3a0cec05
drop table if exists t1, t2;
delete from mysql.proc; delete from mysql.proc;
create procedure syntaxerror(t int)| create procedure syntaxerror(t int)|
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 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
...@@ -635,3 +636,32 @@ ERROR 0A000: EXECUTE is not allowed in stored procedures ...@@ -635,3 +636,32 @@ ERROR 0A000: EXECUTE is not allowed in stored procedures
create function f() returns int begin execute stmt; create function f() returns int begin execute stmt;
ERROR 0A000: EXECUTE is not allowed in stored procedures ERROR 0A000: EXECUTE is not allowed in stored procedures
deallocate prepare stmt; deallocate prepare stmt;
create table t1(f1 int);
create table t2(f1 int);
CREATE PROCEDURE SP001()
P1: BEGIN
DECLARE ENDTABLE INT DEFAULT 0;
DECLARE TEMP_NUM INT;
DECLARE TEMP_SUM INT;
DECLARE C1 CURSOR FOR SELECT F1 FROM t1;
DECLARE C2 CURSOR FOR SELECT F1 FROM t2;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET ENDTABLE = 1;
SET ENDTABLE=0;
SET TEMP_SUM=0;
SET TEMP_NUM=0;
OPEN C1;
FETCH C1 INTO TEMP_NUM;
WHILE ENDTABLE = 0 DO
SET TEMP_SUM=TEMP_NUM+TEMP_SUM;
FETCH C1 INTO TEMP_NUM;
END WHILE;
SELECT TEMP_SUM;
CLOSE C1;
CLOSE C1;
SELECT 'end of proc';
END P1|
call SP001();
TEMP_SUM
0
drop procedure SP001;
drop table t1, t2;
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
# Stored PROCEDURE error tests # Stored PROCEDURE error tests
# #
--disable_warnings
drop table if exists t1, t2;
--enable_warnings
# Make sure we don't have any procedures left. # Make sure we don't have any procedures left.
delete from mysql.proc; delete from mysql.proc;
...@@ -933,3 +937,37 @@ create procedure p() execute stmt; ...@@ -933,3 +937,37 @@ create procedure p() execute stmt;
create function f() returns int begin execute stmt; create function f() returns int begin execute stmt;
deallocate prepare stmt; deallocate prepare stmt;
# BUG#9814: Closing a cursor that is not open
create table t1(f1 int);
create table t2(f1 int);
delimiter |;
CREATE PROCEDURE SP001()
P1: BEGIN
DECLARE ENDTABLE INT DEFAULT 0;
DECLARE TEMP_NUM INT;
DECLARE TEMP_SUM INT;
DECLARE C1 CURSOR FOR SELECT F1 FROM t1;
DECLARE C2 CURSOR FOR SELECT F1 FROM t2;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET ENDTABLE = 1;
SET ENDTABLE=0;
SET TEMP_SUM=0;
SET TEMP_NUM=0;
OPEN C1;
FETCH C1 INTO TEMP_NUM;
WHILE ENDTABLE = 0 DO
SET TEMP_SUM=TEMP_NUM+TEMP_SUM;
FETCH C1 INTO TEMP_NUM;
END WHILE;
SELECT TEMP_SUM;
CLOSE C1;
CLOSE C1;
SELECT 'end of proc';
END P1|
delimiter ;|
call SP001();
drop procedure SP001;
drop table t1, t2;
...@@ -643,6 +643,12 @@ sp_head::execute(THD *thd) ...@@ -643,6 +643,12 @@ sp_head::execute(THD *thd)
*/ */
thd->current_arena= i; thd->current_arena= i;
ret= i->execute(thd, &ip); ret= i->execute(thd, &ip);
/*
If this SP instruction have sent eof, it has caused no_send_error to be
set. Clear it back to allow the next instruction to send error. (multi-
statement execution code clears no_send_error between statements too)
*/
thd->net.no_send_error= 0;
if (i->free_list) if (i->free_list)
cleanup_items(i->free_list); cleanup_items(i->free_list);
i->state= Query_arena::EXECUTED; i->state= Query_arena::EXECUTED;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment