summaryrefslogtreecommitdiff
path: root/libmysqld
diff options
context:
space:
mode:
authorunknown <andrey@lmy004.>2006-01-10 21:02:19 +0100
committerunknown <andrey@lmy004.>2006-01-10 21:02:19 +0100
commitbb0b7f5dda0933e60cd9520d172fd27a9724cdb6 (patch)
treeed7905772f33cdc3e24dd8fbfa8894d09ed4ec0a /libmysqld
parent12c8b61aad80d04c99d77ef2a92fc26393b4f68d (diff)
parent1ef97f1f3b3dc53a5945fb4fc7db6a3fea926379 (diff)
downloadmariadb-git-bb0b7f5dda0933e60cd9520d172fd27a9724cdb6.tar.gz
WL #1034 (Internal CRON)
merge before push BUILD/SETUP.sh: Auto merged include/my_sys.h: Auto merged mysql-test/r/grant.result: Auto merged mysql-test/r/ps.result: Auto merged sql/Makefile.am: Auto merged sql/lex.h: Auto merged sql/mysqld.cc: Auto merged sql/set_var.cc: Auto merged sql/set_var.h: Auto merged sql/sp.cc: Auto merged sql/sp.h: Auto merged sql/sp_head.h: Auto merged sql/sql_acl.cc: Auto merged sql/sql_acl.h: Auto merged sql/sql_lex.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_show.cc: Auto merged sql/table.cc: Auto merged sql/tztime.cc: Auto merged libmysqld/Makefile.am: manual merge mysql-test/r/information_schema.result: manual merge sql/share/errmsg.txt: manual merge sql/sp_head.cc: manual merge sql/sql_lex.h: manual merge sql/sql_yacc.yy: manual merge
Diffstat (limited to 'libmysqld')
-rw-r--r--libmysqld/Makefile.am5
-rw-r--r--libmysqld/event.h210
2 files changed, 212 insertions, 3 deletions
diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am
index 28db9d11558..2b28a875137 100644
--- a/libmysqld/Makefile.am
+++ b/libmysqld/Makefile.am
@@ -63,9 +63,8 @@ sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \
unireg.cc uniques.cc stacktrace.c sql_union.cc hash_filo.cc \
spatial.cc gstream.cc sql_help.cc tztime.cc sql_cursor.cc \
sp_head.cc sp_pcontext.cc sp.cc sp_cache.cc sp_rcontext.cc \
- parse_file.cc sql_view.cc sql_trigger.cc my_decimal.cc \
- item_xmlfunc.cc \
- rpl_filter.cc sql_partition.cc handlerton.cc sql_plugin.cc
+ parse_file.cc sql_view.cc sql_trigger.cc my_decimal.cc event_executor.cc event.cc event_timed.cc \
+ rpl_filter.cc sql_partition.cc handlerton.cc sql_plugin.cc
libmysqld_int_a_SOURCES= $(libmysqld_sources) $(libmysqlsources) $(sqlsources)
EXTRA_libmysqld_a_SOURCES = ha_innodb.cc ha_berkeley.cc ha_archive.cc \
diff --git a/libmysqld/event.h b/libmysqld/event.h
new file mode 100644
index 00000000000..5ba96e401ce
--- /dev/null
+++ b/libmysqld/event.h
@@ -0,0 +1,210 @@
+/* -*- C++ -*- */
+#ifndef _EVENT_H_
+#define _EVENT_H_
+#include "sp_head.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)
+
+
+enum enum_event_on_completion
+{
+ MYSQL_EVENT_ON_COMPLETION_DROP = 1,
+ MYSQL_EVENT_ON_COMPLETION_PRESERVE
+};
+
+enum enum_event_status
+{
+ MYSQL_EVENT_ENABLED = 1,
+ MYSQL_EVENT_DISABLED
+};
+
+
+class event_timed
+{
+ event_timed(const event_timed &); /* Prevent use of these */
+ void operator=(event_timed &);
+
+public:
+ LEX_STRING m_db;
+ LEX_STRING m_name;
+ LEX_STRING m_qname; // db.name
+ LEX_STRING m_body;
+
+ LEX_STRING m_definer_user;
+ LEX_STRING m_definer_host;
+ LEX_STRING m_definer;// combination of user and host
+
+ LEX_STRING m_comment;
+ TIME m_starts;
+ TIME m_ends;
+ TIME m_execute_at;
+ longlong m_expr;
+ interval_type m_interval;
+ longlong m_created;
+ longlong m_modified;
+ TIME m_last_executed;
+ enum enum_event_on_completion m_on_completion;
+ 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;
+ bool m_free_sphead_on_delete;
+ uint m_flags;//all kind of purposes
+ bool m_last_executed_changed;
+ bool m_status_changed;
+
+ event_timed():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(); }
+
+ ~event_timed()
+ {
+ if (m_free_sphead_on_delete)
+ free_sp();
+ }
+
+ void
+ init();
+
+ int
+ init_definer(THD *thd);
+
+ int
+ init_execute_at(THD *thd, Item *expr);
+
+ int
+ init_interval(THD *thd, Item *expr, interval_type interval);
+
+ void
+ init_name(THD *thd, sp_name *name);
+
+ int
+ init_starts(THD *thd, Item *starts);
+
+ int
+ init_ends(THD *thd, Item *ends);
+
+ void
+ event_timed::init_body(THD *thd);
+
+ 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);
+
+ bool
+ compute_next_execution_time();
+
+ void
+ mark_last_executed();
+
+ bool
+ drop(THD *thd);
+
+ bool
+ update_fields(THD *thd);
+
+ char *
+ get_show_create_event(THD *thd, uint *length);
+
+ int
+ execute(THD *thd, MEM_ROOT *mem_root);
+
+ int
+ compile(THD *thd, MEM_ROOT *mem_root);
+
+ void free_sp()
+ {
+ if (m_sphead)
+ {
+ delete m_sphead;
+ m_sphead= 0;
+ }
+ }
+};
+
+
+int
+evex_create_event(THD *thd, event_timed *et, uint create_options);
+
+int
+evex_update_event(THD *thd, sp_name *name, event_timed *et);
+
+int
+evex_drop_event(THD *thd, event_timed *et, bool drop_if_exists);
+
+
+int
+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;
+*/
+
+
+/*
+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 '',
+ `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,
+ `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,
+ `starts` datetime default NULL,
+ `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 '',
+ PRIMARY KEY (`db`,`name`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+*/
+
+#endif /* _EVENT_H_ */