From 07315d36030bd1cbe6acfeb3e8f60c49ba876a10 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 17 Apr 2013 19:42:34 +0200 Subject: strmake_buf(X,Y) helper, equivalent to strmake(X,Y,sizeof(X)-1) with a bit of lame protection against abuse. --- sql/sql_error.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql/sql_error.cc') diff --git a/sql/sql_error.cc b/sql/sql_error.cc index 06da6250e71..61281af1d0a 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -367,7 +367,7 @@ Diagnostics_area::set_ok_status(THD *thd, ulonglong affected_rows_arg, m_affected_rows= affected_rows_arg; m_last_insert_id= last_insert_id_arg; if (message_arg) - strmake(m_message, message_arg, sizeof(m_message) - 1); + strmake_buf(m_message, message_arg); else m_message[0]= '\0'; m_status= DA_OK; @@ -435,7 +435,7 @@ Diagnostics_area::set_error_status(THD *thd, uint sql_errno_arg, m_sql_errno= sql_errno_arg; memcpy(m_sqlstate, sqlstate, SQLSTATE_LENGTH); m_sqlstate[SQLSTATE_LENGTH]= '\0'; - strmake(m_message, message_arg, sizeof(m_message)-1); + strmake_buf(m_message, message_arg); m_status= DA_ERROR; DBUG_VOID_RETURN; -- cgit v1.2.1 From d4be9e7bc0cfd5ddd444ecc64daa4166597ca2eb Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 6 May 2013 16:51:41 +0300 Subject: If one declared several continue handler for the same condition on different level of stored procedures, all of them where executed. Now we only execute the innermost of them (the most relevant). The solution was to add a 'handled' marker to MYSQL_ERROR and mark all elements for which we have executed a condition handler. When searching for new conditions, we will ignore any marked element. .bzrignore: Ignore error message file mysql-test/r/sp.result: Added testcase for continue handlers. mysql-test/t/sp.test: Added testcase for continue handlers. sql/sp_head.cc: Mark errors for which we will excute a handler as 'handled' Ignore already handled warnings/errors sql/sql_error.cc: Add 'handled' argument to MYSQL_ERROR, so that we can mark the errors/warnings we have handled. sql/sql_error.h: Add 'handled' argument to MYSQL_ERROR, so that we can mark the errors/warnings we have handled. --- sql/sql_error.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sql/sql_error.cc') diff --git a/sql/sql_error.cc b/sql/sql_error.cc index 61281af1d0a..a4f5b210285 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -185,6 +185,7 @@ MYSQL_ERROR::MYSQL_ERROR() m_cursor_name((const char*) NULL, 0, & my_charset_utf8_bin), m_message_text(), m_sql_errno(0), + m_handled(0), m_level(MYSQL_ERROR::WARN_LEVEL_ERROR), m_mem_root(NULL) { @@ -212,6 +213,7 @@ void MYSQL_ERROR::clear() m_cursor_name.length(0); m_message_text.length(0); m_sql_errno= 0; + m_handled= 0; m_level= MYSQL_ERROR::WARN_LEVEL_ERROR; } @@ -229,6 +231,7 @@ MYSQL_ERROR::MYSQL_ERROR(MEM_ROOT *mem_root) m_cursor_name((const char*) NULL, 0, & my_charset_utf8_bin), m_message_text(), m_sql_errno(0), + m_handled(0), m_level(MYSQL_ERROR::WARN_LEVEL_ERROR), m_mem_root(mem_root) { @@ -267,6 +270,7 @@ MYSQL_ERROR::copy_opt_attributes(const MYSQL_ERROR *cond) copy_string(m_mem_root, & m_table_name, & cond->m_table_name); copy_string(m_mem_root, & m_column_name, & cond->m_column_name); copy_string(m_mem_root, & m_cursor_name, & cond->m_cursor_name); + m_handled= cond->m_handled; } void -- cgit v1.2.1