2006-06-27 08:48:50 +02:00
|
|
|
#ifndef _EVENT_DB_REPOSITORY_H_
|
|
|
|
#define _EVENT_DB_REPOSITORY_H_
|
|
|
|
/* Copyright (C) 2004-2006 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-27 02:23:51 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2006-06-27 08:48:50 +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 */
|
|
|
|
|
2007-08-15 17:08:44 +02:00
|
|
|
/**
|
|
|
|
@addtogroup Event_Scheduler
|
|
|
|
@{
|
|
|
|
|
|
|
|
@file event_db_repository.h
|
|
|
|
|
|
|
|
Data Dictionary related operations of Event Scheduler.
|
|
|
|
|
2007-04-05 13:24:34 +02:00
|
|
|
This is a private header file of Events module. Please do not include it
|
|
|
|
directly. All public declarations of Events module should be stored in
|
|
|
|
events.h and event_data_objects.h.
|
|
|
|
*/
|
2006-07-11 18:28:15 +02:00
|
|
|
|
2006-06-28 01:28:03 +02:00
|
|
|
enum enum_events_table_field
|
|
|
|
{
|
2007-03-16 14:56:57 +01:00
|
|
|
ET_FIELD_DB = 0,
|
2006-06-28 01:28:03 +02:00
|
|
|
ET_FIELD_NAME,
|
|
|
|
ET_FIELD_BODY,
|
|
|
|
ET_FIELD_DEFINER,
|
|
|
|
ET_FIELD_EXECUTE_AT,
|
|
|
|
ET_FIELD_INTERVAL_EXPR,
|
|
|
|
ET_FIELD_TRANSIENT_INTERVAL,
|
|
|
|
ET_FIELD_CREATED,
|
|
|
|
ET_FIELD_MODIFIED,
|
|
|
|
ET_FIELD_LAST_EXECUTED,
|
|
|
|
ET_FIELD_STARTS,
|
|
|
|
ET_FIELD_ENDS,
|
|
|
|
ET_FIELD_STATUS,
|
|
|
|
ET_FIELD_ON_COMPLETION,
|
|
|
|
ET_FIELD_SQL_MODE,
|
|
|
|
ET_FIELD_COMMENT,
|
2007-03-16 14:56:57 +01:00
|
|
|
ET_FIELD_ORIGINATOR,
|
2007-03-16 15:31:07 +01:00
|
|
|
ET_FIELD_TIME_ZONE,
|
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;
2007-06-28 19:34:54 +02:00
|
|
|
ET_FIELD_CHARACTER_SET_CLIENT,
|
|
|
|
ET_FIELD_COLLATION_CONNECTION,
|
|
|
|
ET_FIELD_DB_COLLATION,
|
|
|
|
ET_FIELD_BODY_UTF8,
|
2006-06-28 01:28:03 +02:00
|
|
|
ET_FIELD_COUNT /* a cool trick to count the number of fields :) */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-06-28 14:22:14 +02:00
|
|
|
int
|
|
|
|
events_table_index_read_for_db(THD *thd, TABLE *schema_table,
|
|
|
|
TABLE *event_table);
|
|
|
|
|
|
|
|
int
|
|
|
|
events_table_scan_all(THD *thd, TABLE *schema_table, TABLE *event_table);
|
|
|
|
|
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;
2007-06-28 19:34:54 +02:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
class Event_basic;
|
2006-06-29 00:42:25 +02:00
|
|
|
class Event_parse_data;
|
2006-06-28 01:28:03 +02:00
|
|
|
|
|
|
|
class Event_db_repository
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Event_db_repository(){}
|
|
|
|
|
2006-08-17 14:22:59 +02:00
|
|
|
bool
|
2006-08-28 10:27:42 +02:00
|
|
|
create_event(THD *thd, Event_parse_data *parse_data, my_bool create_if_not);
|
2006-06-28 01:28:03 +02:00
|
|
|
|
2006-07-11 18:28:15 +02:00
|
|
|
bool
|
|
|
|
update_event(THD *thd, Event_parse_data *parse_data, LEX_STRING *new_dbname,
|
|
|
|
LEX_STRING *new_name);
|
2006-06-28 01:28:03 +02:00
|
|
|
|
2007-03-23 16:14:03 +01:00
|
|
|
bool
|
2006-08-28 10:27:42 +02:00
|
|
|
drop_event(THD *thd, LEX_STRING db, LEX_STRING name, bool drop_if_exists);
|
2006-06-28 01:28:03 +02:00
|
|
|
|
2006-08-17 14:22:59 +02:00
|
|
|
void
|
2006-06-28 01:28:03 +02:00
|
|
|
drop_schema_events(THD *thd, LEX_STRING schema);
|
|
|
|
|
2006-07-11 18:28:15 +02:00
|
|
|
bool
|
2007-04-05 13:24:34 +02:00
|
|
|
find_named_event(LEX_STRING db, LEX_STRING name, TABLE *table);
|
2006-07-05 17:12:50 +02:00
|
|
|
|
2006-07-11 18:28:15 +02:00
|
|
|
bool
|
2006-07-10 13:44:43 +02:00
|
|
|
load_named_event(THD *thd, LEX_STRING dbname, LEX_STRING name, Event_basic *et);
|
2006-06-28 01:28:03 +02:00
|
|
|
|
2007-04-05 13:24:34 +02:00
|
|
|
bool
|
2006-06-28 14:22:14 +02:00
|
|
|
open_event_table(THD *thd, enum thr_lock_type lock_type, TABLE **table);
|
|
|
|
|
2007-04-05 13:24:34 +02:00
|
|
|
bool
|
2006-08-21 17:16:46 +02:00
|
|
|
fill_schema_events(THD *thd, TABLE_LIST *tables, const char *db);
|
2006-06-28 14:22:14 +02:00
|
|
|
|
2007-04-05 13:24:34 +02:00
|
|
|
bool
|
|
|
|
update_timing_fields_for_event(THD *thd,
|
|
|
|
LEX_STRING event_db_name,
|
|
|
|
LEX_STRING event_name,
|
|
|
|
bool update_last_executed,
|
|
|
|
my_time_t last_executed,
|
|
|
|
bool update_status,
|
|
|
|
ulonglong status);
|
|
|
|
public:
|
|
|
|
static bool
|
|
|
|
check_system_tables(THD *thd);
|
2006-06-28 14:22:14 +02:00
|
|
|
private:
|
2006-08-17 14:22:59 +02:00
|
|
|
void
|
2006-06-28 01:28:03 +02:00
|
|
|
drop_events_by_field(THD *thd, enum enum_events_table_field field,
|
|
|
|
LEX_STRING field_value);
|
2006-08-17 14:22:59 +02:00
|
|
|
bool
|
2006-06-28 14:22:14 +02:00
|
|
|
index_read_for_db_for_i_s(THD *thd, TABLE *schema_table, TABLE *event_table,
|
2006-08-21 17:16:46 +02:00
|
|
|
const char *db);
|
2006-06-28 14:22:14 +02:00
|
|
|
|
2006-08-17 14:22:59 +02:00
|
|
|
bool
|
2006-06-28 14:22:14 +02:00
|
|
|
table_scan_all_for_i_s(THD *thd, TABLE *schema_table, TABLE *event_table);
|
2006-06-28 01:28:03 +02:00
|
|
|
|
2007-04-05 13:24:34 +02:00
|
|
|
private:
|
2006-06-28 01:28:03 +02:00
|
|
|
/* Prevent use of these */
|
|
|
|
Event_db_repository(const Event_db_repository &);
|
|
|
|
void operator=(Event_db_repository &);
|
|
|
|
};
|
2007-03-23 16:14:03 +01:00
|
|
|
|
2007-08-15 17:08:44 +02:00
|
|
|
/**
|
|
|
|
@} (End of group Event_Scheduler)
|
|
|
|
*/
|
2006-06-27 08:48:50 +02:00
|
|
|
#endif /* _EVENT_DB_REPOSITORY_H_ */
|