2004-06-18 08:11:31 +02:00
|
|
|
/* Copyright (C) 2004 MySQL AB
|
|
|
|
|
|
|
|
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
|
2006-12-23 20:17:15 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2004-06-18 08:11:31 +02:00
|
|
|
|
|
|
|
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
|
|
|
|
|
2005-05-04 15:05:56 +02:00
|
|
|
#ifdef USE_PRAGMA_INTERFACE
|
2004-06-18 08:11:31 +02:00
|
|
|
#pragma interface /* gcc class interface */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(TESTTIME) && !defined(TZINFO2SQL)
|
2004-07-29 23:25:58 +02:00
|
|
|
|
2007-10-16 22:11:50 +02:00
|
|
|
/**
|
2004-06-18 08:11:31 +02:00
|
|
|
This class represents abstract time zone and provides
|
2007-03-23 21:08:31 +01:00
|
|
|
basic interface for MYSQL_TIME <-> my_time_t conversion.
|
2004-06-18 08:11:31 +02:00
|
|
|
Actual time zones which are specified by DB, or via offset
|
|
|
|
or use system functions are its descendants.
|
|
|
|
*/
|
|
|
|
class Time_zone: public Sql_alloc
|
|
|
|
{
|
|
|
|
public:
|
2006-02-25 16:46:30 +01:00
|
|
|
Time_zone() {} /* Remove gcc warning */
|
2007-10-16 22:11:50 +02:00
|
|
|
/**
|
2007-03-23 21:08:31 +01:00
|
|
|
Converts local time in broken down MYSQL_TIME representation to
|
2004-06-18 08:11:31 +02:00
|
|
|
my_time_t (UTC seconds since Epoch) represenation.
|
|
|
|
Returns 0 in case of error. Sets in_dst_time_gap to true if date provided
|
|
|
|
falls into spring time-gap (or lefts it untouched otherwise).
|
|
|
|
*/
|
2007-03-23 21:08:31 +01:00
|
|
|
virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t,
|
2005-07-31 11:49:55 +02:00
|
|
|
my_bool *in_dst_time_gap) const = 0;
|
2007-10-16 22:11:50 +02:00
|
|
|
/**
|
2004-06-18 08:11:31 +02:00
|
|
|
Converts time in my_time_t representation to local time in
|
2007-03-23 21:08:31 +01:00
|
|
|
broken down MYSQL_TIME representation.
|
2004-06-18 08:11:31 +02:00
|
|
|
*/
|
2007-03-23 21:08:31 +01:00
|
|
|
virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const = 0;
|
2007-10-16 22:11:50 +02:00
|
|
|
/**
|
2004-06-18 08:11:31 +02:00
|
|
|
Because of constness of String returned by get_name() time zone name
|
|
|
|
have to be already zeroended to be able to use String::ptr() instead
|
|
|
|
of c_ptr().
|
|
|
|
*/
|
|
|
|
virtual const String * get_name() const = 0;
|
|
|
|
|
2007-10-16 22:11:50 +02:00
|
|
|
/**
|
2004-06-18 08:11:31 +02:00
|
|
|
We need this only for surpressing warnings, objects of this type are
|
|
|
|
allocated on MEM_ROOT and should not require destruction.
|
|
|
|
*/
|
|
|
|
virtual ~Time_zone() {};
|
2008-12-01 15:18:35 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static inline void adjust_leap_second(MYSQL_TIME *t);
|
2004-06-18 08:11:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extern Time_zone * my_tz_UTC;
|
|
|
|
extern Time_zone * my_tz_SYSTEM;
|
2007-07-25 09:43:49 +02:00
|
|
|
extern Time_zone * my_tz_OFFSET0;
|
BUG#9953: CONVERT_TZ requires mysql.time_zone_name to be locked
The problem was that some facilities (like CONVERT_TZ() function or
server HELP statement) may require implicit access to some tables in
'mysql' database. This access was done by ordinary means of adding
such tables to the list of tables the query is going to open.
However, if we issued LOCK TABLES before that, we would get "table
was not locked" error trying to open such implicit tables.
The solution is to treat certain tables as MySQL system tables, like
we already do for mysql.proc. Such tables may be opened for reading
at any moment regardless of any locks in effect. The cost of this is
that system table may be locked for writing only together with other
system tables, it is disallowed to lock system tables for writing and
have any other lock on any other table.
After this patch the following tables are treated as MySQL system
tables:
mysql.help_category
mysql.help_keyword
mysql.help_relation
mysql.help_topic
mysql.proc (it already was)
mysql.time_zone
mysql.time_zone_leap_second
mysql.time_zone_name
mysql.time_zone_transition
mysql.time_zone_transition_type
These tables are now opened with open_system_tables_for_read() and
closed with close_system_tables(), or one table may be opened with
open_system_table_for_update() and closed with close_thread_tables()
(the latter is used for mysql.proc table, which is updated as part of
normal MySQL server operation). These functions may be used when
some tables were opened and locked already.
NOTE: online update of time zone tables is not possible during
replication, because there's no time zone cache flush neither on LOCK
TABLES, nor on FLUSH TABLES, so the master may serve stale time zone
data from cache, while on slave updated data will be loaded from the
time zone tables.
2007-03-09 11:12:31 +01:00
|
|
|
extern Time_zone * my_tz_find(THD *thd, const String *name);
|
2004-06-18 08:11:31 +02:00
|
|
|
extern my_bool my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap);
|
|
|
|
extern void my_tz_free();
|
2007-03-23 21:08:31 +01:00
|
|
|
extern my_time_t sec_since_epoch_TIME(MYSQL_TIME *t);
|
2004-06-18 08:11:31 +02:00
|
|
|
|
2007-10-16 22:11:50 +02:00
|
|
|
/**
|
2006-04-24 16:57:00 +02:00
|
|
|
Number of elements in table list produced by my_tz_get_table_list()
|
|
|
|
(this table list contains tables which are needed for dynamical loading
|
|
|
|
of time zone descriptions). Actually it is imlementation detail that
|
|
|
|
should not be used anywhere outside of tztime.h and tztime.cc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static const int MY_TZ_TABLES_COUNT= 4;
|
|
|
|
|
2004-10-21 20:18:00 +02:00
|
|
|
|
2004-06-18 08:11:31 +02:00
|
|
|
#endif /* !defined(TESTTIME) && !defined(TZINFO2SQL) */
|