summaryrefslogtreecommitdiff
path: root/sql/sp_head.h
diff options
context:
space:
mode:
authorunknown <pem@mysql.com>2005-09-13 17:16:12 +0200
committerunknown <pem@mysql.com>2005-09-13 17:16:12 +0200
commit065a93773ede926d80a8f2dc772e43878304bce3 (patch)
tree0ea49f9919a82483665f1c90efb02d4d4c083545 /sql/sp_head.h
parentb5e15568aafb4f8491b6ae5e825cc4f7ca252adc (diff)
downloadmariadb-git-065a93773ede926d80a8f2dc772e43878304bce3.tar.gz
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.
Diffstat (limited to 'sql/sp_head.h')
-rw-r--r--sql/sp_head.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/sql/sp_head.h b/sql/sp_head.h
index 271119ff2fb..7c9cf364b17 100644
--- a/sql/sp_head.h
+++ b/sql/sp_head.h
@@ -114,7 +114,8 @@ public:
IN_HANDLER= 4, // Is set if the parser is in a handler body
MULTI_RESULTS= 8, // Is set if a procedure with SELECT(s)
CONTAINS_DYNAMIC_SQL= 16, // Is set if a procedure with PREPARE/EXECUTE
- IS_INVOKED= 32 // Is set if this sp_head is being used.
+ IS_INVOKED= 32, // Is set if this sp_head is being used
+ HAS_SET_AUTOCOMMIT_STMT = 64 // Is set if a procedure with 'set autocommit'
};
int m_type; // TYPE_ENUM_FUNCTION or TYPE_ENUM_PROCEDURE
@@ -282,6 +283,8 @@ public:
my_error(ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0), "Dynamic SQL");
else if (m_flags & MULTI_RESULTS)
my_error(ER_SP_NO_RETSET, MYF(0), where);
+ else if (m_flags & HAS_SET_AUTOCOMMIT_STMT)
+ my_error(ER_SP_CANT_SET_AUTOCOMMIT, MYF(0));
return test(m_flags & (CONTAINS_DYNAMIC_SQL|MULTI_RESULTS));
}
private: