Below is the list of changes that have just been committed into a local
5.1 repository of andrey. When andrey does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2080 06/01/19 19:55:04 andrey@lmy004. +10 -0
fix for bug#16642 (Events: No INFORMATION_SCHEMA.EVENTS table)
WL#1034 (Internal CRON)
sql/table.h
1.126 06/01/19 19:54:53 andrey@lmy004. +1 -0
- add an enum value for I_S.EVENTS
sql/sql_show.cc
1.294 06/01/19 19:54:53 andrey@lmy004. +178 -0
- introduce I_S.EVENTS
(fix for bug #16642)
The table structure is :
{"EVENT_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Db"},
{"EVENT_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Name"},
{"EVENT_BODY", 65535, MYSQL_TYPE_STRING, 0, 0, 0},
{"EVENT_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 0, 0},
{"EVENT_TYPE", 9, MYSQL_TYPE_STRING, 0, 0, 0},
{"EXECUTE_AT", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, 0},
{"INTERVAL", 11, MYSQL_TYPE_LONG, 0, 1, 0},
{"INTERVAL_TYPE", 18, MYSQL_TYPE_STRING, 0, 1, 0},
{"STATUS", 8, MYSQL_TYPE_STRING, 0, 0, 0},
{"ON_COMPLETION", 12, MYSQL_TYPE_STRING, 0, 0, 0},
{"CREATED", 0, MYSQL_TYPE_TIMESTAMP, 0, 0, "Created"},
{"LAST_ALTERED", 0, MYSQL_TYPE_TIMESTAMP, 0, 0, "Modified"},
{"LAST_EXECUTED", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, "Last executed"},
{"EVENT_COMMENT", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Comment"},
{"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0, "Definer"},
sql/sql_parse.cc
1.511 06/01/19 19:54:53 andrey@lmy004. +1 -0
add a case for SCH_EVENTS
(introducing I_S.EVENTS)
sql/event_timed.cc
1.18 06/01/19 19:54:53 andrey@lmy004. +1 -2
the statement fits on one line, put it on one line
sql/event_priv.h
1.14 06/01/19 19:54:53 andrey@lmy004. +0 -23
- moved enum evex_table_field to event.h
- moved evex_open_event_table() to event.h
sql/event.h
1.14 06/01/19 19:54:53 andrey@lmy004. +28 -3
- make evex_table_field public to be used in sql_show.cc
- make last_executed public to be used in sql_show.cc
- make evex_open_event_table() public outside of the scheduler
to be used in sql_show.cc for I_S.EVENTS
sql/event.cc
1.21 06/01/19 19:54:53 andrey@lmy004. +5 -0
- make execute_at and (interval_expr && interval_field) mutually exclusive
(this fixes possible bug during execution)
mysql-test/r/information_schema_db.result
1.10 06/01/19 19:54:52 andrey@lmy004. +1 -0
fix the result because of I_S.EVENTS
mysql-test/r/information_schema.result
1.104 06/01/19 19:54:52 andrey@lmy004. +9 -2
fix result because of I_S.EVENTS
include/mysql_time.h
1.5 06/01/19 19:54:52 andrey@lmy004. +4 -0
add a note
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: andrey
# Host: lmy004.
# Root: /work/mysql-5.1-events_i_s
--- 1.510/sql/sql_parse.cc 2006-01-19 03:56:01 +01:00
+++ 1.511/sql/sql_parse.cc 2006-01-19 19:54:53 +01:00
@@ -2251,6 +2251,7 @@
case SCH_COLUMN_PRIVILEGES:
case SCH_TABLE_CONSTRAINTS:
case SCH_KEY_COLUMN_USAGE:
+ case SCH_EVENTS:
default:
break;
}
--- 1.293/sql/sql_show.cc 2006-01-19 03:56:01 +01:00
+++ 1.294/sql/sql_show.cc 2006-01-19 19:54:53 +01:00
@@ -25,6 +25,7 @@
#include "sp_head.h"
#include "sql_trigger.h"
#include "authors.h"
+#include "event.h"
#include <my_dir.h>
#ifdef WITH_PARTITION_STORAGE_ENGINE
@@ -3770,6 +3771,155 @@
}
+static
+TIME ulonglong_to_TIME(ulonglong t)
+{
+ TIME ret;
+ unsigned int *tmp= ((unsigned int *)(((char*)&ret)+offsetof(TIME,second))) + 1;
+ int i= 5;
+
+ bzero(&ret, sizeof(TIME));
+ do
+ {
+ *(--tmp)= t % 100;
+ t/=100;
+ } while (--i > 0);
+ ret.year= t;
+ ret.time_type= MYSQL_TIMESTAMP_DATETIME;
+
+ return ret;
+}
+
+
+int fill_schema_events(THD *thd, TABLE_LIST *tables, COND *cond)
+{
+ const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
+ TABLE *table= tables->table;
+ CHARSET_INFO *scs= system_charset_info;
+ TABLE *event_table= NULL;
+ event_timed *et;
+ Open_tables_state backup;
+ int ret=0;
+
+ DBUG_ENTER("fill_schema_events");
+
+ thd->reset_n_backup_open_tables_state(&backup);
+
+ if ((ret= evex_open_event_table(thd, TL_READ, &event_table)))
+ {
+ sql_print_error("Table mysql.event is damaged.");
+ ret= 1;
+ goto err;
+ }
+
+ event_table->file->ha_index_init(0, 1);
+ if ((ret= event_table->file->index_first(event_table->record[0])))
+ {
+ ret= (ret == HA_ERR_END_OF_FILE) ? 0 : 1;
+ goto err;
+ }
+
+ do
+ {
+ TIME time;
+ restore_record(table, s->default_values);
+ et= new event_timed;
+ if (et->load_from_row(thd->mem_root, event_table))
+ {
+ my_error(ER_EVENT_CANNOT_LOAD_FROM_TABLE, MYF(0));
+ ret= 1;
+ goto err;
+ }
+ if (!(!wild || !wild[0] || !wild_compare(et->name.str, wild, 0)))
+ continue;
+
+ table->field[0]->store(et->dbname.str, et->dbname.length, scs);
+ table->field[1]->store(et->name.str, et->name.length, scs);
+ table->field[2]->store(et->body.str, et->body.length, scs);
+
+ // create event...
+ table->field[3]->store(STRING_WITH_LEN("NOT IMPLEMENTED"), scs);
+
+ if (et->expression)
+ {
+ char *p;
+ //type
+ table->field[4]->store(STRING_WITH_LEN("RECURRING"), scs);
+ //execute_at
+ table->field[5]->set_null();
+ //interval type
+ if ((p= get_field(thd->mem_root,
+ event_table->field[EVEX_FIELD_TRANSIENT_INTERVAL])) == NullS)
+ {
+ my_error(ER_OUTOFMEMORY, MYF(0), 10);
+ ret= 1;
+ goto err;
+ }
+ //interval_type
+ table->field[6]->set_notnull();
+ table->field[6]->store((longlong)et->expression);
+ table->field[7]->set_notnull();
+ table->field[7]->store(p, strlen(p), scs);
+ }
+ else
+ {
+ //type
+ table->field[4]->store(STRING_WITH_LEN("ONE TIME"), scs);
+ //execute_at
+ table->field[5]->set_notnull();
+ table->field[5]->store_time(&et->execute_at, MYSQL_TIMESTAMP_DATETIME);
+ //interval
+ table->field[6]->set_null();
+ //interval_type
+ table->field[7]->set_null();
+ }
+
+ //status
+ if (et->status == MYSQL_EVENT_ENABLED)
+ table->field[8]->store(STRING_WITH_LEN("ENABLED"), scs);
+ else
+ table->field[8]->store(STRING_WITH_LEN("DISABLED"), scs);
+
+ //on_completion
+ if (et->on_completion == MYSQL_EVENT_ON_COMPLETION_DROP)
+ table->field[9]->store(STRING_WITH_LEN("NOT PRESERVE"), scs);
+ else
+ table->field[9]->store(STRING_WITH_LEN("PRESERVE"), scs);
+
+ time= ulonglong_to_TIME(et->created);
+ table->field[10]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+ time= ulonglong_to_TIME(et->modified);
+ table->field[11]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+ if (et->last_executed.year)
+ table->field[12]->store_time(&et->last_executed, MYSQL_TIMESTAMP_DATETIME);
+ else
+ table->field[12]->set_null();
+
+ table->field[13]->store(et->comment.str, et->comment.length, scs);
+
+ table->field[14]->store(et->definer.str, et->definer.length, scs);
+
+ if ((ret=schema_table_store_record(thd, table)))
+ {
+ DBUG_PRINT("fill_schema_events",("schema_table_store_record ret %d",ret))
+ ret= 1;
+ goto err;
+ }
+ delete et;
+ } while (!event_table->file->index_next(event_table->record[0]));
+
+ ret= 0;
+err:
+ if (event_table)
+ {
+ event_table->file->ha_index_end();
+ close_thread_tables(thd);
+ }
+ thd->restore_backup_open_tables_state(&backup);
+ DBUG_RETURN(ret);
+}
+
+
int fill_open_tables(THD *thd, TABLE_LIST *tables, COND *cond)
{
DBUG_ENTER("fill_open_tables");
@@ -4390,6 +4540,32 @@
};
+ST_FIELD_INFO events_fields_info[]=
+{
+ {"EVENT_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Db"},
+ {"EVENT_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Name"},
+ {"EVENT_BODY", 65535, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"EVENT_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"EVENT_TYPE", 9, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"EXECUTE_AT", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, 0},
+ {"INTERVAL", 11, MYSQL_TYPE_LONG, 0, 1, 0},
+ {"INTERVAL_TYPE", 18, MYSQL_TYPE_STRING, 0, 1, 0},
+ {"STATUS", 8, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"ON_COMPLETION", 12, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"CREATED", 0, MYSQL_TYPE_TIMESTAMP, 0, 0, "Created"},
+ {"LAST_ALTERED", 0, MYSQL_TYPE_TIMESTAMP, 0, 0, "Modified"},
+ {"LAST_EXECUTED", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, "Last executed"},
+ {"EVENT_COMMENT", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Comment"},
+ {"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0, "Definer"},
+/*
+ {"SQL_MODE", 65535, MYSQL_TYPE_STRING, 0, 0, 0},
+*/
+
+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
+};
+
+
+
ST_FIELD_INFO coll_charset_app_fields_info[]=
{
{"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0},
@@ -4655,6 +4831,8 @@
fill_schema_column_privileges, 0, 0, -1, -1, 0},
{"ENGINES", engines_fields_info, create_schema_table,
fill_schema_engines, make_old_format, 0, -1, -1, 0},
+ {"EVENTS", events_fields_info, create_schema_table,
+ fill_schema_events, make_old_format, 0, -1, -1, 0},
{"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
{"OPEN_TABLES", open_tables_fields_info, create_schema_table,
--- 1.125/sql/table.h 2006-01-19 03:56:01 +01:00
+++ 1.126/sql/table.h 2006-01-19 19:54:53 +01:00
@@ -338,6 +338,7 @@
SCH_COLUMNS,
SCH_COLUMN_PRIVILEGES,
SCH_ENGINES,
+ SCH_EVENTS,
SCH_KEY_COLUMN_USAGE,
SCH_OPEN_TABLES,
SCH_PARTITIONS,
--- 1.20/sql/event.cc 2006-01-11 12:49:43 +01:00
+++ 1.21/sql/event.cc 2006-01-19 19:54:53 +01:00
@@ -283,10 +283,15 @@
from 1. Thus +1 offset is needed!
*/
table->field[EVEX_FIELD_TRANSIENT_INTERVAL]->store((longlong)et->interval+1);
+
+ table->field[EVEX_FIELD_EXECUTE_AT]->set_null();
}
else if (et->execute_at.year)
{
// fix_fields already called in init_execute_at
+ table->field[EVEX_FIELD_INTERVAL_EXPR]->set_null();
+ table->field[EVEX_FIELD_TRANSIENT_INTERVAL]->set_null();
+
table->field[EVEX_FIELD_EXECUTE_AT]->set_notnull();
table->field[EVEX_FIELD_EXECUTE_AT]->store_time(&et->execute_at,
MYSQL_TIMESTAMP_DATETIME);
--- 1.13/sql/event.h 2006-01-13 07:26:34 +01:00
+++ 1.14/sql/event.h 2006-01-19 19:54:53 +01:00
@@ -54,6 +54,25 @@
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 @@
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 @@
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 @@
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
init_events();
@@ -208,6 +232,7 @@
// auxiliary
int
event_timed_compare(event_timed **a, event_timed **b);
+
/*
--- 1.13/sql/event_priv.h 2005-12-28 17:28:41 +01:00
+++ 1.14/sql/event_priv.h 2006-01-19 19:54:53 +01:00
@@ -24,26 +24,6 @@
#define UNLOCK_MUTEX_AND_BAIL_OUT(__mutex, __label) \
{ VOID(pthread_mutex_unlock(&__mutex)); goto __label; }
-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 :) */
-} ;
-
#define EVEX_DB_FIELD_LEN 64
#define EVEX_NAME_FIELD_LEN 64
@@ -54,9 +34,6 @@
evex_db_find_event_aux(THD *thd, const LEX_STRING dbname,
const LEX_STRING rname, TABLE *table);
-int
-evex_open_event_table(THD *thd, enum thr_lock_type lock_type, TABLE **table);
-
int
event_timed_compare_q(void *vptr, byte* a, byte *b);
--- 1.17/sql/event_timed.cc 2006-01-12 16:51:19 +01:00
+++ 1.18/sql/event_timed.cc 2006-01-19 19:54:53 +01:00
@@ -475,8 +475,7 @@
goto error;
DBUG_PRINT("load_from_row", ("Event [%s] is [%s]", et->name.str, ptr));
- et->status= (ptr[0]=='E'? MYSQL_EVENT_ENABLED:
- MYSQL_EVENT_DISABLED);
+ et->status= (ptr[0]=='E'? MYSQL_EVENT_ENABLED:MYSQL_EVENT_DISABLED);
// ToDo : Andrey . Find a way not to allocate ptr on event_mem_root
if ((ptr= get_field(mem_root,
--- 1.103/mysql-test/r/information_schema.result 2006-01-19 03:55:59 +01:00
+++ 1.104/mysql-test/r/information_schema.result 2006-01-19 19:54:52 +01:00
@@ -44,6 +44,7 @@
COLUMNS
COLUMN_PRIVILEGES
ENGINES
+EVENTS
KEY_COLUMN_USAGE
PARTITIONS
PLUGINS
@@ -734,7 +735,7 @@
CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
count(*)
-109
+110
drop view a2, a1;
drop table t_crashme;
select table_schema,table_name, column_name from
@@ -742,6 +743,8 @@
where data_type = 'longtext';
table_schema table_name column_name
information_schema COLUMNS COLUMN_TYPE
+information_schema EVENTS EVENT_BODY
+information_schema EVENTS EVENT_DEFINITION
information_schema PARTITIONS PARTITION_EXPRESSION
information_schema PARTITIONS SUBPARTITION_EXPRESSION
information_schema PARTITIONS PARTITION_DESCRIPTION
@@ -756,6 +759,10 @@
select table_name, column_name, data_type from information_schema.columns
where data_type = 'datetime';
table_name column_name data_type
+EVENTS EXECUTE_AT datetime
+EVENTS CREATED datetime
+EVENTS LAST_ALTERED datetime
+EVENTS LAST_EXECUTED datetime
PARTITIONS CREATE_TIME datetime
PARTITIONS UPDATE_TIME datetime
PARTITIONS CHECK_TIME datetime
@@ -817,7 +824,7 @@
SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
table_schema count(*)
cluster_replication 1
-information_schema 19
+information_schema 20
mysql 21
create table t1 (i int, j int);
create trigger trg1 before insert on t1 for each row
--- 1.9/mysql-test/r/information_schema_db.result 2006-01-10 16:42:19 +01:00
+++ 1.10/mysql-test/r/information_schema_db.result 2006-01-19 19:54:52 +01:00
@@ -7,6 +7,7 @@
COLUMNS
COLUMN_PRIVILEGES
ENGINES
+EVENTS
KEY_COLUMN_USAGE
PARTITIONS
PLUGINS
--- 1.4/include/mysql_time.h 2004-11-15 13:44:25 +01:00
+++ 1.5/include/mysql_time.h 2006-01-19 19:54:52 +01:00
@@ -44,6 +44,10 @@
There is one exception to this rule though if this structure holds time
value (time_type == MYSQL_TIMESTAMP_TIME) days and hour member can hold
bigger values.
+
+ Warn: if you change the order of year, month, day, hour, minute, second
+ fix ulonglong_to_TIME() in sql_show.cc . It relies on the current
+ order and type being unsigned int.
*/
typedef struct st_mysql_time
{
| Thread |
|---|
| • bk commit into 5.1 tree (andrey:1.2080) BUG#16642 | ahristov | 19 Jan |