Browse Source
Adding the timezone plugin service, to convert between
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.cpppull/3/head
15 changed files with 203 additions and 17 deletions
-
10include/my_time.h
-
1include/mysql.h.pp
-
2include/mysql/plugin.h
-
22include/mysql/plugin_audit.h.pp
-
22include/mysql/plugin_auth.h.pp
-
22include/mysql/plugin_ftparser.h.pp
-
74include/mysql/service_thd_timezone.h
-
1include/mysql/services.h
-
11include/mysql_time.h
-
2include/service_versions.h
-
1libservices/CMakeLists.txt
-
18libservices/thd_timezone_service.c
-
21sql/sql_class.cc
-
8sql/sql_plugin_services.h
-
5storage/connect/value.cpp
@ -0,0 +1,74 @@ |
|||
#ifndef MYSQL_SERVICE_THD_TIMEZONE_INCLUDED |
|||
/* Copyright (C) 2013 MariaDB Foundation. |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; version 2 of the License. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with this program; if not, write to the Free Software |
|||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
|||
|
|||
/** |
|||
@file |
|||
This service provdes functions to convert between my_time_t and |
|||
MYSQL_TIME taking into account the current value of the time_zone |
|||
session variable. |
|||
|
|||
The values of the my_time_t type are in Unix timestamp format, |
|||
i.e. the number of seconds since "1970-01-01 00:00:00 UTC". |
|||
|
|||
The values of the MYSQL_TIME type are in the current time zone, |
|||
according to thd->variables.time_zone. |
|||
|
|||
If the MYSQL_THD parameter is NULL, then global_system_variables.time_zone |
|||
is used for conversion. |
|||
*/ |
|||
|
|||
#ifndef MYSQL_ABI_CHECK |
|||
/* |
|||
This service currently does not depend on any system headers. |
|||
If it needs system headers in the future, make sure to put |
|||
them inside this ifndef. |
|||
*/ |
|||
#endif |
|||
|
|||
typedef char my_bool; |
|||
#include "mysql_time.h" |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
|
|||
|
|||
extern struct thd_timezone_service_st { |
|||
my_time_t (*thd_TIME_to_gmt_sec)(MYSQL_THD thd, const MYSQL_TIME *ltime, unsigned int *errcode); |
|||
void (*thd_gmt_sec_to_TIME)(MYSQL_THD thd, MYSQL_TIME *ltime, my_time_t t); |
|||
} *thd_timezone_service; |
|||
|
|||
#ifdef MYSQL_DYNAMIC_PLUGIN |
|||
|
|||
#define thd_TIME_to_gmt_sec(thd, ltime, errcode) \ |
|||
(thd_timezone_service->thd_TIME_to_gmt_sec((thd), (ltime), (errcode))) |
|||
|
|||
#define thd_gmt_sec_to_TIME(thd, ltime, t) \ |
|||
(thd_timezone_service->thd_gmt_sec_to_TIME((thd), (ltime), (t))) |
|||
|
|||
#else |
|||
|
|||
my_time_t thd_TIME_to_gmt_sec(MYSQL_THD thd, const MYSQL_TIME *ltime, uint *errcode); |
|||
void thd_gmt_sec_to_TIME(MYSQL_THD thd, MYSQL_TIME *ltime, my_time_t t); |
|||
|
|||
#endif |
|||
|
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
|||
|
|||
#define MYSQL_SERVICE_THD_TIMEZONE_INCLUDED |
|||
#endif |
@ -0,0 +1,18 @@ |
|||
/* Copyright (C) 2013 MariaDB Foundation |
|||
Use is subject to license terms. |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; version 2 of the License. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with this program; if not, write to the Free Software |
|||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
|||
|
|||
#include <service_versions.h> |
|||
SERVICE_VERSION thd_timezone_service= (void *) VERSION_thd_timezone; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue