Commit 71468996 authored by msvensson@shellback.(none)'s avatar msvensson@shellback.(none)

Merge bk-internal.mysql.com:/home/bk/mysql-5.1-new

into  shellback.(none):/home/msvensson/mysql/mysql-5.1
parents f8ee9e47 8ebf8db6
...@@ -48,7 +48,7 @@ ADD_LIBRARY(mysqlclient ../mysys/array.c ../strings/bchange.c ../strings/bmove.c ...@@ -48,7 +48,7 @@ ADD_LIBRARY(mysqlclient ../mysys/array.c ../strings/bchange.c ../strings/bmove.c
../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c ../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c
../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c) ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c)
ADD_DEPENDENCIES(mysqlclient comp_err) ADD_DEPENDENCIES(mysqlclient GenError)
ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc) ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc)
LINK_DIRECTORIES(${MYSQL_BINARY_DIR}/mysys ${MYSQL_BINARY_DIR}/zlib) LINK_DIRECTORIES(${MYSQL_BINARY_DIR}/mysys ${MYSQL_BINARY_DIR}/zlib)
TARGET_LINK_LIBRARIES(mysql mysqlclient mysys yassl zlib dbug yassl taocrypt wsock32) TARGET_LINK_LIBRARIES(mysql mysqlclient mysys yassl zlib dbug yassl taocrypt wsock32)
......
...@@ -16,8 +16,11 @@ ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/include/mysqld_error.h ...@@ -16,8 +16,11 @@ ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/include/mysqld_error.h
--name_file=${PROJECT_SOURCE_DIR}/include/mysqld_ername.h --name_file=${PROJECT_SOURCE_DIR}/include/mysqld_ername.h
--state_file=${PROJECT_SOURCE_DIR}/include/sql_state.h --state_file=${PROJECT_SOURCE_DIR}/include/sql_state.h
--in_file=${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt --in_file=${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt
MAIN_DEPENDENCY comp_err DEPENDS comp_err ${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt)
DEPENDS ${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt)
ADD_CUSTOM_TARGET(GenError
ALL
DEPENDS ${PROJECT_SOURCE_DIR}/include/mysqld_error.h)
ADD_EXECUTABLE(my_print_defaults my_print_defaults.c) ADD_EXECUTABLE(my_print_defaults my_print_defaults.c)
TARGET_LINK_LIBRARIES(my_print_defaults strings mysys dbug taocrypt odbc32 odbccp32 wsock32) TARGET_LINK_LIBRARIES(my_print_defaults strings mysys dbug taocrypt odbc32 odbccp32 wsock32)
......
...@@ -45,7 +45,7 @@ ADD_LIBRARY(libmysql MODULE dll.c libmysql.def ...@@ -45,7 +45,7 @@ ADD_LIBRARY(libmysql MODULE dll.c libmysql.def
../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c ../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c
../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c ../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c
../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c) ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c)
ADD_DEPENDENCIES(libmysql dbug vio mysys strings comp_err zlib) ADD_DEPENDENCIES(libmysql dbug vio mysys strings GenError zlib)
TARGET_LINK_LIBRARIES(libmysql mysys strings wsock32) TARGET_LINK_LIBRARIES(libmysql mysys strings wsock32)
# ToDo: We should move the mytest.c program out in libmysql/ # ToDo: We should move the mytest.c program out in libmysql/
......
create database if not exists events_test; create database if not exists events_test;
use events_test; use events_test;
set @a=3;
CREATE PROCEDURE p_16 () CREATE EVENT e_16 ON SCHEDULE EVERY @a SECOND DO SET @a=5;
call p_16();
"Here we used to crash!"
call p_16();
ERROR HY000: Event 'e_16' already exists
call p_16();
ERROR HY000: Event 'e_16' already exists
DROP EVENT e_16;
CALL p_16();
CALL p_16();
ERROR HY000: Event 'e_16' already exists
DROP PROCEDURE p_16;
DROP EVENT e_16;
set global event_scheduler=0; set global event_scheduler=0;
"Wait a bit to settle down" "Wait a bit to settle down"
delete from mysql.event; delete from mysql.event;
......
create database if not exists events_test; create database if not exists events_test;
use events_test; use events_test;
#
# START - BUG#16408: Events: crash for an event in a procedure
#
set @a=3;
CREATE PROCEDURE p_16 () CREATE EVENT e_16 ON SCHEDULE EVERY @a SECOND DO SET @a=5;
call p_16();
--echo "Here we used to crash!"
--error 1516
call p_16();
--error 1516
call p_16();
DROP EVENT e_16;
CALL p_16();
--error 1516
CALL p_16();
DROP PROCEDURE p_16;
DROP EVENT e_16;
#
# END - BUG#16408: Events: crash for an event in a procedure
#
# #
# Start - 16407: Events: Changes in sql_mode won't be taken into account # Start - 16407: Events: Changes in sql_mode won't be taken into account
# #
......
...@@ -12,5 +12,5 @@ ADD_EXECUTABLE(mysqlmanager buffer.cc command.cc commands.cc guardian.cc instanc ...@@ -12,5 +12,5 @@ ADD_EXECUTABLE(mysqlmanager buffer.cc command.cc commands.cc guardian.cc instanc
../../sql/sql_state.c ../../sql-common/client.c ../../libmysql/get_password.c ../../sql/sql_state.c ../../sql-common/client.c ../../libmysql/get_password.c
../../libmysql/errmsg.c) ../../libmysql/errmsg.c)
ADD_DEPENDENCIES(mysqlmanager comp_err) ADD_DEPENDENCIES(mysqlmanager GenError)
TARGET_LINK_LIBRARIES(mysqlmanager dbug mysys strings taocrypt vio yassl zlib wsock32) TARGET_LINK_LIBRARIES(mysqlmanager dbug mysys strings taocrypt vio yassl zlib wsock32)
...@@ -50,7 +50,7 @@ ADD_EXECUTABLE(mysqld ../sql-common/client.c derror.cc des_key_file.cc discover. ...@@ -50,7 +50,7 @@ ADD_EXECUTABLE(mysqld ../sql-common/client.c derror.cc des_key_file.cc discover.
${PROJECT_SOURCE_DIR}/sql/handlerton.cc ${PROJECT_SOURCE_DIR}/sql/handlerton.cc
${PROJECT_SOURCE_DIR}/sql/lex_hash.h) ${PROJECT_SOURCE_DIR}/sql/lex_hash.h)
TARGET_LINK_LIBRARIES(mysqld heap myisam myisammrg innobase mysys yassl zlib dbug yassl taocrypt strings vio regex wsock32) TARGET_LINK_LIBRARIES(mysqld heap myisam myisammrg innobase mysys yassl zlib dbug yassl taocrypt strings vio regex wsock32)
ADD_DEPENDENCIES(mysqld comp_err) ADD_DEPENDENCIES(mysqld GenError)
# Sql Parser custom command # Sql Parser custom command
ADD_CUSTOM_COMMAND( ADD_CUSTOM_COMMAND(
......
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
#define EVENT_EXEC_NO_MORE (1L << 0) #define EVENT_EXEC_NO_MORE (1L << 0)
#define EVENT_NOT_USED (1L << 1) #define EVENT_NOT_USED (1L << 1)
extern ulong opt_event_executor; extern ulong opt_event_executor;
enum enum_event_on_completion enum enum_event_on_completion
...@@ -122,6 +121,39 @@ class Event_timed ...@@ -122,6 +121,39 @@ class Event_timed
bool free_sphead_on_delete; bool free_sphead_on_delete;
uint flags;//all kind of purposes uint flags;//all kind of purposes
static void *operator new(size_t size)
{
void *p;
DBUG_ENTER("Event_timed::new(size)");
p= my_malloc(size, MYF(0));
DBUG_PRINT("info", ("alloc_ptr=0x%lx", p));
DBUG_RETURN(p);
}
static void *operator new(size_t size, MEM_ROOT *mem_root)
{ return (void*) alloc_root(mem_root, (uint) size); }
static void operator delete(void *ptr, size_t size)
{
DBUG_ENTER("Event_timed::delete(ptr,size)");
DBUG_PRINT("enter", ("free_ptr=0x%lx", ptr));
TRASH(ptr, size);
my_free((gptr) ptr, MYF(0));
DBUG_VOID_RETURN;
}
static void operator delete(void *ptr, MEM_ROOT *mem_root)
{
/*
Don't free the memory it will be done by the mem_root but
we need to call the destructor because we free other resources
which are not allocated on the root but on the heap, or we
deinit mutexes.
*/
DBUG_ASSERT(0);
}
Event_timed():in_spawned_thread(0),locked_by_thread_id(0), Event_timed():in_spawned_thread(0),locked_by_thread_id(0),
running(0), status_changed(false), running(0), status_changed(false),
last_executed_changed(false), expression(0), created(0), last_executed_changed(false), expression(0), created(0),
...@@ -136,15 +168,21 @@ class Event_timed ...@@ -136,15 +168,21 @@ class Event_timed
} }
~Event_timed() ~Event_timed()
{ {
pthread_mutex_destroy(&this->LOCK_running); deinit_mutexes();
if (free_sphead_on_delete) if (free_sphead_on_delete)
free_sp(); free_sp();
} }
void void
init(); init();
void
deinit_mutexes()
{
pthread_mutex_destroy(&this->LOCK_running);
}
int int
init_definer(THD *thd); init_definer(THD *thd);
......
...@@ -1228,12 +1228,12 @@ Event_timed::change_security_context(THD *thd, Security_context *s_ctx, ...@@ -1228,12 +1228,12 @@ Event_timed::change_security_context(THD *thd, Security_context *s_ctx,
definer_host.str, dbname.str)) definer_host.str, dbname.str))
{ {
my_error(ER_NO_SUCH_USER, MYF(0), definer_user.str, definer_host.str); my_error(ER_NO_SUCH_USER, MYF(0), definer_user.str, definer_host.str);
DBUG_RETURN(TRUE); DBUG_RETURN(true);
} }
*backup= thd->security_ctx; *backup= thd->security_ctx;
thd->security_ctx= s_ctx; thd->security_ctx= s_ctx;
#endif #endif
DBUG_RETURN(FALSE); DBUG_RETURN(false);
} }
...@@ -1368,7 +1368,8 @@ Event_timed::compile(THD *thd, MEM_ROOT *mem_root) ...@@ -1368,7 +1368,8 @@ Event_timed::compile(THD *thd, MEM_ROOT *mem_root)
ret= 0; ret= 0;
done: done:
lex.et->free_sphead_on_delete= false; lex.et->free_sphead_on_delete= false;
delete lex.et; lex.et->deinit_mutexes();
lex_end(&lex); lex_end(&lex);
DBUG_PRINT("note", ("return old data on its place. set back NAMES")); DBUG_PRINT("note", ("return old data on its place. set back NAMES"));
......
...@@ -3803,10 +3803,14 @@ mysql_execute_command(THD *thd) ...@@ -3803,10 +3803,14 @@ mysql_execute_command(THD *thd)
send_ok(thd, rows_affected); send_ok(thd, rows_affected);
/* lex->unit.cleanup() is called outside, no need to call it here */ /* lex->unit.cleanup() is called outside, no need to call it here */
} while (0); } while (0);
lex->et->free_sphead_on_delete= true; if (!thd->spcont)
delete lex->et; {
lex->et= 0; lex->et->free_sphead_on_delete= true;
lex->et->free_sp();
lex->et->deinit_mutexes();
}
break; break;
} }
case SQLCOM_SHOW_CREATE_EVENT: case SQLCOM_SHOW_CREATE_EVENT:
...@@ -5845,7 +5849,9 @@ void mysql_parse(THD *thd, char *inBuf, uint length) ...@@ -5845,7 +5849,9 @@ void mysql_parse(THD *thd, char *inBuf, uint length)
if (thd->lex->et) if (thd->lex->et)
{ {
thd->lex->et->free_sphead_on_delete= true; thd->lex->et->free_sphead_on_delete= true;
delete thd->lex->et; /* alloced on thd->mem_root so no real memory free but dtor call */
thd->lex->et->free_sp();
thd->lex->et->deinit_mutexes();
thd->lex->et= NULL; thd->lex->et= NULL;
} }
} }
...@@ -5886,7 +5892,8 @@ void mysql_parse(THD *thd, char *inBuf, uint length) ...@@ -5886,7 +5892,8 @@ void mysql_parse(THD *thd, char *inBuf, uint length)
if (thd->lex->et) if (thd->lex->et)
{ {
thd->lex->et->free_sphead_on_delete= true; thd->lex->et->free_sphead_on_delete= true;
delete thd->lex->et; lex->et->free_sp();
lex->et->deinit_mutexes();
thd->lex->et= NULL; thd->lex->et= NULL;
} }
} }
......
...@@ -1275,7 +1275,7 @@ create: ...@@ -1275,7 +1275,7 @@ create:
lex->create_info.options= $3; lex->create_info.options= $3;
if (!(lex->et= new Event_timed())) // implicitly calls Event_timed::init() if (!(lex->et= new(YYTHD->mem_root) Event_timed())) // implicitly calls Event_timed::init()
YYABORT; YYABORT;
/* /*
...@@ -4813,7 +4813,7 @@ alter: ...@@ -4813,7 +4813,7 @@ alter:
} }
lex->spname= 0;//defensive programming lex->spname= 0;//defensive programming
if (!(et= new Event_timed()))// implicitly calls Event_timed::init() if (!(et= new (YYTHD->mem_root) Event_timed()))// implicitly calls Event_timed::init()
YYABORT; YYABORT;
lex->et = et; lex->et = et;
...@@ -7717,7 +7717,7 @@ drop: ...@@ -7717,7 +7717,7 @@ drop:
YYABORT; YYABORT;
} }
if (!(lex->et= new Event_timed())) if (!(lex->et= new (YYTHD->mem_root) Event_timed()))
YYABORT; YYABORT;
if (!lex->et_compile_phase) if (!lex->et_compile_phase)
...@@ -8441,7 +8441,7 @@ show_param: ...@@ -8441,7 +8441,7 @@ show_param:
{ {
Lex->sql_command = SQLCOM_SHOW_CREATE_EVENT; Lex->sql_command = SQLCOM_SHOW_CREATE_EVENT;
Lex->spname= $3; Lex->spname= $3;
Lex->et= new Event_timed(); Lex->et= new (YYTHD->mem_root) Event_timed();
if (!Lex->et) if (!Lex->et)
YYABORT; YYABORT;
Lex->et->init_definer(YYTHD); Lex->et->init_definer(YYTHD);
......
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