Commit e42a24e5 authored by Dmitry Shulga's avatar Dmitry Shulga

Manual merge of patch for bug#11756013 from mysql-5.1 tree.

parents 7545f866 bc7af175
Tests of syncronization of stored procedure execution.
Tests of synchronization of stored procedure execution.
SET DEBUG_SYNC= 'RESET';
#
# Bug #30977 Concurrent statement using stored function and
......@@ -92,4 +92,16 @@ COUNT(f1(a))
DROP PROCEDURE p1;
DROP FUNCTION f1;
DROP TABLES t0, t1;
SET DEBUG_SYNC= 'RESET';
#
# test for bug#11756013
#
DROP SCHEMA IF EXISTS s1;
CREATE SCHEMA s1;
CREATE PROCEDURE s1.p1() BEGIN END;
SET DEBUG_SYNC='before_db_dir_check SIGNAL check_db WAIT_FOR dropped_schema';
CALL s1.p1;
SET DEBUG_SYNC='now WAIT_FOR check_db';
DROP SCHEMA s1;
SET DEBUG_SYNC='now SIGNAL dropped_schema';
ERROR 42000: Unknown database 's1'
SET DEBUG_SYNC = 'RESET';
# This test should work in embedded server after mysqltest is fixed
-- source include/not_embedded.inc
--echo Tests of syncronization of stored procedure execution.
--echo Tests of synchronization of stored procedure execution.
--source include/have_debug_sync.inc
......@@ -149,9 +149,34 @@ disconnect con2;
DROP PROCEDURE p1;
DROP FUNCTION f1;
DROP TABLES t0, t1;
SET DEBUG_SYNC= 'RESET';
--echo #
--echo # test for bug#11756013
--echo #
--disable_warnings
DROP SCHEMA IF EXISTS s1;
--enable_warnings
CREATE SCHEMA s1;
CREATE PROCEDURE s1.p1() BEGIN END;
connect (con3, localhost, root);
SET DEBUG_SYNC='before_db_dir_check SIGNAL check_db WAIT_FOR dropped_schema';
--send CALL s1.p1
connection default;
SET DEBUG_SYNC='now WAIT_FOR check_db';
DROP SCHEMA s1;
SET DEBUG_SYNC='now SIGNAL dropped_schema';
connection con3;
--error ER_BAD_DB_ERROR
--reap
connection default;
disconnect con3;
SET DEBUG_SYNC = 'RESET';
# Check that all connections opened by test cases in this file are really
# gone so execution of other tests won't be affected by their presence.
--source include/wait_until_count_sessions.inc
......@@ -756,6 +756,43 @@ static sp_head *sp_compile(THD *thd, String *defstr, ulong sql_mode,
}
class Bad_db_error_handler : public Internal_error_handler
{
public:
Bad_db_error_handler()
:m_error_caught(false)
{}
virtual bool handle_condition(THD *thd,
uint sql_errno,
const char* sqlstate,
MYSQL_ERROR::enum_warning_level level,
const char* message,
MYSQL_ERROR ** cond_hdl);
bool error_caught() const { return m_error_caught; }
private:
bool m_error_caught;
};
bool
Bad_db_error_handler::handle_condition(THD *thd,
uint sql_errno,
const char* sqlstate,
MYSQL_ERROR::enum_warning_level level,
const char* message,
MYSQL_ERROR ** cond_hdl)
{
if (sql_errno == ER_BAD_DB_ERROR)
{
m_error_caught= true;
return true;
}
return false;
}
static int
db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
ulong sql_mode, const char *params, const char *returns,
......@@ -769,7 +806,7 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
LEX_STRING saved_cur_db_name=
{ saved_cur_db_name_buf, sizeof(saved_cur_db_name_buf) };
bool cur_db_changed;
Bad_db_error_handler db_not_exists_handler;
char definer_user_name_holder[USERNAME_LENGTH + 1];
LEX_STRING definer_user_name= { definer_user_name_holder,
USERNAME_LENGTH };
......@@ -808,6 +845,7 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
goto end;
}
thd->push_internal_handler(&db_not_exists_handler);
/*
Change the current database (if needed).
......@@ -818,6 +856,15 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
&cur_db_changed))
{
ret= SP_INTERNAL_ERROR;
thd->pop_internal_handler();
goto end;
}
thd->pop_internal_handler();
if (db_not_exists_handler.error_caught())
{
ret= SP_INTERNAL_ERROR;
my_error(ER_BAD_DB_ERROR, MYF(0), name->m_db.str);
goto end;
}
......
......@@ -39,6 +39,7 @@
#ifdef __WIN__
#include <direct.h>
#endif
#include "debug_sync.h"
#define MAX_DROP_TABLE_Q_LEN 1024
......@@ -1536,6 +1537,8 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch)
}
#endif
DEBUG_SYNC(thd, "before_db_dir_check");
if (check_db_dir_existence(new_db_file_name.str))
{
if (force_switch)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment