summaryrefslogtreecommitdiff
path: root/sql/event.h
diff options
context:
space:
mode:
authorunknown <andrey@lmy004.>2006-01-30 13:15:23 +0100
committerunknown <andrey@lmy004.>2006-01-30 13:15:23 +0100
commitc3542cebf9c775241652ef8f0a4ed7dd788683d7 (patch)
tree85e23e401f2246d158fe3e4d023c5a02d3e89a6c /sql/event.h
parent098af0ae1aae693829f0c9daef551f2c3571c476 (diff)
downloadmariadb-git-c3542cebf9c775241652ef8f0a4ed7dd788683d7.tar.gz
fix for bug#16642 (Events: No INFORMATION_SCHEMA.EVENTS table)
post-review change - use pointer instead of copy on the stack. WL#1034 (Internal CRON) This patch adds INFORMATION_SCHEMA.EVENTS table with the following format: EVENT_CATALOG - MYSQL_TYPE_STRING (Always NULL) EVENT_SCHEMA - MYSQL_TYPE_STRING (the database) EVENT_NAME - MYSQL_TYPE_STRING (the name) DEFINER - MYSQL_TYPE_STRING (user@host) EVENT_BODY - MYSQL_TYPE_STRING (the body from mysql.event) EVENT_TYPE - MYSQL_TYPE_STRING ("ONE TIME" | "RECURRING") EXECUTE_AT - MYSQL_TYPE_TIMESTAMP (set for "ONE TIME" otherwise NULL) INTERVAL_VALUE - MYSQL_TYPE_LONG (set for RECURRING otherwise NULL) INTERVAL_FIELD - MYSQL_TYPE_STRING (set for RECURRING otherwise NULL) SQL_MODE - MYSQL_TYPE_STRING (for now NULL) STARTS - MYSQL_TYPE_TIMESTAMP (starts from mysql.event) ENDS - MYSQL_TYPE_TIMESTAMP (ends from mysql.event) STATUS - MYSQL_TYPE_STRING (ENABLED | DISABLED) ON_COMPLETION - MYSQL_TYPE_STRING (NOT PRESERVE | PRESERVE) CREATED - MYSQL_TYPE_TIMESTAMP LAST_ALTERED - MYSQL_TYPE_TIMESTAMP LAST_EXECUTED - MYSQL_TYPE_TIMESTAMP EVENT_COMMENT - MYSQL_TYPE_STRING SQL_MODE is NULL for now, because the value is still not stored in mysql.event . Support will be added as a fix for another bug. This patch also adds SHOW [FULL] EVENTS [FROM db] [LIKE pattern] 1. SHOW EVENTS shows always only the events on the same user, because the PK of mysql.event is (definer, db, name) several users may have event with the same name -> no information disclosure. 2. SHOW FULL EVENTS - shows the events (in the current db as SHOW EVENTS) of all users. The user has to have PROCESS privilege, if not then SHOW FULL EVENTS behave like SHOW EVENTS. 3. If [FROM db] is specified then this db is considered. 4. Event names can be filtered with LIKE pattern. SHOW EVENTS returns table with the following columns, which are subset of the data which is returned by SELECT * FROM I_S.EVENTS Db Name Definer Type Execute at Interval value Interval field Starts Ends Status mysql-test/lib/init_db.sql: change the PK - (definer, db, name) quicker searches when SHOW EVENTS; allow also different users to have events with the same name -> no information disclosure mysql-test/r/events.result: result of new tests mysql-test/r/information_schema.result: result of new tests mysql-test/r/information_schema_db.result: result of new tests mysql-test/r/system_mysql_db.result: result of new tests mysql-test/t/events.test: new tests for information_schema.events scripts/mysql_create_system_tables.sh: change the PK of mysql.event to (definer, db, name) scripts/mysql_fix_privilege_tables.sql: change the PK of mysql.event to (definer, db, name) sql/event.cc: pass around the definer of the event because of the new PK which is (definer, db, name). It's needed for index searching. sql/event.h: - make enum evex_table_field again public so it can be used in sql_show.cc - make created and modified ulonglong, because they should be such - make public evex_open_event_table so it can be used in sql_show.cc sql/event_executor.cc: - cosmetics sql/event_priv.h: - moved enum evex_table_field and evex_open_event_table() to event.h (made them therefore public) sql/event_timed.cc: - in event_timed::init_definer() always fill this.definer with the concatenated value of definer_user@definer_host. Makes later the work easier. - pass around the definer wherever is needed for searching (new prototype of evex_db_find_evex_aux) sql/mysqld.cc: - add counter for SHOW EVENTS sql/sql_lex.h: - register SHOW EVENTS as command sql/sql_parse.cc: - handle SCH_EVENTS (I_S.EVENTS like SCH_TRIGGERS) - make additional check in case of SHOW EVENTS (check for EVENT on the current database. if it is null check_access() gives appropriate message back. sql/sql_show.cc: - add INFORMATION_SCHEMA.EVENTS and SHOW EVENTS - I_S.EVENTS.SQL_MODE is NULL for now -> not implemented. Trudy asked to be added so bug #16642 can be completely closed. There is another bug report which will fix the lack of storage of SQL_MODE during event creation. sql/sql_yacc.yy: - always call event_timed::init_definer() when CREATE/ALTER/DROP EVENT but not when just compiling the body of the event because in this case this operation is not needed, it takes memory and CPU time and at the end the result is not used. event_timed::definer is used only on SQLCOM_CREATE/ALTER/DROP_EVENT execution not on statement compilation. - add SHOW [FULL] EVENTS [FROM db] [LIKE pattern] in case of FULL and the user has PROCESS privilege then he will see also others' events in the current database, otherwise the output is the same as of SHOW EVENTS. Because the events are per DB only the events from the current database are shown. pattern is applied against event name. FROM db is self explanatory. sql/table.h: add SCH_EVENTS as part of INFORMATION_SCHEMA
Diffstat (limited to 'sql/event.h')
-rw-r--r--sql/event.h33
1 files changed, 29 insertions, 4 deletions
diff --git a/sql/event.h b/sql/event.h
index d302a2f70ab..6fdf2702212 100644
--- a/sql/event.h
+++ b/sql/event.h
@@ -54,6 +54,25 @@ enum enum_event_status
MYSQL_EVENT_DISABLED
};
+enum evex_table_field
+{
+ EVEX_FIELD_DB = 0,
+ EVEX_FIELD_NAME,
+ EVEX_FIELD_BODY,
+ EVEX_FIELD_DEFINER,
+ EVEX_FIELD_EXECUTE_AT,
+ EVEX_FIELD_INTERVAL_EXPR,
+ EVEX_FIELD_TRANSIENT_INTERVAL,
+ EVEX_FIELD_CREATED,
+ EVEX_FIELD_MODIFIED,
+ EVEX_FIELD_LAST_EXECUTED,
+ EVEX_FIELD_STARTS,
+ EVEX_FIELD_ENDS,
+ EVEX_FIELD_STATUS,
+ EVEX_FIELD_ON_COMPLETION,
+ EVEX_FIELD_COMMENT,
+ EVEX_FIELD_COUNT /* a cool trick to count the number of fields :) */
+} ;
class event_timed
{
@@ -64,9 +83,10 @@ class event_timed
bool status_changed;
bool last_executed_changed;
- TIME last_executed;
public:
+ TIME last_executed;
+
LEX_STRING dbname;
LEX_STRING name;
LEX_STRING body;
@@ -83,8 +103,8 @@ public:
longlong expression;
interval_type interval;
- longlong created;
- longlong modified;
+ ulonglong created;
+ ulonglong modified;
enum enum_event_on_completion on_completion;
enum enum_event_status status;
sp_head *sphead;
@@ -197,6 +217,10 @@ int
evex_drop_event(THD *thd, event_timed *et, bool drop_if_exists,
uint *rows_affected);
+int
+evex_open_event_table(THD *thd, enum thr_lock_type lock_type, TABLE **table);
+
+int sortcmp_lex_string(LEX_STRING s, LEX_STRING t, CHARSET_INFO *cs);
int
init_events();
@@ -210,6 +234,7 @@ int
event_timed_compare(event_timed **a, event_timed **b);
+
/*
CREATE TABLE event (
db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '',
@@ -233,7 +258,7 @@ CREATE TABLE event (
status ENUM('ENABLED','DISABLED') NOT NULL default 'ENABLED',
on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP',
comment varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '',
- PRIMARY KEY (db,name)
+ PRIMARY KEY (definer,db,name)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events';
*/