The world's most popular open source database
00001 /* Copyright (C) 2004 MySQL AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 00018 #ifdef USE_PRAGMA_INTERFACE 00019 #pragma interface /* gcc class interface */ 00020 #endif 00021 00022 #if !defined(TESTTIME) && !defined(TZINFO2SQL) 00023 00024 /* 00025 This class represents abstract time zone and provides 00026 basic interface for TIME <-> my_time_t conversion. 00027 Actual time zones which are specified by DB, or via offset 00028 or use system functions are its descendants. 00029 */ 00030 class Time_zone: public Sql_alloc 00031 { 00032 public: 00033 Time_zone() {} /* Remove gcc warning */ 00034 /* 00035 Converts local time in broken down TIME representation to 00036 my_time_t (UTC seconds since Epoch) represenation. 00037 Returns 0 in case of error. Sets in_dst_time_gap to true if date provided 00038 falls into spring time-gap (or lefts it untouched otherwise). 00039 */ 00040 virtual my_time_t TIME_to_gmt_sec(const TIME *t, 00041 my_bool *in_dst_time_gap) const = 0; 00042 /* 00043 Converts time in my_time_t representation to local time in 00044 broken down TIME representation. 00045 */ 00046 virtual void gmt_sec_to_TIME(TIME *tmp, my_time_t t) const = 0; 00047 /* 00048 Because of constness of String returned by get_name() time zone name 00049 have to be already zeroended to be able to use String::ptr() instead 00050 of c_ptr(). 00051 */ 00052 virtual const String * get_name() const = 0; 00053 00054 /* 00055 We need this only for surpressing warnings, objects of this type are 00056 allocated on MEM_ROOT and should not require destruction. 00057 */ 00058 virtual ~Time_zone() {}; 00059 }; 00060 00061 extern Time_zone * my_tz_UTC; 00062 extern Time_zone * my_tz_SYSTEM; 00063 extern TABLE_LIST * my_tz_get_table_list(THD *thd, TABLE_LIST ***global_next_ptr); 00064 extern Time_zone * my_tz_find(const String *name, TABLE_LIST *tz_tables); 00065 extern Time_zone * my_tz_find_with_opening_tz_tables(THD *thd, const String *name); 00066 extern my_bool my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap); 00067 extern void my_tz_free(); 00068 extern my_time_t sec_since_epoch_TIME(TIME *t); 00069 00070 extern TABLE_LIST fake_time_zone_tables_list; 00071 00072 /* 00073 Number of elements in table list produced by my_tz_get_table_list() 00074 (this table list contains tables which are needed for dynamical loading 00075 of time zone descriptions). Actually it is imlementation detail that 00076 should not be used anywhere outside of tztime.h and tztime.cc. 00077 */ 00078 00079 static const int MY_TZ_TABLES_COUNT= 4; 00080 00081 /* 00082 Check if we have pointer to the begining of list of implicitly used time 00083 zone tables, set SELECT_ACL for them and fast-forward to its end. 00084 00085 SYNOPSIS 00086 my_tz_check_n_skip_implicit_tables() 00087 table - (in/out) pointer to element of table list to check 00088 tz_tables - list of implicitly used time zone tables received 00089 from my_tz_get_table_list() function. 00090 00091 NOTE 00092 This function relies on my_tz_get_table_list() implementation. 00093 00094 RETURN VALUE 00095 TRUE - if table points to the beggining of tz_tables list 00096 FALSE - otherwise. 00097 */ 00098 inline bool my_tz_check_n_skip_implicit_tables(TABLE_LIST **table, 00099 TABLE_LIST *tz_tables) 00100 { 00101 if (*table == tz_tables) 00102 { 00103 for (int i= 0; i < MY_TZ_TABLES_COUNT; i++) 00104 (*table)[i].grant.privilege= SELECT_ACL; 00105 (*table)+= MY_TZ_TABLES_COUNT - 1; 00106 return TRUE; 00107 } 00108 return FALSE; 00109 } 00110 00111 #endif /* !defined(TESTTIME) && !defined(TZINFO2SQL) */
1.4.7

