summaryrefslogtreecommitdiff
path: root/sql/event.h
diff options
context:
space:
mode:
authorunknown <andrey@lmy004.>2005-12-05 11:45:04 +0100
committerunknown <andrey@lmy004.>2005-12-05 11:45:04 +0100
commit7ff79771057678b8c3474963773abe3a591fb812 (patch)
treee98ba39876d161bb72b5a72a6122df08aecdfd33 /sql/event.h
parente7f18c97b8528b283a06c76e7be319c3d8b5cc69 (diff)
downloadmariadb-git-7ff79771057678b8c3474963773abe3a591fb812.tar.gz
WL#1034 updated
- split into several files - forbid parallel execution (before analyse is done how to make it possible) because the same sp_head instance cannot be executed in parallel - added GPL headers - changed EVENT_ACL to be per DB variable - fixed minor problems mysql-test/lib/init_db.sql: WL#1034 updated - add Event_priv to mysql.user (update test) - add updated mysql.event table struct scripts/mysql_fix_privilege_tables.sql: WL#1034 updated add updated mysql.event structure sql/Makefile.am: split event.cc into - event.cc (create/alter/drop) - event_executor.cc (main and worker threads) - event_timed.cc (class event_timed) - event_priv.h (some definitions used internally by the module) sql/event.cc: - added GPL header - split into few files - fixed some issues after code review - now using SP routines for opening/traversing/closing tables (will be reverted) sql/event.h: - add GPL header - remove two methods - inline them in sql_yacc.yy - don't use absolute values for EVEX_ defines but the SP_ equivalents (have to move 100% to SP_ defines and as later step to not transfer messages upwards in the stack but report them at the place they occur) - updated reference table definition - move default mem_root param from event.cc to the header sql/mysqld.cc: WL#1034 rename --event-executor to --event-scheduler executor sounds a bit scary :) sql/set_var.cc: rename internal variable name from event_executor to event_scheduler (ppl won't be scarried anymore :) sql/share/errmsg.txt: omit one %s - not needed sql/sp_head.cc: disable this DBUG_PRINT for a bit. m_next_cached_sp is 0x0 and I get crash here... sql/sp_head.h: remove m_old_cmq, a temporal variable is used in sql_yacc.yy (Serg's idea) to keep the previous state. $<ulong_val>$ = .... YYTHD->client_capabilites != $<ulong_val>4; (the same is done also for class event_timed) sql/sql_acl.cc: handle pre-5.1.4 table and give the user EVENT_ACL if he had CREATE_ACL sql/sql_acl.h: fix the bitmask sql/sql_parse.cc: - move from EVENT_ACL being global to EVENT_ACL being per DB like CREATE_PROC_ACL - lex->m_qname dropped, because not needed, fix code therefore - add comment that SHOW CREATE EVENT has to be implemented sql/sql_yacc.yy: - use temporal variable of Bison to store a short lived value - fix indentation - inline 2 class event_timed methods in the parser sql/tztime.h: be more expressive - it's already extern
Diffstat (limited to 'sql/event.h')
-rw-r--r--sql/event.h117
1 files changed, 68 insertions, 49 deletions
diff --git a/sql/event.h b/sql/event.h
index 5ba96e401ce..cab5d9bf257 100644
--- a/sql/event.h
+++ b/sql/event.h
@@ -1,27 +1,58 @@
-/* -*- C++ -*- */
+/* Copyright (C) 2000-2003 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ 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 */
+
#ifndef _EVENT_H_
#define _EVENT_H_
#include "sp_head.h"
+#include "sp.h"
extern ulong opt_event_executor;
-#define EVEX_OK 0
-#define EVEX_KEY_NOT_FOUND -1
-#define EVEX_OPEN_TABLE_FAILED -2
-#define EVEX_WRITE_ROW_FAILED -3
-#define EVEX_DELETE_ROW_FAILED -4
-#define EVEX_GET_FIELD_FAILED -5
-#define EVEX_PARSE_ERROR -6
-#define EVEX_INTERNAL_ERROR -7
-#define EVEX_NO_DB_ERROR -8
-#define EVEX_GENERAL_ERROR -9
-#define EVEX_BAD_PARAMS -10
-#define EVEX_NOT_RUNNING -11
-
-#define EVENT_EXEC_NO_MORE (1L << 0)
-#define EVENT_NOT_USED (1L << 1)
+#define EVEX_OK SP_OK
+#define EVEX_KEY_NOT_FOUND SP_KEY_NOT_FOUND
+#define EVEX_OPEN_TABLE_FAILED SP_OPEN_TABLE_FAILED
+#define EVEX_WRITE_ROW_FAILED SP_WRITE_ROW_FAILED
+#define EVEX_DELETE_ROW_FAILED SP_DELETE_ROW_FAILED
+#define EVEX_GET_FIELD_FAILED SP_GET_FIELD_FAILED
+#define EVEX_PARSE_ERROR SP_PARSE_ERROR
+#define EVEX_INTERNAL_ERROR SP_INTERNAL_ERROR
+#define EVEX_NO_DB_ERROR SP_NO_DB_ERROR
+#define EVEX_GENERAL_ERROR -20
+#define EVEX_BAD_IDENTIFIER SP_BAD_IDENTIFIER
+#define EVEX_BODY_TOO_LONG SP_BODY_TOO_LONG
+#define EVEX_BAD_PARAMS -21
+#define EVEX_NOT_RUNNING -22
+
+#define EVENT_EXEC_NO_MORE (1L << 0)
+#define EVENT_NOT_USED (1L << 1)
+
+#define SP_OK 0
+#define SP_KEY_NOT_FOUND -1
+#define SP_OPEN_TABLE_FAILED -2
+#define SP_WRITE_ROW_FAILED -3
+#define SP_DELETE_ROW_FAILED -4
+#define SP_GET_FIELD_FAILED -5
+#define SP_PARSE_ERROR -6
+#define SP_INTERNAL_ERROR -7
+#define SP_NO_DB_ERROR -8
+#define SP_BAD_IDENTIFIER -9
+#define SP_BODY_TOO_LONG -10
+extern ulong opt_event_executor;
enum enum_event_on_completion
{
@@ -40,11 +71,12 @@ class event_timed
{
event_timed(const event_timed &); /* Prevent use of these */
void operator=(event_timed &);
+ my_bool running;
+ pthread_mutex_t LOCK_running;
public:
LEX_STRING m_db;
LEX_STRING m_name;
- LEX_STRING m_qname; // db.name
LEX_STRING m_body;
LEX_STRING m_definer_user;
@@ -64,9 +96,6 @@ public:
enum enum_event_status m_status;
sp_head *m_sphead;
-
-
- uint m_old_cmq; // Old CLIENT_MULTI_QUERIES value
const uchar *m_body_begin;
bool m_dropped;
@@ -75,15 +104,19 @@ public:
bool m_last_executed_changed;
bool m_status_changed;
- event_timed():m_expr(0), m_created(0), m_modified(0),
+ event_timed():running(0), m_expr(0), m_created(0), m_modified(0),
m_on_completion(MYSQL_EVENT_ON_COMPLETION_DROP),
m_status(MYSQL_EVENT_ENABLED), m_sphead(0), m_dropped(false),
m_free_sphead_on_delete(true), m_flags(0),
m_last_executed_changed(false), m_status_changed(false)
- { init(); }
+ {
+ pthread_mutex_init(&LOCK_running, MY_MUTEX_INIT_FAST);
+ init();
+ }
~event_timed()
{
+ pthread_mutex_destroy(&LOCK_running);
if (m_free_sphead_on_delete)
free_sp();
}
@@ -115,12 +148,6 @@ public:
void
init_comment(THD *thd, LEX_STRING *comment);
- void
- set_on_completion_drop(bool drop);
-
- void
- set_event_status(bool enabled);
-
int
load_from_row(MEM_ROOT *mem_root, TABLE *table);
@@ -140,10 +167,10 @@ public:
get_show_create_event(THD *thd, uint *length);
int
- execute(THD *thd, MEM_ROOT *mem_root);
+ execute(THD *thd, MEM_ROOT *mem_root= NULL);
int
- compile(THD *thd, MEM_ROOT *mem_root);
+ compile(THD *thd, MEM_ROOT *mem_root= NULL);
void free_sp()
{
@@ -172,29 +199,21 @@ init_events();
void
shutdown_events();
-/*
-typedef struct st_event_item {
- my_time_t execute_at;
- sp_head *proc;
- char *definer_user;
- char *definer_host;
-} EVENT_ITEM;
-*/
+
+// auxiliary
+int
+event_timed_compare(event_timed **a, event_timed **b);
/*
CREATE TABLE `event` (
- `db` varchar(64) character set latin1 collate latin1_bin NOT NULL default '',
- `name` varchar(64) NOT NULL default '',
- `body` blob NOT NULL,
- `definer` varchar(77) character set latin1 collate latin1_bin NOT NULL default '',
+ `db` varchar(64) character set utf8 collate utf8_bin NOT NULL default '',
+ `name` varchar(64) character set utf8 collate utf8_bin NOT NULL default '',
+ `body` longblob NOT NULL,
+ `definer` varchar(77) character set utf8 collate utf8_bin NOT NULL default '',
`execute_at` datetime default NULL,
`transient_expression` int(11) default NULL,
- `interval_type` enum('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK',
- 'SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE',
- 'DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND',
- 'DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND',
- 'SECOND_MICROSECOND') DEFAULT NULL,
+ `interval_type` enum('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') default NULL,
`created` timestamp NOT NULL default '0000-00-00 00:00:00',
`modified` timestamp NOT NULL default '0000-00-00 00:00:00',
`last_executed` datetime default NULL,
@@ -202,9 +221,9 @@ CREATE TABLE `event` (
`ends` datetime default NULL,
`status` enum('ENABLED','DISABLED') NOT NULL default 'ENABLED',
`on_completion` enum('DROP','PRESERVE') NOT NULL default 'DROP',
- `comment` varchar(64) character set latin1 collate latin1_bin NOT NULL default '',
+ `comment` varchar(64) character set utf8 collate utf8_bin NOT NULL default '',
PRIMARY KEY (`db`,`name`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
+) ENGINE=MyISAM DEFAULT CHARSET=utf8
*/
#endif /* _EVENT_H_ */