Adding the timezone plugin service, to convert between

MYSQL_TIME and my_time_t and back.

Using the new service instead of direct access to thd.

added:
  include/mysql/service_thd_timezone.h
  libservices/thd_timezone_service.c
modified:
  include/my_time.h
  include/mysql.h.pp
  include/mysql/plugin.h
  include/mysql/plugin_audit.h.pp
  include/mysql/plugin_auth.h.pp
  include/mysql/plugin_ftparser.h.pp
  include/mysql/services.h
  include/mysql_time.h
  include/service_versions.h
  libservices/CMakeLists.txt
  sql/sql_class.cc
  sql/sql_plugin_services.h
  storage/connect/value.cpp
This commit is contained in:
Alexander Barkov 2013-05-24 19:09:59 +04:00
commit 32bd0c7d1f
15 changed files with 203 additions and 17 deletions

View file

@ -35,6 +35,7 @@
#include "sql_cache.h" // query_cache_abort
#include "sql_base.h" // close_thread_tables
#include "sql_time.h" // date_time_format_copy
#include "tztime.h" // MYSQL_TIME <-> my_time_t
#include "sql_acl.h" // NO_ACCESS,
// acl_getroot_no_password
#include "sql_base.h" // close_temporary_tables
@ -1261,6 +1262,26 @@ void thd_get_xid(const MYSQL_THD thd, MYSQL_XID *xid)
*xid = *(MYSQL_XID *) &thd->transaction.xid_state.xid;
}
extern "C"
my_time_t thd_TIME_to_gmt_sec(MYSQL_THD thd, const MYSQL_TIME *ltime,
unsigned int *errcode)
{
Time_zone *tz= thd ? thd->variables.time_zone :
global_system_variables.time_zone;
return tz->TIME_to_gmt_sec(ltime, errcode);
}
extern "C"
void thd_gmt_sec_to_TIME(MYSQL_THD thd, MYSQL_TIME *ltime, my_time_t t)
{
Time_zone *tz= thd ? thd->variables.time_zone :
global_system_variables.time_zone;
tz->gmt_sec_to_TIME(ltime, t);
}
#ifdef _WIN32
extern "C" THD *_current_thd_noinline(void)
{

View file

@ -54,6 +54,11 @@ static struct kill_statement_service_st thd_kill_statement_handler= {
thd_kill_level
};
static struct thd_timezone_service_st thd_timezone_handler= {
thd_TIME_to_gmt_sec,
thd_gmt_sec_to_TIME
};
static struct st_service_ref list_of_services[]=
{
{ "my_snprintf_service", VERSION_my_snprintf, &my_snprintf_handler },
@ -61,6 +66,7 @@ static struct st_service_ref list_of_services[]=
{ "thd_wait_service", VERSION_thd_wait, &thd_wait_handler },
{ "progress_report_service", VERSION_progress_report, &progress_report_handler },
{ "debug_sync_service", VERSION_debug_sync, 0 }, // updated in plugin_init()
{ "thd_kill_statement_service", VERSION_kill_statement, &thd_kill_statement_handler }
{ "thd_kill_statement_service", VERSION_kill_statement, &thd_kill_statement_handler },
{ "thd_timezone_service", VERSION_thd_timezone, &thd_timezone_handler },
};