service_thd_timezone.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef MYSQL_SERVICE_THD_TIMEZONE_INCLUDED
  2. /* Copyright (C) 2013 MariaDB Foundation.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; version 2 of the License.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  13. /**
  14. @file
  15. This service provdes functions to convert between my_time_t and
  16. MYSQL_TIME taking into account the current value of the time_zone
  17. session variable.
  18. The values of the my_time_t type are in Unix timestamp format,
  19. i.e. the number of seconds since "1970-01-01 00:00:00 UTC".
  20. The values of the MYSQL_TIME type are in the current time zone,
  21. according to thd->variables.time_zone.
  22. If the MYSQL_THD parameter is NULL, then global_system_variables.time_zone
  23. is used for conversion.
  24. */
  25. #ifndef MYSQL_ABI_CHECK
  26. /*
  27. This service currently does not depend on any system headers.
  28. If it needs system headers in the future, make sure to put
  29. them inside this ifndef.
  30. */
  31. #endif
  32. #include "mysql_time.h"
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. extern struct thd_timezone_service_st {
  37. my_time_t (*thd_TIME_to_gmt_sec)(MYSQL_THD thd, const MYSQL_TIME *ltime, unsigned int *errcode);
  38. void (*thd_gmt_sec_to_TIME)(MYSQL_THD thd, MYSQL_TIME *ltime, my_time_t t);
  39. } *thd_timezone_service;
  40. #ifdef MYSQL_DYNAMIC_PLUGIN
  41. #define thd_TIME_to_gmt_sec(thd, ltime, errcode) \
  42. (thd_timezone_service->thd_TIME_to_gmt_sec((thd), (ltime), (errcode)))
  43. #define thd_gmt_sec_to_TIME(thd, ltime, t) \
  44. (thd_timezone_service->thd_gmt_sec_to_TIME((thd), (ltime), (t)))
  45. #else
  46. my_time_t thd_TIME_to_gmt_sec(MYSQL_THD thd, const MYSQL_TIME *ltime, unsigned int *errcode);
  47. void thd_gmt_sec_to_TIME(MYSQL_THD thd, MYSQL_TIME *ltime, my_time_t t);
  48. #endif
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52. #define MYSQL_SERVICE_THD_TIMEZONE_INCLUDED
  53. #endif