Commit 06115abd authored by Guilhem Bichot's avatar Guilhem Bichot

merge from latest 5.1

parents 12c42b98 733893ba
......@@ -51,6 +51,23 @@ extern "C" void unireg_clear(int exit_code)
DBUG_VOID_RETURN;
}
/*
Wrapper error handler for embedded server to call client/server error
handler based on whether thread is in client/server context
*/
static int embedded_error_handler(uint error, const char *str, myf MyFlags)
{
DBUG_ENTER("embedded_error_handler");
/*
If current_thd is NULL, it means restore_global has been called and
thread is in client context, then call client error handler else call
server error handler.
*/
DBUG_RETURN(current_thd ? my_message_sql(error, str, MyFlags):
my_message_no_curses(error, str, MyFlags));
}
/*
Reads error information from the MYSQL_DATA and puts
......@@ -107,7 +124,8 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
if (mysql->status != MYSQL_STATUS_READY)
{
set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);
return 1;
result= 1;
goto end;
}
/* Clear result variables */
......@@ -147,6 +165,9 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
thd->profiling.finish_current_query();
#endif
end:
thd->restore_globals();
return result;
}
......@@ -525,7 +546,10 @@ int init_embedded_server(int argc, char **argv, char **groups)
return 1;
}
error_handler_hook = my_message_sql;
/*
set error_handler_hook to embedded_error_handler wrapper.
*/
error_handler_hook= embedded_error_handler;
acl_error= 0;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
......
......@@ -1417,4 +1417,13 @@ NULL
SELECT DATE_FORMAT('0000-00-11', '%w');
DATE_FORMAT('0000-00-11', '%w')
NULL
#
# Bug#12403504 AFTER FIX FOR #11889186 : ASSERTION FAILED: DELSUM+(INT) Y/4-TEMP > 0
#
SELECT MAKEDATE(11111111,1);
MAKEDATE(11111111,1)
NULL
SELECT WEEK(DATE_ADD(FROM_DAYS(1),INTERVAL 1 MONTH), 1);
WEEK(DATE_ADD(FROM_DAYS(1),INTERVAL 1 MONTH), 1)
NULL
End of 5.1 tests
include/master-slave.inc
[connection master]
stop slave;
include/stop_slave.inc
create table t1 (a int);
drop table t1;
create table t1 (a int);
......@@ -8,10 +8,8 @@ drop table t1;
reset slave;
start slave io_thread;
include/wait_for_slave_param.inc [Slave_IO_State]
stop slave io_thread;
include/stop_slave_io.inc
reset slave;
start slave;
select master_pos_wait('master-bin.001',200,6)=-1;
master_pos_wait('master-bin.001',200,6)=-1
0
include/start_slave.inc
include/assert.inc [Assert that master_pos_wait does not timeout nor it returns NULL]
include/rpl_end.inc
......@@ -2,8 +2,9 @@
# to force the deadlock after one event.
source include/master-slave.inc;
--let $master_log_file= query_get_value(SHOW MASTER STATUS, File, 1)
connection slave;
stop slave;
--source include/stop_slave.inc
connection master;
# This will generate a master's binlog > 10 bytes
create table t1 (a int);
......@@ -19,20 +20,33 @@ let $slave_param_value= Waiting for the slave SQL thread to free enough relay lo
source include/wait_for_slave_param.inc;
# A bug caused the I/O thread to refuse stopping.
stop slave io_thread;
--source include/stop_slave_io.inc
reset slave;
start slave;
# The I/O thread stops filling the relay log when
# it's >10b. And the SQL thread cannot purge this relay log
# as purge is done only when the SQL thread switches to another
# relay log, which does not exist here.
# So we should have a deadlock.
# if it is not resolved automatically we'll detect
# it with master_pos_wait that waits for farther than 1Ob;
# it will timeout after 10 seconds;
# also the slave will probably not cooperate to shutdown
# (as 2 threads are locked)
select master_pos_wait('master-bin.001',200,6)=-1;
--source include/start_slave.inc
# The I/O thread stops filling the relay log when it's >10b. And the
# SQL thread cannot purge this relay log as purge is done only when
# the SQL thread switches to another relay log, which does not exist
# here. So we should have a deadlock. If it is not resolved
# automatically we'll detect it with master_pos_wait that waits for
# farther than 1Ob; it will timeout after 300 seconds (which is inline
# with the default used for sync_slave_with_master and will protect us
# against slow test envs); also the slave will probably not cooperate
# to shutdown (as 2 threads are locked)
--let $outcome= `SELECT MASTER_POS_WAIT('$master_log_file',200,300) AS mpw;`
# master_pos_wait returns:
#
# * >= 0, the number of events the slave had to wait to advance to the
# position
#
# * -1, if there was a timeout
#
# * NULL, if an error occurred, or the SQL thread was not started,
# slave master info is not initialized, the arguments are incorrect
--let $assert_text= Assert that master_pos_wait does not timeout nor it returns NULL
--let $assert_cond= $outcome IS NOT NULL AND $outcome <> -1
--source include/assert.inc
# End of 4.1 tests
--source include/rpl_end.inc
......@@ -921,4 +921,11 @@ SELECT DATE_FORMAT('0000-00-11', '%W');
SELECT DATE_FORMAT('0000-00-11', '%a');
SELECT DATE_FORMAT('0000-00-11', '%w');
--echo #
--echo # Bug#12403504 AFTER FIX FOR #11889186 : ASSERTION FAILED: DELSUM+(INT) Y/4-TEMP > 0
--echo #
SELECT MAKEDATE(11111111,1);
SELECT WEEK(DATE_ADD(FROM_DAYS(1),INTERVAL 1 MONTH), 1);
--echo End of 5.1 tests
......@@ -1519,6 +1519,11 @@ bool Item_func_from_days::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
return 1;
bzero(ltime, sizeof(MYSQL_TIME));
get_date_from_daynr((long) value, &ltime->year, &ltime->month, &ltime->day);
if ((null_value= (fuzzy_date & TIME_NO_ZERO_DATE) &&
(ltime->year == 0 || ltime->month == 0 || ltime->day == 0)))
return TRUE;
ltime->time_type= MYSQL_TIMESTAMP_DATE;
return 0;
}
......@@ -2697,7 +2702,7 @@ String *Item_func_makedate::val_str(String *str)
long days;
if (args[0]->null_value || args[1]->null_value ||
year < 0 || daynr <= 0)
year < 0 || year > 9999 || daynr <= 0)
goto err;
if (year < 100)
......@@ -2740,7 +2745,7 @@ longlong Item_func_makedate::val_int()
long days;
if (args[0]->null_value || args[1]->null_value ||
year < 0 || daynr <= 0)
year < 0 || year > 9999 || daynr <= 0)
goto err;
if (year < 100)
......
......@@ -670,6 +670,10 @@ enum enum_check_fields
extern "C" THD *_current_thd_noinline();
#define _current_thd() _current_thd_noinline()
#else
/*
THR_THD is a key which will be used to set/get THD* for a thread,
using my_pthread_setspecific_ptr()/my_thread_getspecific_ptr().
*/
extern pthread_key(THD*, THR_THD);
inline THD *_current_thd(void)
{
......@@ -2022,6 +2026,10 @@ extern TABLE_LIST general_log, slow_log;
extern FILE *bootstrap_file;
extern int bootstrap_error;
extern FILE *stderror_file;
/*
THR_MALLOC is a key which will be used to set/get MEM_ROOT** for a thread,
using my_pthread_setspecific_ptr()/my_thread_getspecific_ptr().
*/
extern pthread_key(MEM_ROOT**,THR_MALLOC);
extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open, LOCK_lock_db,
LOCK_mapped_file,LOCK_user_locks, LOCK_status,
......
......@@ -1195,6 +1195,25 @@ bool THD::store_globals()
return 0;
}
/*
Remove the thread specific info (THD and mem_root pointer) stored during
store_global call for this thread.
*/
bool THD::restore_globals()
{
/*
Assert that thread_stack is initialized: it's necessary to be able
to track stack overrun.
*/
DBUG_ASSERT(thread_stack);
/* Undocking the thread specific data. */
my_pthread_setspecific_ptr(THR_THD, NULL);
my_pthread_setspecific_ptr(THR_MALLOC, NULL);
return 0;
}
/*
Cleanup after query.
......
......@@ -1943,6 +1943,7 @@ public:
void cleanup(void);
void cleanup_after_query();
bool store_globals();
bool restore_globals();
#ifdef SIGNAL_WITH_VIO_CLOSE
inline void set_active_vio(Vio* vio)
{
......
This diff is collapsed.
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