summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMikael Ronström <mikael@dator9>2011-05-19 10:49:43 +0200
committerMikael Ronström <mikael@dator9>2011-05-19 10:49:43 +0200
commitc51c4a77afb46aaf706c9c540fec9064a9d2997a (patch)
tree96b106b875a33beafadd90ada5a0d593ef5f0f2e /sql
parenta922909a898ec2d238f427c34442cf5d0a3a7823 (diff)
parent47f7fc4353f4ee665b703bee6479ad1664db0f48 (diff)
downloadmariadb-git-c51c4a77afb46aaf706c9c540fec9064a9d2997a.tar.gz
merge
Diffstat (limited to 'sql')
-rw-r--r--sql/item_timefunc.cc9
-rw-r--r--sql/mysqld.h8
-rw-r--r--sql/sql_acl.cc1
-rw-r--r--sql/sql_class.cc19
-rw-r--r--sql/sql_class.h1
5 files changed, 36 insertions, 2 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 0952a5448e4..b31a388bea4 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -1591,6 +1591,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;
}
@@ -2779,7 +2784,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)
@@ -2822,7 +2827,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)
diff --git a/sql/mysqld.h b/sql/mysqld.h
index 303ee5bec0f..d2366224b3f 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -216,6 +216,10 @@ extern char err_shared_dir[];
extern TYPELIB thread_handling_typelib;
extern my_decimal decimal_zero;
+/*
+ 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);
#ifdef HAVE_PSI_INTERFACE
@@ -503,6 +507,10 @@ get_thread_running()
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)
{
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 18758130767..0eb05489015 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -3644,6 +3644,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
{ // Should never happen
/* Restore the state of binlog format */
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
+ thd->lex->restore_backup_query_tables_list(&backup);
if (save_binlog_row_based)
thd->set_current_stmt_binlog_format_row();
DBUG_RETURN(TRUE); /* purecov: deadcode */
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 2646cc82717..9636dc50ee4 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -1600,6 +1600,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.
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 71b1a7d4c1c..a2c622b2326 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -2199,6 +2199,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)
{