From 065a93773ede926d80a8f2dc772e43878304bce3 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Sep 2005 17:16:12 +0200 Subject: Fixed BUG#12712: SET AUTOCOMMIT should fail within SP/functions/triggers Second version after review. Allow 'set autocommit' in procedures, but not functions or triggers. Can return error in run-time (when a function calls a procedure). mysql-test/r/sp-error.result: New test case for BUG#12712. mysql-test/t/sp-error.test: New test case for BUG#12712. sql/set_var.cc: Made sys_autocommit external, to allow testing in sql_yacc.yy. sql/set_var.h: Made sys_autocommit external, to allow testing in sql_yacc.yy. sql/share/errmsg.txt: New error message for disallowing the setting of autocommit in stored functions and triggers. sql/sp_head.h: New flag: has 'set autocommit', and testing for this in is_not_allowed_in_function(). sql/sql_yacc.yy: Disallow setting AUTOCOMMIT in stored function and triggers. --- mysql-test/r/sp-error.result | 47 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'mysql-test/r/sp-error.result') diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 09d829e9d12..17a2050437f 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -786,3 +786,50 @@ END| ERROR 0A000: HANDLER is not allowed in stored procedures SELECT bug12995()| ERROR 42000: FUNCTION test.bug12995 does not exist +drop procedure if exists bug12712; +drop function if exists bug12712; +create procedure bug12712() +set session autocommit = 0; +select @@autocommit; +@@autocommit +1 +set @au = @@autocommit; +call bug12712(); +select @@autocommit; +@@autocommit +0 +set session autocommit = @au; +create function bug12712() +returns int +begin +call bug12712(); +return 0; +end| +set @x = bug12712()| +ERROR HY000: Not allowed to set autocommit from a stored function or trigger +drop procedure bug12712| +drop function bug12712| +create function bug12712() +returns int +begin +set session autocommit = 0; +return 0; +end| +ERROR HY000: Not allowed to set autocommit from a stored function or trigger +create function bug12712() +returns int +begin +set @@autocommit = 0; +return 0; +end| +ERROR HY000: Not allowed to set autocommit from a stored function or trigger +create function bug12712() +returns int +begin +set local autocommit = 0; +return 0; +end| +ERROR HY000: Not allowed to set autocommit from a stored function or trigger +create trigger bug12712 +before insert on t1 for each row set session autocommit = 0; +ERROR HY000: Not allowed to set autocommit from a stored function or trigger -- cgit v1.2.1