2006-06-27 08:48:50 +02:00
|
|
|
#ifndef _EVENT_DATA_OBJECTS_H_
|
|
|
|
#define _EVENT_DATA_OBJECTS_H_
|
2011-06-30 17:46:53 +02:00
|
|
|
/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
|
2006-06-20 17:05:41 +02:00
|
|
|
|
|
|
|
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-27 02:23:51 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2006-06-20 17:05:41 +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
|
2019-05-11 20:29:06 +02:00
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
|
2006-06-20 17:05:41 +02:00
|
|
|
|
2007-08-15 17:08:44 +02:00
|
|
|
/**
|
|
|
|
@addtogroup Event_Scheduler
|
|
|
|
@{
|
|
|
|
|
|
|
|
@file event_data_objects.h
|
|
|
|
*/
|
2006-06-20 17:05:41 +02:00
|
|
|
|
2008-05-09 09:43:02 +02:00
|
|
|
#include "event_parse_data.h"
|
2010-03-31 16:05:33 +02:00
|
|
|
#include "thr_lock.h" /* thr_lock_type */
|
|
|
|
|
|
|
|
class Field;
|
|
|
|
class THD;
|
|
|
|
class Time_zone;
|
|
|
|
struct TABLE;
|
2006-06-28 01:28:03 +02:00
|
|
|
|
2007-01-29 18:46:29 +01:00
|
|
|
class Event_queue_element_for_exec
|
|
|
|
{
|
|
|
|
public:
|
2021-04-22 06:51:33 +02:00
|
|
|
Event_queue_element_for_exec() : dbname{nullptr, 0}, name{nullptr, 0} {}
|
2007-01-29 18:46:29 +01:00
|
|
|
~Event_queue_element_for_exec();
|
|
|
|
|
|
|
|
bool
|
2018-01-07 17:03:44 +01:00
|
|
|
init(const LEX_CSTRING *dbname, const LEX_CSTRING *name);
|
2007-01-29 18:46:29 +01:00
|
|
|
|
2017-04-23 18:39:57 +02:00
|
|
|
LEX_CSTRING dbname;
|
|
|
|
LEX_CSTRING name;
|
2007-01-29 18:46:29 +01:00
|
|
|
bool dropped;
|
|
|
|
THD *thd;
|
|
|
|
|
|
|
|
private:
|
|
|
|
/* Prevent use of these */
|
|
|
|
Event_queue_element_for_exec(const Event_queue_element_for_exec &);
|
|
|
|
void operator=(Event_queue_element_for_exec &);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
class Event_basic
|
2006-06-20 17:05:41 +02:00
|
|
|
{
|
2006-07-10 13:44:43 +02:00
|
|
|
protected:
|
|
|
|
MEM_ROOT mem_root;
|
2006-06-20 17:05:41 +02:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
public:
|
2007-03-16 14:56:57 +01:00
|
|
|
|
2017-04-23 18:39:57 +02:00
|
|
|
LEX_CSTRING dbname;
|
|
|
|
LEX_CSTRING name;
|
|
|
|
LEX_CSTRING definer;// combination of user and host
|
2006-08-17 14:22:59 +02:00
|
|
|
|
BUG#16420: Events: timestamps become UTC
BUG#26429: SHOW CREATE EVENT is incorrect for an event that
STARTS NOW()
BUG#26431: Impossible to re-create an event from backup if its
STARTS clause is in the past
WL#3698: Events: execution in local time zone
The problem was that local times specified by the user in AT, STARTS
and ENDS of CREATE EVENT/ALTER EVENT statement were converted to UTC,
and the original time zone was forgotten. This way, event scheduler
couldn't honor Daylight Saving Time shifts, and times shown to the
user were also in UTC. Additionally, CREATE EVENT didn't allow times
in the past, thus preventing straightforward event restoration from
old backups.
This patch reworks event scheduler time computations, performing them
in the time zone associated with the event. Also it allows times to
be in the past.
The patch adds time_zone column to mysql.event table.
NOTE: The patch is almost final, but the bug#9953 should be pushed
first.
client/mysqldump.c:
Before every CREATE EVENT, output its time zone.
mysql-test/include/wait_condition.inc:
Add optional $wait_timeout parameter.
mysql-test/lib/init_db.sql:
Add time_zone column.
mysql-test/r/events.result:
Update result.
mysql-test/r/events_bugs.result:
Update result.
mysql-test/r/events_grant.result:
Update result.
mysql-test/r/events_restart_phase1.result:
Update result.
mysql-test/r/events_scheduling.result:
Update result.
mysql-test/r/mysqldump.result:
Update result.
mysql-test/r/ps.result:
Update result.
mysql-test/r/system_mysql_db.result:
Update result.
mysql-test/t/events.test:
Remove STARTS from the result, as it depends on current time.
mysql-test/t/events_bugs.test:
Time in the past is no longer an error.
mysql-test/t/events_restart_phase1.test:
Fill new column 'time_zone' in mysql.event.
mysql-test/t/events_scheduling.test:
Cleanup: disable event scheduler.
scripts/mysql_create_system_tables.sh:
Add new column 'time_zone' to mysql.event.
scripts/mysql_fix_privilege_tables.sql:
Add new column 'time_zone' to mysql.event.
sql/event_data_objects.cc:
The essence of the change is the following:
- for internal times use my_time_t instead of TIME. Assignment and
comparison is done now on plain numbers.
- in init_execute_at(), init_starts(), init_ends() convert given time
to number of seconds since Epoch (aka Unix time, in UTC).
- handle time_zone field loading and storing.
- in get_next_time(), Unix time is converted back to event time zone,
interval is added, and the result is converted to UTC again.
- fix Event_timed::get_create_event() to report STARTS and ENDS.
- before executing the event body we set thread time zone to the
event time zone.
sql/event_data_objects.h:
Add time_zone member to Event_basic class.
Store internal times in my_time_t (number of seconds since Epoch),
rather than in broken down TIME structure.
sql/event_db_repository.cc:
Add time_zone column handling.
Give a warning and do not create an event if its execution time is in
the past, and ON COMPLETION NOT PRESERVE is set, because such an event
should be dropped by that time. Also, do not allow ALTER EVENT to
set execution time in the past when ON COMPLETION NOT PRESERVE is set.
sql/event_db_repository.h:
Add enum member for new time zone column.
sql/event_queue.cc:
Replace handling of broken down times with simple handling of
my_time_t.
sql/event_queue.h:
Store internal times in my_time_t (number of seconds since Epoch),
rather than in broken down TIME structure.
sql/event_scheduler.cc:
Add TODO comment.
sql/events.cc:
Send time_zone column for SHOW CREATE EVENT.
sql/share/errmsg.txt:
Update error message, and add two more errors.
sql/sql_show.cc:
Add TIME_ZONE column to the output of SHOW EVENTS.
mysql-test/r/events_time_zone.result:
BitKeeper file /home/tomash/src/mysql_ab/mysql-5.1-wl3698/mysql-test/r/events_time_zone.result
mysql-test/t/events_time_zone.test:
BitKeeper file /home/tomash/src/mysql_ab/mysql-5.1-wl3698/mysql-test/t/events_time_zone.test
2007-03-16 15:31:07 +01:00
|
|
|
Time_zone *time_zone;
|
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_basic();
|
|
|
|
virtual ~Event_basic();
|
|
|
|
|
2007-06-14 16:49:17 +02:00
|
|
|
virtual bool
|
BUG#16420: Events: timestamps become UTC
BUG#26429: SHOW CREATE EVENT is incorrect for an event that
STARTS NOW()
BUG#26431: Impossible to re-create an event from backup if its
STARTS clause is in the past
WL#3698: Events: execution in local time zone
The problem was that local times specified by the user in AT, STARTS
and ENDS of CREATE EVENT/ALTER EVENT statement were converted to UTC,
and the original time zone was forgotten. This way, event scheduler
couldn't honor Daylight Saving Time shifts, and times shown to the
user were also in UTC. Additionally, CREATE EVENT didn't allow times
in the past, thus preventing straightforward event restoration from
old backups.
This patch reworks event scheduler time computations, performing them
in the time zone associated with the event. Also it allows times to
be in the past.
The patch adds time_zone column to mysql.event table.
NOTE: The patch is almost final, but the bug#9953 should be pushed
first.
client/mysqldump.c:
Before every CREATE EVENT, output its time zone.
mysql-test/include/wait_condition.inc:
Add optional $wait_timeout parameter.
mysql-test/lib/init_db.sql:
Add time_zone column.
mysql-test/r/events.result:
Update result.
mysql-test/r/events_bugs.result:
Update result.
mysql-test/r/events_grant.result:
Update result.
mysql-test/r/events_restart_phase1.result:
Update result.
mysql-test/r/events_scheduling.result:
Update result.
mysql-test/r/mysqldump.result:
Update result.
mysql-test/r/ps.result:
Update result.
mysql-test/r/system_mysql_db.result:
Update result.
mysql-test/t/events.test:
Remove STARTS from the result, as it depends on current time.
mysql-test/t/events_bugs.test:
Time in the past is no longer an error.
mysql-test/t/events_restart_phase1.test:
Fill new column 'time_zone' in mysql.event.
mysql-test/t/events_scheduling.test:
Cleanup: disable event scheduler.
scripts/mysql_create_system_tables.sh:
Add new column 'time_zone' to mysql.event.
scripts/mysql_fix_privilege_tables.sql:
Add new column 'time_zone' to mysql.event.
sql/event_data_objects.cc:
The essence of the change is the following:
- for internal times use my_time_t instead of TIME. Assignment and
comparison is done now on plain numbers.
- in init_execute_at(), init_starts(), init_ends() convert given time
to number of seconds since Epoch (aka Unix time, in UTC).
- handle time_zone field loading and storing.
- in get_next_time(), Unix time is converted back to event time zone,
interval is added, and the result is converted to UTC again.
- fix Event_timed::get_create_event() to report STARTS and ENDS.
- before executing the event body we set thread time zone to the
event time zone.
sql/event_data_objects.h:
Add time_zone member to Event_basic class.
Store internal times in my_time_t (number of seconds since Epoch),
rather than in broken down TIME structure.
sql/event_db_repository.cc:
Add time_zone column handling.
Give a warning and do not create an event if its execution time is in
the past, and ON COMPLETION NOT PRESERVE is set, because such an event
should be dropped by that time. Also, do not allow ALTER EVENT to
set execution time in the past when ON COMPLETION NOT PRESERVE is set.
sql/event_db_repository.h:
Add enum member for new time zone column.
sql/event_queue.cc:
Replace handling of broken down times with simple handling of
my_time_t.
sql/event_queue.h:
Store internal times in my_time_t (number of seconds since Epoch),
rather than in broken down TIME structure.
sql/event_scheduler.cc:
Add TODO comment.
sql/events.cc:
Send time_zone column for SHOW CREATE EVENT.
sql/share/errmsg.txt:
Update error message, and add two more errors.
sql/sql_show.cc:
Add TIME_ZONE column to the output of SHOW EVENTS.
mysql-test/r/events_time_zone.result:
BitKeeper file /home/tomash/src/mysql_ab/mysql-5.1-wl3698/mysql-test/r/events_time_zone.result
mysql-test/t/events_time_zone.test:
BitKeeper file /home/tomash/src/mysql_ab/mysql-5.1-wl3698/mysql-test/t/events_time_zone.test
2007-03-16 15:31:07 +01:00
|
|
|
load_from_row(THD *thd, TABLE *table) = 0;
|
2006-07-10 13:44:43 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool
|
|
|
|
load_string_fields(Field **fields, ...);
|
BUG#16420: Events: timestamps become UTC
BUG#26429: SHOW CREATE EVENT is incorrect for an event that
STARTS NOW()
BUG#26431: Impossible to re-create an event from backup if its
STARTS clause is in the past
WL#3698: Events: execution in local time zone
The problem was that local times specified by the user in AT, STARTS
and ENDS of CREATE EVENT/ALTER EVENT statement were converted to UTC,
and the original time zone was forgotten. This way, event scheduler
couldn't honor Daylight Saving Time shifts, and times shown to the
user were also in UTC. Additionally, CREATE EVENT didn't allow times
in the past, thus preventing straightforward event restoration from
old backups.
This patch reworks event scheduler time computations, performing them
in the time zone associated with the event. Also it allows times to
be in the past.
The patch adds time_zone column to mysql.event table.
NOTE: The patch is almost final, but the bug#9953 should be pushed
first.
client/mysqldump.c:
Before every CREATE EVENT, output its time zone.
mysql-test/include/wait_condition.inc:
Add optional $wait_timeout parameter.
mysql-test/lib/init_db.sql:
Add time_zone column.
mysql-test/r/events.result:
Update result.
mysql-test/r/events_bugs.result:
Update result.
mysql-test/r/events_grant.result:
Update result.
mysql-test/r/events_restart_phase1.result:
Update result.
mysql-test/r/events_scheduling.result:
Update result.
mysql-test/r/mysqldump.result:
Update result.
mysql-test/r/ps.result:
Update result.
mysql-test/r/system_mysql_db.result:
Update result.
mysql-test/t/events.test:
Remove STARTS from the result, as it depends on current time.
mysql-test/t/events_bugs.test:
Time in the past is no longer an error.
mysql-test/t/events_restart_phase1.test:
Fill new column 'time_zone' in mysql.event.
mysql-test/t/events_scheduling.test:
Cleanup: disable event scheduler.
scripts/mysql_create_system_tables.sh:
Add new column 'time_zone' to mysql.event.
scripts/mysql_fix_privilege_tables.sql:
Add new column 'time_zone' to mysql.event.
sql/event_data_objects.cc:
The essence of the change is the following:
- for internal times use my_time_t instead of TIME. Assignment and
comparison is done now on plain numbers.
- in init_execute_at(), init_starts(), init_ends() convert given time
to number of seconds since Epoch (aka Unix time, in UTC).
- handle time_zone field loading and storing.
- in get_next_time(), Unix time is converted back to event time zone,
interval is added, and the result is converted to UTC again.
- fix Event_timed::get_create_event() to report STARTS and ENDS.
- before executing the event body we set thread time zone to the
event time zone.
sql/event_data_objects.h:
Add time_zone member to Event_basic class.
Store internal times in my_time_t (number of seconds since Epoch),
rather than in broken down TIME structure.
sql/event_db_repository.cc:
Add time_zone column handling.
Give a warning and do not create an event if its execution time is in
the past, and ON COMPLETION NOT PRESERVE is set, because such an event
should be dropped by that time. Also, do not allow ALTER EVENT to
set execution time in the past when ON COMPLETION NOT PRESERVE is set.
sql/event_db_repository.h:
Add enum member for new time zone column.
sql/event_queue.cc:
Replace handling of broken down times with simple handling of
my_time_t.
sql/event_queue.h:
Store internal times in my_time_t (number of seconds since Epoch),
rather than in broken down TIME structure.
sql/event_scheduler.cc:
Add TODO comment.
sql/events.cc:
Send time_zone column for SHOW CREATE EVENT.
sql/share/errmsg.txt:
Update error message, and add two more errors.
sql/sql_show.cc:
Add TIME_ZONE column to the output of SHOW EVENTS.
mysql-test/r/events_time_zone.result:
BitKeeper file /home/tomash/src/mysql_ab/mysql-5.1-wl3698/mysql-test/r/events_time_zone.result
mysql-test/t/events_time_zone.test:
BitKeeper file /home/tomash/src/mysql_ab/mysql-5.1-wl3698/mysql-test/t/events_time_zone.test
2007-03-16 15:31:07 +01:00
|
|
|
|
|
|
|
bool
|
2017-04-23 18:39:57 +02:00
|
|
|
load_time_zone(THD *thd, const LEX_CSTRING *tz_name);
|
2006-07-10 13:44:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Event_queue_element : public Event_basic
|
|
|
|
{
|
2006-06-20 17:05:41 +02:00
|
|
|
public:
|
2007-03-16 14:56:57 +01:00
|
|
|
int on_completion;
|
|
|
|
int status;
|
2014-09-04 21:37:10 +02:00
|
|
|
uint32 originator;
|
2006-06-20 17:05:41 +02:00
|
|
|
|
BUG#16420: Events: timestamps become UTC
BUG#26429: SHOW CREATE EVENT is incorrect for an event that
STARTS NOW()
BUG#26431: Impossible to re-create an event from backup if its
STARTS clause is in the past
WL#3698: Events: execution in local time zone
The problem was that local times specified by the user in AT, STARTS
and ENDS of CREATE EVENT/ALTER EVENT statement were converted to UTC,
and the original time zone was forgotten. This way, event scheduler
couldn't honor Daylight Saving Time shifts, and times shown to the
user were also in UTC. Additionally, CREATE EVENT didn't allow times
in the past, thus preventing straightforward event restoration from
old backups.
This patch reworks event scheduler time computations, performing them
in the time zone associated with the event. Also it allows times to
be in the past.
The patch adds time_zone column to mysql.event table.
NOTE: The patch is almost final, but the bug#9953 should be pushed
first.
client/mysqldump.c:
Before every CREATE EVENT, output its time zone.
mysql-test/include/wait_condition.inc:
Add optional $wait_timeout parameter.
mysql-test/lib/init_db.sql:
Add time_zone column.
mysql-test/r/events.result:
Update result.
mysql-test/r/events_bugs.result:
Update result.
mysql-test/r/events_grant.result:
Update result.
mysql-test/r/events_restart_phase1.result:
Update result.
mysql-test/r/events_scheduling.result:
Update result.
mysql-test/r/mysqldump.result:
Update result.
mysql-test/r/ps.result:
Update result.
mysql-test/r/system_mysql_db.result:
Update result.
mysql-test/t/events.test:
Remove STARTS from the result, as it depends on current time.
mysql-test/t/events_bugs.test:
Time in the past is no longer an error.
mysql-test/t/events_restart_phase1.test:
Fill new column 'time_zone' in mysql.event.
mysql-test/t/events_scheduling.test:
Cleanup: disable event scheduler.
scripts/mysql_create_system_tables.sh:
Add new column 'time_zone' to mysql.event.
scripts/mysql_fix_privilege_tables.sql:
Add new column 'time_zone' to mysql.event.
sql/event_data_objects.cc:
The essence of the change is the following:
- for internal times use my_time_t instead of TIME. Assignment and
comparison is done now on plain numbers.
- in init_execute_at(), init_starts(), init_ends() convert given time
to number of seconds since Epoch (aka Unix time, in UTC).
- handle time_zone field loading and storing.
- in get_next_time(), Unix time is converted back to event time zone,
interval is added, and the result is converted to UTC again.
- fix Event_timed::get_create_event() to report STARTS and ENDS.
- before executing the event body we set thread time zone to the
event time zone.
sql/event_data_objects.h:
Add time_zone member to Event_basic class.
Store internal times in my_time_t (number of seconds since Epoch),
rather than in broken down TIME structure.
sql/event_db_repository.cc:
Add time_zone column handling.
Give a warning and do not create an event if its execution time is in
the past, and ON COMPLETION NOT PRESERVE is set, because such an event
should be dropped by that time. Also, do not allow ALTER EVENT to
set execution time in the past when ON COMPLETION NOT PRESERVE is set.
sql/event_db_repository.h:
Add enum member for new time zone column.
sql/event_queue.cc:
Replace handling of broken down times with simple handling of
my_time_t.
sql/event_queue.h:
Store internal times in my_time_t (number of seconds since Epoch),
rather than in broken down TIME structure.
sql/event_scheduler.cc:
Add TODO comment.
sql/events.cc:
Send time_zone column for SHOW CREATE EVENT.
sql/share/errmsg.txt:
Update error message, and add two more errors.
sql/sql_show.cc:
Add TIME_ZONE column to the output of SHOW EVENTS.
mysql-test/r/events_time_zone.result:
BitKeeper file /home/tomash/src/mysql_ab/mysql-5.1-wl3698/mysql-test/r/events_time_zone.result
mysql-test/t/events_time_zone.test:
BitKeeper file /home/tomash/src/mysql_ab/mysql-5.1-wl3698/mysql-test/t/events_time_zone.test
2007-03-16 15:31:07 +01:00
|
|
|
my_time_t last_executed;
|
|
|
|
my_time_t execute_at;
|
|
|
|
my_time_t starts;
|
|
|
|
my_time_t ends;
|
2010-09-24 00:00:32 +02:00
|
|
|
bool starts_null;
|
|
|
|
bool ends_null;
|
|
|
|
bool execute_at_null;
|
2006-06-20 17:05:41 +02:00
|
|
|
|
|
|
|
longlong expression;
|
|
|
|
interval_type interval;
|
|
|
|
|
|
|
|
bool dropped;
|
2006-07-10 13:44:43 +02:00
|
|
|
|
2006-07-17 16:52:45 +02:00
|
|
|
uint execution_count;
|
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_queue_element();
|
|
|
|
virtual ~Event_queue_element();
|
2006-08-17 14:22:59 +02:00
|
|
|
|
2007-06-14 16:49:17 +02:00
|
|
|
virtual bool
|
BUG#16420: Events: timestamps become UTC
BUG#26429: SHOW CREATE EVENT is incorrect for an event that
STARTS NOW()
BUG#26431: Impossible to re-create an event from backup if its
STARTS clause is in the past
WL#3698: Events: execution in local time zone
The problem was that local times specified by the user in AT, STARTS
and ENDS of CREATE EVENT/ALTER EVENT statement were converted to UTC,
and the original time zone was forgotten. This way, event scheduler
couldn't honor Daylight Saving Time shifts, and times shown to the
user were also in UTC. Additionally, CREATE EVENT didn't allow times
in the past, thus preventing straightforward event restoration from
old backups.
This patch reworks event scheduler time computations, performing them
in the time zone associated with the event. Also it allows times to
be in the past.
The patch adds time_zone column to mysql.event table.
NOTE: The patch is almost final, but the bug#9953 should be pushed
first.
client/mysqldump.c:
Before every CREATE EVENT, output its time zone.
mysql-test/include/wait_condition.inc:
Add optional $wait_timeout parameter.
mysql-test/lib/init_db.sql:
Add time_zone column.
mysql-test/r/events.result:
Update result.
mysql-test/r/events_bugs.result:
Update result.
mysql-test/r/events_grant.result:
Update result.
mysql-test/r/events_restart_phase1.result:
Update result.
mysql-test/r/events_scheduling.result:
Update result.
mysql-test/r/mysqldump.result:
Update result.
mysql-test/r/ps.result:
Update result.
mysql-test/r/system_mysql_db.result:
Update result.
mysql-test/t/events.test:
Remove STARTS from the result, as it depends on current time.
mysql-test/t/events_bugs.test:
Time in the past is no longer an error.
mysql-test/t/events_restart_phase1.test:
Fill new column 'time_zone' in mysql.event.
mysql-test/t/events_scheduling.test:
Cleanup: disable event scheduler.
scripts/mysql_create_system_tables.sh:
Add new column 'time_zone' to mysql.event.
scripts/mysql_fix_privilege_tables.sql:
Add new column 'time_zone' to mysql.event.
sql/event_data_objects.cc:
The essence of the change is the following:
- for internal times use my_time_t instead of TIME. Assignment and
comparison is done now on plain numbers.
- in init_execute_at(), init_starts(), init_ends() convert given time
to number of seconds since Epoch (aka Unix time, in UTC).
- handle time_zone field loading and storing.
- in get_next_time(), Unix time is converted back to event time zone,
interval is added, and the result is converted to UTC again.
- fix Event_timed::get_create_event() to report STARTS and ENDS.
- before executing the event body we set thread time zone to the
event time zone.
sql/event_data_objects.h:
Add time_zone member to Event_basic class.
Store internal times in my_time_t (number of seconds since Epoch),
rather than in broken down TIME structure.
sql/event_db_repository.cc:
Add time_zone column handling.
Give a warning and do not create an event if its execution time is in
the past, and ON COMPLETION NOT PRESERVE is set, because such an event
should be dropped by that time. Also, do not allow ALTER EVENT to
set execution time in the past when ON COMPLETION NOT PRESERVE is set.
sql/event_db_repository.h:
Add enum member for new time zone column.
sql/event_queue.cc:
Replace handling of broken down times with simple handling of
my_time_t.
sql/event_queue.h:
Store internal times in my_time_t (number of seconds since Epoch),
rather than in broken down TIME structure.
sql/event_scheduler.cc:
Add TODO comment.
sql/events.cc:
Send time_zone column for SHOW CREATE EVENT.
sql/share/errmsg.txt:
Update error message, and add two more errors.
sql/sql_show.cc:
Add TIME_ZONE column to the output of SHOW EVENTS.
mysql-test/r/events_time_zone.result:
BitKeeper file /home/tomash/src/mysql_ab/mysql-5.1-wl3698/mysql-test/r/events_time_zone.result
mysql-test/t/events_time_zone.test:
BitKeeper file /home/tomash/src/mysql_ab/mysql-5.1-wl3698/mysql-test/t/events_time_zone.test
2007-03-16 15:31:07 +01:00
|
|
|
load_from_row(THD *thd, TABLE *table);
|
2006-07-10 13:44:43 +02:00
|
|
|
|
|
|
|
bool
|
|
|
|
compute_next_execution_time();
|
|
|
|
|
|
|
|
void
|
|
|
|
mark_last_executed(THD *thd);
|
|
|
|
};
|
2006-06-20 17:05:41 +02:00
|
|
|
|
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
class Event_timed : public Event_queue_element
|
|
|
|
{
|
|
|
|
Event_timed(const Event_timed &); /* Prevent use of these */
|
|
|
|
void operator=(Event_timed &);
|
2006-06-20 17:05:41 +02:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
public:
|
2017-04-23 18:39:57 +02:00
|
|
|
LEX_CSTRING body;
|
2006-06-20 17:05:41 +02:00
|
|
|
|
2017-04-23 18:39:57 +02:00
|
|
|
LEX_CSTRING definer_user;
|
|
|
|
LEX_CSTRING definer_host;
|
2006-06-20 17:05:41 +02:00
|
|
|
|
2017-04-23 18:39:57 +02:00
|
|
|
LEX_CSTRING comment;
|
2006-06-20 17:05:41 +02:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
ulonglong created;
|
|
|
|
ulonglong modified;
|
|
|
|
|
2016-10-02 15:39:40 +02:00
|
|
|
sql_mode_t sql_mode;
|
2006-07-10 13:44:43 +02:00
|
|
|
|
Patch for the following bugs:
- BUG#11986: Stored routines and triggers can fail if the code
has a non-ascii symbol
- BUG#16291: mysqldump corrupts string-constants with non-ascii-chars
- BUG#19443: INFORMATION_SCHEMA does not support charsets properly
- BUG#21249: Character set of SP-var can be ignored
- BUG#25212: Character set of string constant is ignored (stored routines)
- BUG#25221: Character set of string constant is ignored (triggers)
There were a few general problems that caused these bugs:
1. Character set information of the original (definition) query for views,
triggers, stored routines and events was lost.
2. mysqldump output query in client character set, which can be
inappropriate to encode definition-query.
3. INFORMATION_SCHEMA used strings with mixed encodings to display object
definition;
1. No query-definition-character set.
In order to compile query into execution code, some extra data (such as
environment variables or the database character set) is used. The problem
here was that this context was not preserved. So, on the next load it can
differ from the original one, thus the result will be different.
The context contains the following data:
- client character set;
- connection collation (character set and collation);
- collation of the owner database;
The fix is to store this context and use it each time we parse (compile)
and execute the object (stored routine, trigger, ...).
2. Wrong mysqldump-output.
The original query can contain several encodings (by means of character set
introducers). The problem here was that we tried to convert original query
to the mysqldump-client character set.
Moreover, we stored queries in different character sets for different
objects (views, for one, used UTF8, triggers used original character set).
The solution is
- to store definition queries in the original character set;
- to change SHOW CREATE statement to output definition query in the
binary character set (i.e. without any conversion);
- introduce SHOW CREATE TRIGGER statement;
- to dump special statements to switch the context to the original one
before dumping and restore it afterwards.
Note, in order to preserve the database collation at the creation time,
additional ALTER DATABASE might be used (to temporary switch the database
collation back to the original value). In this case, ALTER DATABASE
privilege will be required. This is a backward-incompatible change.
3. INFORMATION_SCHEMA showed non-UTF8 strings
The fix is to generate UTF8-query during the parsing, store it in the object
and show it in the INFORMATION_SCHEMA.
Basically, the idea is to create a copy of the original query convert it to
UTF8. Character set introducers are removed and all text literals are
converted to UTF8.
This UTF8 query is intended to provide user-readable output. It must not be
used to recreate the object. Specialized SHOW CREATE statements should be
used for this.
The reason for this limitation is the following: the original query can
contain symbols from several character sets (by means of character set
introducers).
Example:
- original query:
CREATE VIEW v1 AS SELECT _cp1251 'Hello' AS c1;
- UTF8 query (for INFORMATION_SCHEMA):
CREATE VIEW v1 AS SELECT 'Hello' AS c1;
client/mysqldump.c:
Set original character set and collation before dumping definition query.
include/my_sys.h:
Move out-parameter to the end of list.
mysql-test/lib/mtr_report.pl:
Ignore server-warnings during the test case.
mysql-test/r/create.result:
Update result file.
mysql-test/r/ctype_cp932_binlog_stm.result:
Update result file.
mysql-test/r/events.result:
Update result file.
mysql-test/r/events_bugs.result:
Update result file.
mysql-test/r/events_grant.result:
Update result file.
mysql-test/r/func_in.result:
Update result file.
mysql-test/r/gis.result:
Update result file.
mysql-test/r/grant.result:
Update result file.
mysql-test/r/information_schema.result:
Update result file.
mysql-test/r/information_schema_db.result:
Update result file.
mysql-test/r/lowercase_view.result:
Update result file.
mysql-test/r/mysqldump.result:
Update result file.
mysql-test/r/ndb_sp.result:
Update result file.
mysql-test/r/ps.result:
Update result file.
mysql-test/r/rpl_replicate_do.result:
Update result file.
mysql-test/r/rpl_sp.result:
Update result file.
mysql-test/r/rpl_trigger.result:
Update result file.
mysql-test/r/rpl_view.result:
Update result file.
mysql-test/r/show_check.result:
Update result file.
mysql-test/r/skip_grants.result:
Update result file.
mysql-test/r/sp-destruct.result:
Update result file.
mysql-test/r/sp-error.result:
Update result file.
mysql-test/r/sp-security.result:
Update result file.
mysql-test/r/sp.result:
Update result file.
mysql-test/r/sql_mode.result:
Update result file.
mysql-test/r/system_mysql_db.result:
Update result file.
mysql-test/r/temp_table.result:
Update result file.
mysql-test/r/trigger-compat.result:
Update result file.
mysql-test/r/trigger-grant.result:
Update result file.
mysql-test/r/trigger.result:
Update result file.
mysql-test/r/view.result:
Update result file.
mysql-test/r/view_grant.result:
Update result file.
mysql-test/t/events.test:
Update test case (new columns added).
mysql-test/t/information_schema.test:
Update test case (new columns added).
mysql-test/t/show_check.test:
Test case for SHOW CREATE TRIGGER in prepared statements and
stored routines.
mysql-test/t/sp-destruct.test:
Update test case (new columns added).
mysql-test/t/sp.test:
Update test case (new columns added).
mysql-test/t/view.test:
Update test.
mysys/charset.c:
Move out-parameter to the end of list.
scripts/mysql_system_tables.sql:
Add new columns to mysql.proc and mysql.event.
scripts/mysql_system_tables_fix.sql:
Add new columns to mysql.proc and mysql.event.
sql/event_data_objects.cc:
Support new attributes for events.
sql/event_data_objects.h:
Support new attributes for events.
sql/event_db_repository.cc:
Support new attributes for events.
sql/event_db_repository.h:
Support new attributes for events.
sql/events.cc:
Add new columns to SHOW CREATE event resultset.
sql/mysql_priv.h:
1. Introduce Object_creation_ctx;
2. Introduce SHOW CREATE TRIGGER;
3. Introduce auxilary functions.
sql/sp.cc:
Add support for new store routines attributes.
sql/sp_head.cc:
Add support for new store routines attributes.
sql/sp_head.h:
Add support for new store routines attributes.
sql/sql_lex.cc:
Generate UTF8-body on parsing/lexing.
sql/sql_lex.h:
1. Generate UTF8-body on parsing/lexing.
2. Introduce SHOW CREATE TRIGGER.
sql/sql_parse.cc:
Introduce SHOW CREATE TRIGGER.
sql/sql_partition.cc:
Update parse_sql().
sql/sql_prepare.cc:
Update parse_sql().
sql/sql_show.cc:
Support new attributes for views
sql/sql_trigger.cc:
Support new attributes for views
sql/sql_trigger.h:
Support new attributes for views
sql/sql_view.cc:
Support new attributes for views
sql/sql_yacc.yy:
1. Add SHOW CREATE TRIGGER statement.
2. Generate UTF8-body for views, stored routines, triggers and events.
sql/table.cc:
Introduce Object_creation_ctx.
sql/table.h:
Introduce Object_creation_ctx.
sql/share/errmsg.txt:
Add new errors.
mysql-test/include/ddl_i18n.check_events.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_sp.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_triggers.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_views.inc:
Aux file for test suite.
mysql-test/include/have_cp1251.inc:
Aux file for test suite.
mysql-test/include/have_cp866.inc:
Aux file for test suite.
mysql-test/include/have_koi8r.inc:
Aux file for test suite.
mysql-test/include/have_utf8.inc:
Aux file for test suite.
mysql-test/r/ddl_i18n_koi8r.result:
Result file.
mysql-test/r/ddl_i18n_utf8.result:
Result file.
mysql-test/r/have_cp1251.require:
Aux file for test suite.
mysql-test/r/have_cp866.require:
Aux file for test suite.
mysql-test/r/have_koi8r.require:
Aux file for test suite.
mysql-test/r/have_utf8.require:
Aux file for test suite.
mysql-test/t/ddl_i18n_koi8r.test:
Complete koi8r test case for the CS patch.
mysql-test/t/ddl_i18n_utf8.test:
Complete utf8 test case for the CS patch.
2007-06-28 19:34:54 +02:00
|
|
|
class Stored_program_creation_ctx *creation_ctx;
|
2017-04-23 18:39:57 +02:00
|
|
|
LEX_CSTRING body_utf8;
|
Patch for the following bugs:
- BUG#11986: Stored routines and triggers can fail if the code
has a non-ascii symbol
- BUG#16291: mysqldump corrupts string-constants with non-ascii-chars
- BUG#19443: INFORMATION_SCHEMA does not support charsets properly
- BUG#21249: Character set of SP-var can be ignored
- BUG#25212: Character set of string constant is ignored (stored routines)
- BUG#25221: Character set of string constant is ignored (triggers)
There were a few general problems that caused these bugs:
1. Character set information of the original (definition) query for views,
triggers, stored routines and events was lost.
2. mysqldump output query in client character set, which can be
inappropriate to encode definition-query.
3. INFORMATION_SCHEMA used strings with mixed encodings to display object
definition;
1. No query-definition-character set.
In order to compile query into execution code, some extra data (such as
environment variables or the database character set) is used. The problem
here was that this context was not preserved. So, on the next load it can
differ from the original one, thus the result will be different.
The context contains the following data:
- client character set;
- connection collation (character set and collation);
- collation of the owner database;
The fix is to store this context and use it each time we parse (compile)
and execute the object (stored routine, trigger, ...).
2. Wrong mysqldump-output.
The original query can contain several encodings (by means of character set
introducers). The problem here was that we tried to convert original query
to the mysqldump-client character set.
Moreover, we stored queries in different character sets for different
objects (views, for one, used UTF8, triggers used original character set).
The solution is
- to store definition queries in the original character set;
- to change SHOW CREATE statement to output definition query in the
binary character set (i.e. without any conversion);
- introduce SHOW CREATE TRIGGER statement;
- to dump special statements to switch the context to the original one
before dumping and restore it afterwards.
Note, in order to preserve the database collation at the creation time,
additional ALTER DATABASE might be used (to temporary switch the database
collation back to the original value). In this case, ALTER DATABASE
privilege will be required. This is a backward-incompatible change.
3. INFORMATION_SCHEMA showed non-UTF8 strings
The fix is to generate UTF8-query during the parsing, store it in the object
and show it in the INFORMATION_SCHEMA.
Basically, the idea is to create a copy of the original query convert it to
UTF8. Character set introducers are removed and all text literals are
converted to UTF8.
This UTF8 query is intended to provide user-readable output. It must not be
used to recreate the object. Specialized SHOW CREATE statements should be
used for this.
The reason for this limitation is the following: the original query can
contain symbols from several character sets (by means of character set
introducers).
Example:
- original query:
CREATE VIEW v1 AS SELECT _cp1251 'Hello' AS c1;
- UTF8 query (for INFORMATION_SCHEMA):
CREATE VIEW v1 AS SELECT 'Hello' AS c1;
client/mysqldump.c:
Set original character set and collation before dumping definition query.
include/my_sys.h:
Move out-parameter to the end of list.
mysql-test/lib/mtr_report.pl:
Ignore server-warnings during the test case.
mysql-test/r/create.result:
Update result file.
mysql-test/r/ctype_cp932_binlog_stm.result:
Update result file.
mysql-test/r/events.result:
Update result file.
mysql-test/r/events_bugs.result:
Update result file.
mysql-test/r/events_grant.result:
Update result file.
mysql-test/r/func_in.result:
Update result file.
mysql-test/r/gis.result:
Update result file.
mysql-test/r/grant.result:
Update result file.
mysql-test/r/information_schema.result:
Update result file.
mysql-test/r/information_schema_db.result:
Update result file.
mysql-test/r/lowercase_view.result:
Update result file.
mysql-test/r/mysqldump.result:
Update result file.
mysql-test/r/ndb_sp.result:
Update result file.
mysql-test/r/ps.result:
Update result file.
mysql-test/r/rpl_replicate_do.result:
Update result file.
mysql-test/r/rpl_sp.result:
Update result file.
mysql-test/r/rpl_trigger.result:
Update result file.
mysql-test/r/rpl_view.result:
Update result file.
mysql-test/r/show_check.result:
Update result file.
mysql-test/r/skip_grants.result:
Update result file.
mysql-test/r/sp-destruct.result:
Update result file.
mysql-test/r/sp-error.result:
Update result file.
mysql-test/r/sp-security.result:
Update result file.
mysql-test/r/sp.result:
Update result file.
mysql-test/r/sql_mode.result:
Update result file.
mysql-test/r/system_mysql_db.result:
Update result file.
mysql-test/r/temp_table.result:
Update result file.
mysql-test/r/trigger-compat.result:
Update result file.
mysql-test/r/trigger-grant.result:
Update result file.
mysql-test/r/trigger.result:
Update result file.
mysql-test/r/view.result:
Update result file.
mysql-test/r/view_grant.result:
Update result file.
mysql-test/t/events.test:
Update test case (new columns added).
mysql-test/t/information_schema.test:
Update test case (new columns added).
mysql-test/t/show_check.test:
Test case for SHOW CREATE TRIGGER in prepared statements and
stored routines.
mysql-test/t/sp-destruct.test:
Update test case (new columns added).
mysql-test/t/sp.test:
Update test case (new columns added).
mysql-test/t/view.test:
Update test.
mysys/charset.c:
Move out-parameter to the end of list.
scripts/mysql_system_tables.sql:
Add new columns to mysql.proc and mysql.event.
scripts/mysql_system_tables_fix.sql:
Add new columns to mysql.proc and mysql.event.
sql/event_data_objects.cc:
Support new attributes for events.
sql/event_data_objects.h:
Support new attributes for events.
sql/event_db_repository.cc:
Support new attributes for events.
sql/event_db_repository.h:
Support new attributes for events.
sql/events.cc:
Add new columns to SHOW CREATE event resultset.
sql/mysql_priv.h:
1. Introduce Object_creation_ctx;
2. Introduce SHOW CREATE TRIGGER;
3. Introduce auxilary functions.
sql/sp.cc:
Add support for new store routines attributes.
sql/sp_head.cc:
Add support for new store routines attributes.
sql/sp_head.h:
Add support for new store routines attributes.
sql/sql_lex.cc:
Generate UTF8-body on parsing/lexing.
sql/sql_lex.h:
1. Generate UTF8-body on parsing/lexing.
2. Introduce SHOW CREATE TRIGGER.
sql/sql_parse.cc:
Introduce SHOW CREATE TRIGGER.
sql/sql_partition.cc:
Update parse_sql().
sql/sql_prepare.cc:
Update parse_sql().
sql/sql_show.cc:
Support new attributes for views
sql/sql_trigger.cc:
Support new attributes for views
sql/sql_trigger.h:
Support new attributes for views
sql/sql_view.cc:
Support new attributes for views
sql/sql_yacc.yy:
1. Add SHOW CREATE TRIGGER statement.
2. Generate UTF8-body for views, stored routines, triggers and events.
sql/table.cc:
Introduce Object_creation_ctx.
sql/table.h:
Introduce Object_creation_ctx.
sql/share/errmsg.txt:
Add new errors.
mysql-test/include/ddl_i18n.check_events.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_sp.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_triggers.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_views.inc:
Aux file for test suite.
mysql-test/include/have_cp1251.inc:
Aux file for test suite.
mysql-test/include/have_cp866.inc:
Aux file for test suite.
mysql-test/include/have_koi8r.inc:
Aux file for test suite.
mysql-test/include/have_utf8.inc:
Aux file for test suite.
mysql-test/r/ddl_i18n_koi8r.result:
Result file.
mysql-test/r/ddl_i18n_utf8.result:
Result file.
mysql-test/r/have_cp1251.require:
Aux file for test suite.
mysql-test/r/have_cp866.require:
Aux file for test suite.
mysql-test/r/have_koi8r.require:
Aux file for test suite.
mysql-test/r/have_utf8.require:
Aux file for test suite.
mysql-test/t/ddl_i18n_koi8r.test:
Complete koi8r test case for the CS patch.
mysql-test/t/ddl_i18n_utf8.test:
Complete utf8 test case for the CS patch.
2007-06-28 19:34:54 +02:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_timed();
|
|
|
|
virtual ~Event_timed();
|
2006-06-20 17:05:41 +02:00
|
|
|
|
|
|
|
void
|
2006-07-10 13:44:43 +02:00
|
|
|
init();
|
2006-06-20 17:05:41 +02:00
|
|
|
|
2007-06-14 16:49:17 +02:00
|
|
|
virtual bool
|
BUG#16420: Events: timestamps become UTC
BUG#26429: SHOW CREATE EVENT is incorrect for an event that
STARTS NOW()
BUG#26431: Impossible to re-create an event from backup if its
STARTS clause is in the past
WL#3698: Events: execution in local time zone
The problem was that local times specified by the user in AT, STARTS
and ENDS of CREATE EVENT/ALTER EVENT statement were converted to UTC,
and the original time zone was forgotten. This way, event scheduler
couldn't honor Daylight Saving Time shifts, and times shown to the
user were also in UTC. Additionally, CREATE EVENT didn't allow times
in the past, thus preventing straightforward event restoration from
old backups.
This patch reworks event scheduler time computations, performing them
in the time zone associated with the event. Also it allows times to
be in the past.
The patch adds time_zone column to mysql.event table.
NOTE: The patch is almost final, but the bug#9953 should be pushed
first.
client/mysqldump.c:
Before every CREATE EVENT, output its time zone.
mysql-test/include/wait_condition.inc:
Add optional $wait_timeout parameter.
mysql-test/lib/init_db.sql:
Add time_zone column.
mysql-test/r/events.result:
Update result.
mysql-test/r/events_bugs.result:
Update result.
mysql-test/r/events_grant.result:
Update result.
mysql-test/r/events_restart_phase1.result:
Update result.
mysql-test/r/events_scheduling.result:
Update result.
mysql-test/r/mysqldump.result:
Update result.
mysql-test/r/ps.result:
Update result.
mysql-test/r/system_mysql_db.result:
Update result.
mysql-test/t/events.test:
Remove STARTS from the result, as it depends on current time.
mysql-test/t/events_bugs.test:
Time in the past is no longer an error.
mysql-test/t/events_restart_phase1.test:
Fill new column 'time_zone' in mysql.event.
mysql-test/t/events_scheduling.test:
Cleanup: disable event scheduler.
scripts/mysql_create_system_tables.sh:
Add new column 'time_zone' to mysql.event.
scripts/mysql_fix_privilege_tables.sql:
Add new column 'time_zone' to mysql.event.
sql/event_data_objects.cc:
The essence of the change is the following:
- for internal times use my_time_t instead of TIME. Assignment and
comparison is done now on plain numbers.
- in init_execute_at(), init_starts(), init_ends() convert given time
to number of seconds since Epoch (aka Unix time, in UTC).
- handle time_zone field loading and storing.
- in get_next_time(), Unix time is converted back to event time zone,
interval is added, and the result is converted to UTC again.
- fix Event_timed::get_create_event() to report STARTS and ENDS.
- before executing the event body we set thread time zone to the
event time zone.
sql/event_data_objects.h:
Add time_zone member to Event_basic class.
Store internal times in my_time_t (number of seconds since Epoch),
rather than in broken down TIME structure.
sql/event_db_repository.cc:
Add time_zone column handling.
Give a warning and do not create an event if its execution time is in
the past, and ON COMPLETION NOT PRESERVE is set, because such an event
should be dropped by that time. Also, do not allow ALTER EVENT to
set execution time in the past when ON COMPLETION NOT PRESERVE is set.
sql/event_db_repository.h:
Add enum member for new time zone column.
sql/event_queue.cc:
Replace handling of broken down times with simple handling of
my_time_t.
sql/event_queue.h:
Store internal times in my_time_t (number of seconds since Epoch),
rather than in broken down TIME structure.
sql/event_scheduler.cc:
Add TODO comment.
sql/events.cc:
Send time_zone column for SHOW CREATE EVENT.
sql/share/errmsg.txt:
Update error message, and add two more errors.
sql/sql_show.cc:
Add TIME_ZONE column to the output of SHOW EVENTS.
mysql-test/r/events_time_zone.result:
BitKeeper file /home/tomash/src/mysql_ab/mysql-5.1-wl3698/mysql-test/r/events_time_zone.result
mysql-test/t/events_time_zone.test:
BitKeeper file /home/tomash/src/mysql_ab/mysql-5.1-wl3698/mysql-test/t/events_time_zone.test
2007-03-16 15:31:07 +01:00
|
|
|
load_from_row(THD *thd, TABLE *table);
|
2006-06-20 17:05:41 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
get_create_event(THD *thd, String *buf);
|
2006-07-10 13:44:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Event_job_data : public Event_basic
|
|
|
|
{
|
|
|
|
public:
|
2017-04-23 18:39:57 +02:00
|
|
|
LEX_CSTRING body;
|
|
|
|
LEX_CSTRING definer_user;
|
|
|
|
LEX_CSTRING definer_host;
|
2006-07-10 13:44:43 +02:00
|
|
|
|
2016-10-02 15:39:40 +02:00
|
|
|
sql_mode_t sql_mode;
|
2006-07-10 13:44:43 +02:00
|
|
|
|
Patch for the following bugs:
- BUG#11986: Stored routines and triggers can fail if the code
has a non-ascii symbol
- BUG#16291: mysqldump corrupts string-constants with non-ascii-chars
- BUG#19443: INFORMATION_SCHEMA does not support charsets properly
- BUG#21249: Character set of SP-var can be ignored
- BUG#25212: Character set of string constant is ignored (stored routines)
- BUG#25221: Character set of string constant is ignored (triggers)
There were a few general problems that caused these bugs:
1. Character set information of the original (definition) query for views,
triggers, stored routines and events was lost.
2. mysqldump output query in client character set, which can be
inappropriate to encode definition-query.
3. INFORMATION_SCHEMA used strings with mixed encodings to display object
definition;
1. No query-definition-character set.
In order to compile query into execution code, some extra data (such as
environment variables or the database character set) is used. The problem
here was that this context was not preserved. So, on the next load it can
differ from the original one, thus the result will be different.
The context contains the following data:
- client character set;
- connection collation (character set and collation);
- collation of the owner database;
The fix is to store this context and use it each time we parse (compile)
and execute the object (stored routine, trigger, ...).
2. Wrong mysqldump-output.
The original query can contain several encodings (by means of character set
introducers). The problem here was that we tried to convert original query
to the mysqldump-client character set.
Moreover, we stored queries in different character sets for different
objects (views, for one, used UTF8, triggers used original character set).
The solution is
- to store definition queries in the original character set;
- to change SHOW CREATE statement to output definition query in the
binary character set (i.e. without any conversion);
- introduce SHOW CREATE TRIGGER statement;
- to dump special statements to switch the context to the original one
before dumping and restore it afterwards.
Note, in order to preserve the database collation at the creation time,
additional ALTER DATABASE might be used (to temporary switch the database
collation back to the original value). In this case, ALTER DATABASE
privilege will be required. This is a backward-incompatible change.
3. INFORMATION_SCHEMA showed non-UTF8 strings
The fix is to generate UTF8-query during the parsing, store it in the object
and show it in the INFORMATION_SCHEMA.
Basically, the idea is to create a copy of the original query convert it to
UTF8. Character set introducers are removed and all text literals are
converted to UTF8.
This UTF8 query is intended to provide user-readable output. It must not be
used to recreate the object. Specialized SHOW CREATE statements should be
used for this.
The reason for this limitation is the following: the original query can
contain symbols from several character sets (by means of character set
introducers).
Example:
- original query:
CREATE VIEW v1 AS SELECT _cp1251 'Hello' AS c1;
- UTF8 query (for INFORMATION_SCHEMA):
CREATE VIEW v1 AS SELECT 'Hello' AS c1;
client/mysqldump.c:
Set original character set and collation before dumping definition query.
include/my_sys.h:
Move out-parameter to the end of list.
mysql-test/lib/mtr_report.pl:
Ignore server-warnings during the test case.
mysql-test/r/create.result:
Update result file.
mysql-test/r/ctype_cp932_binlog_stm.result:
Update result file.
mysql-test/r/events.result:
Update result file.
mysql-test/r/events_bugs.result:
Update result file.
mysql-test/r/events_grant.result:
Update result file.
mysql-test/r/func_in.result:
Update result file.
mysql-test/r/gis.result:
Update result file.
mysql-test/r/grant.result:
Update result file.
mysql-test/r/information_schema.result:
Update result file.
mysql-test/r/information_schema_db.result:
Update result file.
mysql-test/r/lowercase_view.result:
Update result file.
mysql-test/r/mysqldump.result:
Update result file.
mysql-test/r/ndb_sp.result:
Update result file.
mysql-test/r/ps.result:
Update result file.
mysql-test/r/rpl_replicate_do.result:
Update result file.
mysql-test/r/rpl_sp.result:
Update result file.
mysql-test/r/rpl_trigger.result:
Update result file.
mysql-test/r/rpl_view.result:
Update result file.
mysql-test/r/show_check.result:
Update result file.
mysql-test/r/skip_grants.result:
Update result file.
mysql-test/r/sp-destruct.result:
Update result file.
mysql-test/r/sp-error.result:
Update result file.
mysql-test/r/sp-security.result:
Update result file.
mysql-test/r/sp.result:
Update result file.
mysql-test/r/sql_mode.result:
Update result file.
mysql-test/r/system_mysql_db.result:
Update result file.
mysql-test/r/temp_table.result:
Update result file.
mysql-test/r/trigger-compat.result:
Update result file.
mysql-test/r/trigger-grant.result:
Update result file.
mysql-test/r/trigger.result:
Update result file.
mysql-test/r/view.result:
Update result file.
mysql-test/r/view_grant.result:
Update result file.
mysql-test/t/events.test:
Update test case (new columns added).
mysql-test/t/information_schema.test:
Update test case (new columns added).
mysql-test/t/show_check.test:
Test case for SHOW CREATE TRIGGER in prepared statements and
stored routines.
mysql-test/t/sp-destruct.test:
Update test case (new columns added).
mysql-test/t/sp.test:
Update test case (new columns added).
mysql-test/t/view.test:
Update test.
mysys/charset.c:
Move out-parameter to the end of list.
scripts/mysql_system_tables.sql:
Add new columns to mysql.proc and mysql.event.
scripts/mysql_system_tables_fix.sql:
Add new columns to mysql.proc and mysql.event.
sql/event_data_objects.cc:
Support new attributes for events.
sql/event_data_objects.h:
Support new attributes for events.
sql/event_db_repository.cc:
Support new attributes for events.
sql/event_db_repository.h:
Support new attributes for events.
sql/events.cc:
Add new columns to SHOW CREATE event resultset.
sql/mysql_priv.h:
1. Introduce Object_creation_ctx;
2. Introduce SHOW CREATE TRIGGER;
3. Introduce auxilary functions.
sql/sp.cc:
Add support for new store routines attributes.
sql/sp_head.cc:
Add support for new store routines attributes.
sql/sp_head.h:
Add support for new store routines attributes.
sql/sql_lex.cc:
Generate UTF8-body on parsing/lexing.
sql/sql_lex.h:
1. Generate UTF8-body on parsing/lexing.
2. Introduce SHOW CREATE TRIGGER.
sql/sql_parse.cc:
Introduce SHOW CREATE TRIGGER.
sql/sql_partition.cc:
Update parse_sql().
sql/sql_prepare.cc:
Update parse_sql().
sql/sql_show.cc:
Support new attributes for views
sql/sql_trigger.cc:
Support new attributes for views
sql/sql_trigger.h:
Support new attributes for views
sql/sql_view.cc:
Support new attributes for views
sql/sql_yacc.yy:
1. Add SHOW CREATE TRIGGER statement.
2. Generate UTF8-body for views, stored routines, triggers and events.
sql/table.cc:
Introduce Object_creation_ctx.
sql/table.h:
Introduce Object_creation_ctx.
sql/share/errmsg.txt:
Add new errors.
mysql-test/include/ddl_i18n.check_events.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_sp.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_triggers.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_views.inc:
Aux file for test suite.
mysql-test/include/have_cp1251.inc:
Aux file for test suite.
mysql-test/include/have_cp866.inc:
Aux file for test suite.
mysql-test/include/have_koi8r.inc:
Aux file for test suite.
mysql-test/include/have_utf8.inc:
Aux file for test suite.
mysql-test/r/ddl_i18n_koi8r.result:
Result file.
mysql-test/r/ddl_i18n_utf8.result:
Result file.
mysql-test/r/have_cp1251.require:
Aux file for test suite.
mysql-test/r/have_cp866.require:
Aux file for test suite.
mysql-test/r/have_koi8r.require:
Aux file for test suite.
mysql-test/r/have_utf8.require:
Aux file for test suite.
mysql-test/t/ddl_i18n_koi8r.test:
Complete koi8r test case for the CS patch.
mysql-test/t/ddl_i18n_utf8.test:
Complete utf8 test case for the CS patch.
2007-06-28 19:34:54 +02:00
|
|
|
class Stored_program_creation_ctx *creation_ctx;
|
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_job_data();
|
|
|
|
|
2007-06-14 16:49:17 +02:00
|
|
|
virtual bool
|
BUG#16420: Events: timestamps become UTC
BUG#26429: SHOW CREATE EVENT is incorrect for an event that
STARTS NOW()
BUG#26431: Impossible to re-create an event from backup if its
STARTS clause is in the past
WL#3698: Events: execution in local time zone
The problem was that local times specified by the user in AT, STARTS
and ENDS of CREATE EVENT/ALTER EVENT statement were converted to UTC,
and the original time zone was forgotten. This way, event scheduler
couldn't honor Daylight Saving Time shifts, and times shown to the
user were also in UTC. Additionally, CREATE EVENT didn't allow times
in the past, thus preventing straightforward event restoration from
old backups.
This patch reworks event scheduler time computations, performing them
in the time zone associated with the event. Also it allows times to
be in the past.
The patch adds time_zone column to mysql.event table.
NOTE: The patch is almost final, but the bug#9953 should be pushed
first.
client/mysqldump.c:
Before every CREATE EVENT, output its time zone.
mysql-test/include/wait_condition.inc:
Add optional $wait_timeout parameter.
mysql-test/lib/init_db.sql:
Add time_zone column.
mysql-test/r/events.result:
Update result.
mysql-test/r/events_bugs.result:
Update result.
mysql-test/r/events_grant.result:
Update result.
mysql-test/r/events_restart_phase1.result:
Update result.
mysql-test/r/events_scheduling.result:
Update result.
mysql-test/r/mysqldump.result:
Update result.
mysql-test/r/ps.result:
Update result.
mysql-test/r/system_mysql_db.result:
Update result.
mysql-test/t/events.test:
Remove STARTS from the result, as it depends on current time.
mysql-test/t/events_bugs.test:
Time in the past is no longer an error.
mysql-test/t/events_restart_phase1.test:
Fill new column 'time_zone' in mysql.event.
mysql-test/t/events_scheduling.test:
Cleanup: disable event scheduler.
scripts/mysql_create_system_tables.sh:
Add new column 'time_zone' to mysql.event.
scripts/mysql_fix_privilege_tables.sql:
Add new column 'time_zone' to mysql.event.
sql/event_data_objects.cc:
The essence of the change is the following:
- for internal times use my_time_t instead of TIME. Assignment and
comparison is done now on plain numbers.
- in init_execute_at(), init_starts(), init_ends() convert given time
to number of seconds since Epoch (aka Unix time, in UTC).
- handle time_zone field loading and storing.
- in get_next_time(), Unix time is converted back to event time zone,
interval is added, and the result is converted to UTC again.
- fix Event_timed::get_create_event() to report STARTS and ENDS.
- before executing the event body we set thread time zone to the
event time zone.
sql/event_data_objects.h:
Add time_zone member to Event_basic class.
Store internal times in my_time_t (number of seconds since Epoch),
rather than in broken down TIME structure.
sql/event_db_repository.cc:
Add time_zone column handling.
Give a warning and do not create an event if its execution time is in
the past, and ON COMPLETION NOT PRESERVE is set, because such an event
should be dropped by that time. Also, do not allow ALTER EVENT to
set execution time in the past when ON COMPLETION NOT PRESERVE is set.
sql/event_db_repository.h:
Add enum member for new time zone column.
sql/event_queue.cc:
Replace handling of broken down times with simple handling of
my_time_t.
sql/event_queue.h:
Store internal times in my_time_t (number of seconds since Epoch),
rather than in broken down TIME structure.
sql/event_scheduler.cc:
Add TODO comment.
sql/events.cc:
Send time_zone column for SHOW CREATE EVENT.
sql/share/errmsg.txt:
Update error message, and add two more errors.
sql/sql_show.cc:
Add TIME_ZONE column to the output of SHOW EVENTS.
mysql-test/r/events_time_zone.result:
BitKeeper file /home/tomash/src/mysql_ab/mysql-5.1-wl3698/mysql-test/r/events_time_zone.result
mysql-test/t/events_time_zone.test:
BitKeeper file /home/tomash/src/mysql_ab/mysql-5.1-wl3698/mysql-test/t/events_time_zone.test
2007-03-16 15:31:07 +01:00
|
|
|
load_from_row(THD *thd, TABLE *table);
|
2006-06-20 17:05:41 +02:00
|
|
|
|
2007-04-13 22:35:56 +02:00
|
|
|
bool
|
2007-04-05 18:47:22 +02:00
|
|
|
execute(THD *thd, bool drop);
|
2006-07-13 10:59:58 +02:00
|
|
|
private:
|
2007-04-13 22:35:56 +02:00
|
|
|
bool
|
|
|
|
construct_sp_sql(THD *thd, String *sp_sql);
|
2007-04-14 05:53:05 +02:00
|
|
|
bool
|
|
|
|
construct_drop_event_sql(THD *thd, String *sp_sql);
|
2006-07-10 13:44:43 +02:00
|
|
|
|
2006-08-17 14:22:59 +02:00
|
|
|
Event_job_data(const Event_job_data &); /* Prevent use of these */
|
2006-07-10 13:44:43 +02:00
|
|
|
void operator=(Event_job_data &);
|
2006-06-20 17:05:41 +02:00
|
|
|
};
|
2006-06-27 08:48:50 +02:00
|
|
|
|
|
|
|
|
2006-07-11 18:28:15 +02:00
|
|
|
/* Compares only the schema part of the identifier */
|
|
|
|
bool
|
2017-04-23 18:39:57 +02:00
|
|
|
event_basic_db_equal(const LEX_CSTRING *db, Event_basic *et);
|
2006-07-11 18:28:15 +02:00
|
|
|
|
|
|
|
/* Compares the whole identifier*/
|
|
|
|
bool
|
2017-04-23 18:39:57 +02:00
|
|
|
event_basic_identifier_equal(const LEX_CSTRING *db, const LEX_CSTRING *name,
|
|
|
|
Event_basic *b);
|
2006-07-11 18:28:15 +02:00
|
|
|
|
2007-08-15 17:08:44 +02:00
|
|
|
/**
|
|
|
|
@} (End of group Event_Scheduler)
|
|
|
|
*/
|
2006-07-11 18:28:15 +02:00
|
|
|
|
2006-06-27 08:48:50 +02:00
|
|
|
#endif /* _EVENT_DATA_OBJECTS_H_ */
|