summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mnogosearch.org>2013-05-24 19:09:59 +0400
committerAlexander Barkov <bar@mnogosearch.org>2013-05-24 19:09:59 +0400
commit32bd0c7d1fd3e996bf4431ed2c2e22cc1bcde4cd (patch)
treef4b7e59f087e5c884fa5c5b09035ca84a77ce545 /include
parent74be65c6d8f3541dc4a83666e32f043a7b6b49fe (diff)
downloadmariadb-git-32bd0c7d1fd3e996bf4431ed2c2e22cc1bcde4cd.tar.gz
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
Diffstat (limited to 'include')
-rw-r--r--include/my_time.h10
-rw-r--r--include/mysql.h.pp1
-rw-r--r--include/mysql/plugin.h2
-rw-r--r--include/mysql/plugin_audit.h.pp22
-rw-r--r--include/mysql/plugin_auth.h.pp22
-rw-r--r--include/mysql/plugin_ftparser.h.pp22
-rw-r--r--include/mysql/service_thd_timezone.h74
-rw-r--r--include/mysql/services.h1
-rw-r--r--include/mysql_time.h11
-rw-r--r--include/service_versions.h2
10 files changed, 155 insertions, 12 deletions
diff --git a/include/my_time.h b/include/my_time.h
index 9bd545bb850..046b5c94923 100644
--- a/include/my_time.h
+++ b/include/my_time.h
@@ -29,16 +29,6 @@ C_MODE_START
extern ulonglong log_10_int[20];
extern uchar days_in_month[];
-/*
- Portable time_t replacement.
- Should be signed and hold seconds for 1902 -- 2038-01-19 range
- i.e at least a 32bit variable
-
- Using the system built in time_t is not an option as
- we rely on the above requirements in the time functions
-*/
-typedef long my_time_t;
-
#define MY_TIME_T_MAX LONG_MAX
#define MY_TIME_T_MIN LONG_MIN
diff --git a/include/mysql.h.pp b/include/mysql.h.pp
index d33822b2021..02eb62655df 100644
--- a/include/mysql.h.pp
+++ b/include/mysql.h.pp
@@ -143,6 +143,7 @@ const char *mysql_errno_to_sqlstate(unsigned int mysql_errno);
my_bool my_thread_init(void);
void my_thread_end(void);
#include "mysql_time.h"
+typedef long my_time_t;
enum enum_mysql_timestamp_type
{
MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h
index 38573180232..db9b8e2aa9a 100644
--- a/include/mysql/plugin.h
+++ b/include/mysql/plugin.h
@@ -72,7 +72,7 @@ typedef struct st_mysql_xid MYSQL_XID;
#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0103
/* MariaDB plugin interface version */
-#define MARIA_PLUGIN_INTERFACE_VERSION 0x0104
+#define MARIA_PLUGIN_INTERFACE_VERSION 0x0105
/*
The allowable types of plugins
diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp
index 1c4b46c2a01..8592eb9f852 100644
--- a/include/mysql/plugin_audit.h.pp
+++ b/include/mysql/plugin_audit.h.pp
@@ -85,6 +85,28 @@ extern struct kill_statement_service_st {
enum thd_kill_levels (*thd_kill_level_func)(const void*);
} *thd_kill_statement_service;
enum thd_kill_levels thd_kill_level(const void*);
+#include <mysql/service_thd_timezone.h>
+typedef char my_bool;
+#include "mysql_time.h"
+typedef long my_time_t;
+enum enum_mysql_timestamp_type
+{
+ MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
+ MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
+};
+typedef struct st_mysql_time
+{
+ unsigned int year, month, day, hour, minute, second;
+ unsigned long second_part;
+ my_bool neg;
+ enum enum_mysql_timestamp_type time_type;
+} MYSQL_TIME;
+extern struct thd_timezone_service_st {
+ my_time_t (*thd_TIME_to_gmt_sec)(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+ void (*thd_gmt_sec_to_TIME)(void* thd, MYSQL_TIME *ltime, my_time_t t);
+} *thd_timezone_service;
+my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, uint *errcode);
+void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t);
struct st_mysql_xid {
long formatID;
long gtrid_length;
diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp
index ac6e5e3b13d..81b717acc8f 100644
--- a/include/mysql/plugin_auth.h.pp
+++ b/include/mysql/plugin_auth.h.pp
@@ -85,6 +85,28 @@ extern struct kill_statement_service_st {
enum thd_kill_levels (*thd_kill_level_func)(const void*);
} *thd_kill_statement_service;
enum thd_kill_levels thd_kill_level(const void*);
+#include <mysql/service_thd_timezone.h>
+typedef char my_bool;
+#include "mysql_time.h"
+typedef long my_time_t;
+enum enum_mysql_timestamp_type
+{
+ MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
+ MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
+};
+typedef struct st_mysql_time
+{
+ unsigned int year, month, day, hour, minute, second;
+ unsigned long second_part;
+ my_bool neg;
+ enum enum_mysql_timestamp_type time_type;
+} MYSQL_TIME;
+extern struct thd_timezone_service_st {
+ my_time_t (*thd_TIME_to_gmt_sec)(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+ void (*thd_gmt_sec_to_TIME)(void* thd, MYSQL_TIME *ltime, my_time_t t);
+} *thd_timezone_service;
+my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, uint *errcode);
+void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t);
struct st_mysql_xid {
long formatID;
long gtrid_length;
diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp
index f5d6ac3b849..f28a508d62b 100644
--- a/include/mysql/plugin_ftparser.h.pp
+++ b/include/mysql/plugin_ftparser.h.pp
@@ -85,6 +85,28 @@ extern struct kill_statement_service_st {
enum thd_kill_levels (*thd_kill_level_func)(const void*);
} *thd_kill_statement_service;
enum thd_kill_levels thd_kill_level(const void*);
+#include <mysql/service_thd_timezone.h>
+typedef char my_bool;
+#include "mysql_time.h"
+typedef long my_time_t;
+enum enum_mysql_timestamp_type
+{
+ MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
+ MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
+};
+typedef struct st_mysql_time
+{
+ unsigned int year, month, day, hour, minute, second;
+ unsigned long second_part;
+ my_bool neg;
+ enum enum_mysql_timestamp_type time_type;
+} MYSQL_TIME;
+extern struct thd_timezone_service_st {
+ my_time_t (*thd_TIME_to_gmt_sec)(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+ void (*thd_gmt_sec_to_TIME)(void* thd, MYSQL_TIME *ltime, my_time_t t);
+} *thd_timezone_service;
+my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, uint *errcode);
+void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t);
struct st_mysql_xid {
long formatID;
long gtrid_length;
diff --git a/include/mysql/service_thd_timezone.h b/include/mysql/service_thd_timezone.h
new file mode 100644
index 00000000000..e6d92e73ece
--- /dev/null
+++ b/include/mysql/service_thd_timezone.h
@@ -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
diff --git a/include/mysql/services.h b/include/mysql/services.h
index e14523f4fa1..1145d19872b 100644
--- a/include/mysql/services.h
+++ b/include/mysql/services.h
@@ -25,6 +25,7 @@ extern "C" {
#include <mysql/service_progress_report.h>
#include <mysql/service_debug_sync.h>
#include <mysql/service_kill_statement.h>
+#include <mysql/service_thd_timezone.h>
#ifdef __cplusplus
}
diff --git a/include/mysql_time.h b/include/mysql_time.h
index 0a3f17a81fb..baa236e891e 100644
--- a/include/mysql_time.h
+++ b/include/mysql_time.h
@@ -17,6 +17,17 @@
#define _mysql_time_h_
/*
+ Portable time_t replacement.
+ Should be signed and hold seconds for 1902 -- 2038-01-19 range
+ i.e at least a 32bit variable
+
+ Using the system built in time_t is not an option as
+ we rely on the above requirements in the time functions
+*/
+typedef long my_time_t;
+
+
+/*
Time declarations shared between the server and client API:
you should not add anything to this header unless it's used
(and hence should be visible) in mysql.h.
diff --git a/include/service_versions.h b/include/service_versions.h
index e0a717fea9e..2dffa7cf863 100644
--- a/include/service_versions.h
+++ b/include/service_versions.h
@@ -26,4 +26,4 @@
#define VERSION_progress_report 0x0100
#define VERSION_debug_sync 0x1000
#define VERSION_kill_statement 0x1000
-
+#define VERSION_thd_timezone 0x0100