List:Internals« Previous MessageNext Message »
From:pem Date:September 8 2005 5:29pm
Subject:bk commit into 5.0 tree (pem:1.1959)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of pem. When pem does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1959 05/09/08 18:56:39 pem@stripped +6 -0
  Fixed BUG##12712: SET AUTOCOMMIT should fail within SP/functions/triggers
    Disallowed it completely in routines. (Allowing it in some procedures
    would be more complicated and requires a run-time check as well.)

  sql/sql_yacc.yy
    1.420 05/09/08 18:56:30 pem@stripped +9 -0
    Disallow setting AUTOCOMMIT in stored routines and triggers.

  sql/share/errmsg.txt
    1.43 05/09/08 18:56:30 pem@stripped +2 -0
    New error message for disallowing the setting of some sys variables in SPs and triggers.

  sql/set_var.h
    1.71 05/09/08 18:56:30 pem@stripped +1 -0
    Made sys_autocommit external, to allow testing in sql_yacc.yy.

  sql/set_var.cc
    1.140 05/09/08 18:56:30 pem@stripped +4 -4
    Made sys_autocommit external, to allow testing in sql_yacc.yy.

  mysql-test/t/sp-error.test
    1.88 05/09/08 18:56:30 pem@stripped +18 -0
    New test cases for BUG#12712.

  mysql-test/r/sp-error.result
    1.84 05/09/08 18:56:30 pem@stripped +12 -0
    New test cases for BUG#12712.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	pem
# Host:	mysql.comhem.se
# Root:	/home/pem/work/mysql-5.0

--- 1.419/sql/sql_yacc.yy	2005-09-07 21:44:12 +02:00
+++ 1.420/sql/sql_yacc.yy	2005-09-08 18:56:30 +02:00
@@ -8000,6 +8000,15 @@
             if (tmp == &sys_time_zone &&
                 lex->add_time_zone_tables_to_query_tables(YYTHD))
               YYABORT;
+            else
+              if (spc && tmp == &sys_autocommit)
+              {
+                /*
+                  We don't allow setting AUTOCOMMIT from a stored routine
+                */
+                my_error(ER_SP_CANT_SET_VAR, MYF(0), tmp->name);
+                YYABORT;
+              }
 	  }
 	  else
 	  {

--- 1.42/sql/share/errmsg.txt	2005-09-03 01:25:41 +02:00
+++ 1.43/sql/share/errmsg.txt	2005-09-08 18:56:30 +02:00
@@ -5403,3 +5403,5 @@
         eng "The definition of table '%-.64s' prevents operation %s on table '%-.64s'."
 ER_PS_NO_RECURSION
         eng "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"
+ER_SP_CANT_SET_VAR
+	eng "Not allowed to set '%s' from a stored routine or trigger"

--- 1.139/sql/set_var.cc	2005-09-07 12:36:58 +02:00
+++ 1.140/sql/set_var.cc	2005-09-08 18:56:30 +02:00
@@ -447,10 +447,10 @@
 
 /* Variables that are bits in THD */
 
-static sys_var_thd_bit	sys_autocommit("autocommit", 0,
-				       set_option_autocommit,
-				       OPTION_NOT_AUTOCOMMIT,
-				       1);
+sys_var_thd_bit	sys_autocommit("autocommit", 0,
+			       set_option_autocommit,
+			       OPTION_NOT_AUTOCOMMIT,
+			       1);
 static sys_var_thd_bit	sys_big_tables("big_tables", 0,
 				       set_option_bit,
 				       OPTION_BIG_TABLES);

--- 1.70/sql/set_var.h	2005-09-07 12:36:58 +02:00
+++ 1.71/sql/set_var.h	2005-09-08 18:56:30 +02:00
@@ -905,6 +905,7 @@
 extern sys_var_str sys_init_connect;
 extern sys_var_str sys_init_slave;
 extern sys_var_thd_time_zone sys_time_zone;
+extern sys_var_thd_bit sys_autocommit;
 CHARSET_INFO *get_old_charset_by_name(const char *old_name);
 gptr find_named(I_List<NAMED_LIST> *list, const char *name, uint length,
 		NAMED_LIST **found);

--- 1.83/mysql-test/r/sp-error.result	2005-09-08 12:56:49 +02:00
+++ 1.84/mysql-test/r/sp-error.result	2005-09-08 18:56:30 +02:00
@@ -833,3 +833,15 @@
 ERROR 0A000: HANDLER is not allowed in stored procedures
 SELECT bug12995()|
 ERROR 42000: FUNCTION test.bug12995 does not exist
+create procedure bug12712()
+set session autocommit = 0;
+ERROR HY000: Not allowed to set 'autocommit' from a stored routine or trigger
+create procedure bug12712()
+set @@autocommit = 0;
+ERROR HY000: Not allowed to set 'autocommit' from a stored routine or trigger
+create procedure bug12712()
+set local autocommit = 0;
+ERROR HY000: Not allowed to set 'autocommit' from a stored routine 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 routine or trigger

--- 1.87/mysql-test/t/sp-error.test	2005-09-08 12:56:49 +02:00
+++ 1.88/mysql-test/t/sp-error.test	2005-09-08 18:56:30 +02:00
@@ -1138,6 +1138,24 @@
 SELECT bug12995()|
 delimiter ;|
 
+
+#
+# BUG#12712: SET AUTOCOMMIT should fail within SP/functions/triggers
+#
+--error ER_SP_CANT_SET_VAR
+create procedure bug12712()
+  set session autocommit = 0;
+--error ER_SP_CANT_SET_VAR
+create procedure bug12712()
+  set @@autocommit = 0;
+--error ER_SP_CANT_SET_VAR
+create procedure bug12712()
+  set local autocommit = 0;
+--error ER_SP_CANT_SET_VAR
+create trigger bug12712
+  before insert on t1 for each row set session autocommit = 0;
+
+
 #
 # BUG#NNNN: New bug synopsis
 #
Thread
bk commit into 5.0 tree (pem:1.1959)pem8 Sep