summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorAlfranio Correia <alfranio.correia@sun.com>2009-07-28 18:44:38 +0100
committerAlfranio Correia <alfranio.correia@sun.com>2009-07-28 18:44:38 +0100
commit043e09b5433df9b9b0d4a14cb94cd979984a4b0a (patch)
treefabc16f145fee1a240be8559a0e326fedfda69fa /sql/item_func.cc
parent422696d673dececd0feb54c28d05327bf4825834 (diff)
downloadmariadb-git-043e09b5433df9b9b0d4a14cb94cd979984a4b0a.tar.gz
BUG#41166 stored function requires "deterministic" if binlog_format is "statement"
If the log_bin_trust_function_creators option is not defined, creating a stored function requires either one of the modifiers DETERMINISTIC, NO SQL, or READS SQL DATA. Executing a stored function should also follows the same rules if in STATEMENT mode. However, this was not happening and a wrong error was being printed out: ER_BINLOG_ROW_RBR_TO_SBR. The patch makes the creation and execution compatible and prints out the correct error ER_BINLOG_UNSAFE_ROUTINE when a stored function without one of the modifiers above is executed in STATEMENT mode.
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 0af3c4954cd..55d4b37ddb0 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -5990,6 +5990,9 @@ Item_func_sp::execute_impl(THD *thd)
#ifndef NO_EMBEDDED_ACCESS_CHECKS
Security_context *save_security_ctx= thd->security_ctx;
#endif
+ enum enum_sp_data_access access=
+ (m_sp->m_chistics->daccess == SP_DEFAULT_ACCESS) ?
+ SP_DEFAULT_ACCESS_MAPPING : m_sp->m_chistics->daccess;
DBUG_ENTER("Item_func_sp::execute_impl");
@@ -6007,11 +6010,13 @@ Item_func_sp::execute_impl(THD *thd)
Throw an error if a non-deterministic function is called while
statement-based replication (SBR) is active.
*/
+
if (!m_sp->m_chistics->detistic && !trust_function_creators &&
+ (access == SP_CONTAINS_SQL || access == SP_MODIFIES_SQL_DATA) &&
(mysql_bin_log.is_open() &&
thd->variables.binlog_format == BINLOG_FORMAT_STMT))
{
- my_error(ER_BINLOG_ROW_RBR_TO_SBR, MYF(0));
+ my_error(ER_BINLOG_UNSAFE_ROUTINE, MYF(0));
goto error;
}