Below is the list of changes that have just been committed into a local
5.0 repository of gluh. When gluh 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.1956 05/06/03 13:23:57 gluh@stripped +7 -0
Fix for bug#9586: information_schema doesn't contain table with trigger information(2nd
version)
(see also wl#1996 TRIGGERS view)
sql/sql_yacc.yy
1.388 05/06/03 13:23:00 gluh@stripped +2 -1
Fix for bug#9586: information_schema doesn't contain table with trigger
information(2nd version)
(see also wl#1996 TRIGGERS view)
sql/sql_trigger.h
1.8 05/06/03 13:23:00 gluh@stripped +5 -0
Fix for bug#9586: information_schema doesn't contain table with trigger
information(2nd version)
(see also wl#1996 TRIGGERS view)
sql/sql_trigger.cc
1.19 05/06/03 13:23:00 gluh@stripped +15 -0
Fix for bug#9586: information_schema doesn't contain table with trigger
information(2nd version)
(see also wl#1996 TRIGGERS view)
sql/sql_show.cc
1.249 05/06/03 13:23:00 gluh@stripped +100 -0
Fix for bug#9586: information_schema doesn't contain table with trigger
information(2nd version)
(see also wl#1996 TRIGGERS view)
sql/mysql_priv.h
1.306 05/06/03 13:23:00 gluh@stripped +4 -0
Fix for bug#9586: information_schema doesn't contain table with trigger
information(2nd version)
(see also wl#1996 TRIGGERS view)
mysql-test/t/information_schema.test
1.37 05/06/03 13:23:00 gluh@stripped +31 -0
Fix for bug#9586: information_schema doesn't contain table with trigger
information(2nd version)
(see also wl#1996 TRIGGERS view)
mysql-test/r/information_schema_db.result
1.3 05/06/03 13:23:00 gluh@stripped +2 -0
Fix for bug#9586: information_schema doesn't contain table with trigger
information(2nd version)
(see also wl#1996 TRIGGERS view)
# 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: gluh
# Host: eagle.intranet.mysql.r18.ru
# Root: /home/gluh/MySQL/Bugs/5.0.9586
--- 1.305/sql/mysql_priv.h Wed Jun 1 13:52:58 2005
+++ 1.306/sql/mysql_priv.h Fri Jun 3 13:23:00 2005
@@ -1048,6 +1048,10 @@
extern const char *myisam_recover_options_str;
extern const char *in_left_expr_name, *in_additional_cond;
extern const char * const triggers_file_ext;
+extern const LEX_STRING trg_action_time_type_name[];
+extern uint action_time_type_count;
+extern const LEX_STRING trg_event_type_name[];
+extern uint action_event_type_count;
extern Eq_creator eq_creator;
extern Ne_creator ne_creator;
extern Gt_creator gt_creator;
--- 1.248/sql/sql_show.cc Tue May 31 13:15:18 2005
+++ 1.249/sql/sql_show.cc Fri Jun 3 13:23:00 2005
@@ -21,6 +21,7 @@
#include "sql_select.h" // For select_describe
#include "repl_failsafe.h"
#include "sp_head.h"
+#include "sql_trigger.h"
#include <my_dir.h>
#ifdef HAVE_BERKELEY_DB
@@ -3047,6 +3048,80 @@
}
+/*
+ Fill 'triggers' table record with data
+
+ SYNOPSIS
+ get_schema_triggers_record()
+ thd thread handler
+ tables processed table
+ table I_S table
+ res result of opening of
+ processed table
+ base_name db name
+ file_name table name
+
+ RETURN
+ 0 success
+ # error
+*/
+
+static int get_schema_triggers_record(THD *thd, struct st_table_list *tables,
+ TABLE *table, bool res,
+ const char *base_name,
+ const char *file_name)
+{
+ CHARSET_INFO *cs= system_charset_info;
+ DBUG_ENTER("get_schema_triggers_record");
+
+ /*
+ res can be non zero value when processed table is a view
+ or error happened during opening of processed table
+ */
+ if (res)
+ {
+ if (!tables->view)
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ thd->net.last_errno, thd->net.last_error);
+ thd->clear_error();
+ DBUG_RETURN(0);
+ }
+
+ if (tables->table->triggers)
+ {
+ for (uint i= 0; i < action_event_type_count; i++)
+ {
+ for (uint j= 0; j < action_time_type_count; j++)
+ {
+ sp_head *trg= (tables->table->triggers->
+ get_trigger((enum trg_event_type) i,
+ (enum trg_action_time_type) j));
+ if (trg)
+ {
+ restore_record(table, s->default_values);
+ table->field[1]->store(trg->m_db.str, trg->m_db.length, cs);
+ table->field[2]->store(trg->m_name.str, trg->m_name.length, cs);
+ table->field[3]->store(trg_event_type_name[i].str,
+ trg_event_type_name[i].length, cs);
+ table->field[5]->store(base_name, strlen(base_name), cs);
+ table->field[6]->store(file_name, strlen(file_name), cs);
+ table->field[9]->store(trg->m_body.str, trg->m_body.length, cs);
+ table->field[10]->store("ROW", 3, cs);
+ table->field[11]->store(trg_action_time_type_name[j].str,
+ trg_action_time_type_name[j].length, cs);
+ table->field[14]->store("OLD", 3, cs);
+ table->field[15]->store("NEW", 3, cs);
+ if (schema_table_store_record(thd, table))
+ DBUG_RETURN(1);
+ }
+ }
+ }
+ }
+ DBUG_RETURN(0);
+}
+
+
+
int fill_open_tables(THD *thd, TABLE_LIST *tables, COND *cond)
{
DBUG_ENTER("fill_open_tables");
@@ -3820,6 +3895,29 @@
};
+ST_FIELD_INFO trigger_fields_info[]=
+{
+ {"TRIGGER_CATALOG", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
+ {"TRIGGER_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"TRIGGER_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"EVENT_MANIPULATION", 6, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"EVENT_OBJECT_CATALOG", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
+ {"EVENT_OBJECT_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"EVENT_OBJECT_TABLE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"ACTION_ORDER", 10, MYSQL_TYPE_LONG, 0, 1, 0},
+ {"ACTION_CONDITION", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
+ {"ACTION_STATEMENT", 65535, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"ACTION_ORIENTATION", 3, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"ACTION_TIMING", 6, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"ACTION_REFERENCE_OLD_TABLE", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
+ {"ACTION_REFERENCE_NEW_TABLE", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
+ {"ACTION_REFERENCE_OLD_ROW", 3, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"ACTION_REFERENCE_NEW_ROW", 3, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"CREATED", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, 0},
+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
+};
+
+
/*
Description of ST_FIELD_INFO in table.h
*/
@@ -3864,6 +3962,8 @@
make_old_format, 0, -1, -1, 1},
{"VARIABLES", variables_fields_info, create_schema_table, fill_variables,
make_old_format, 0, -1, -1, 1},
+ {"TRIGGERS", trigger_fields_info, create_schema_table,
+ get_all_tables, 0, get_schema_triggers_record, 5, 6, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0}
};
--- 1.387/sql/sql_yacc.yy Wed Jun 1 18:50:44 2005
+++ 1.388/sql/sql_yacc.yy Fri Jun 3 13:23:00 2005
@@ -1275,7 +1275,8 @@
bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics));
lex->sphead->m_chistics= &lex->sp_chistics;
- lex->sphead->m_body_begin= lex->tok_start;
+ lex->sphead->m_body_begin= lex->ptr;
+ sp->m_name= $3;
}
sp_proc_stmt
{
--- 1.18/sql/sql_trigger.cc Tue May 24 23:19:28 2005
+++ 1.19/sql/sql_trigger.cc Fri Jun 3 13:23:00 2005
@@ -5,6 +5,21 @@
static const LEX_STRING triggers_file_type= {(char *)"TRIGGERS", 8};
+const LEX_STRING trg_action_time_type_name[]=
+{
+ { (char*) "BEFORE", sizeof("BEFORE") },
+ { (char*) "AFTER", sizeof("AFTER") }
+};
+uint action_time_type_count= array_elements(trg_action_time_type_name);
+
+const LEX_STRING trg_event_type_name[]=
+{
+ { (char*) "INSERT", sizeof("INSERT") },
+ { (char*) "UPDATE", sizeof("UPDATE") },
+ { (char*) "DELETE", sizeof("DELETE") }
+};
+uint action_event_type_count= array_elements(trg_event_type_name);
+
const char * const triggers_file_ext= ".TRG";
/*
--- 1.7/sql/sql_trigger.h Tue May 24 23:19:28 2005
+++ 1.8/sql/sql_trigger.h Fri Jun 3 13:23:00 2005
@@ -106,6 +106,11 @@
return test(bodies[TRG_EVENT_UPDATE][TRG_ACTION_BEFORE]);
}
+ sp_head *get_trigger(trg_event_type event, trg_action_time_type time_type)
+ {
+ return bodies[event][time_type];
+ }
+
friend class Item_trigger_field;
private:
--- 1.36/mysql-test/t/information_schema.test Mon May 9 22:21:39 2005
+++ 1.37/mysql-test/t/information_schema.test Fri Jun 3 13:23:00 2005
@@ -493,3 +493,34 @@
#
SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
+#
+# TRIGGERS table test
+#
+create table t1 (i int, j int);
+
+delimiter |;
+create trigger trg1 before insert on t1 for each row
+begin
+ if new.j > 10 then
+ set new.j := 10;
+ end if;
+end|
+create trigger trg2 before update on t1 for each row
+begin
+ if old.i % 2 = 0 then
+ set new.j := -1;
+ end if;
+end|
+create trigger trg3 after update on t1 for each row
+begin
+ if new.j = -1 then
+ set @fired:= "Yes";
+ end if;
+end|
+delimiter ;|
+select * from information_schema.triggers;
+
+drop trigger t1.trg1;
+drop trigger t1.trg2;
+drop trigger t1.trg3;
+drop table t1;
--- 1.2/mysql-test/r/information_schema_db.result Tue May 24 15:35:16 2005
+++ 1.3/mysql-test/r/information_schema_db.result Fri Jun 3 13:23:00 2005
@@ -16,11 +16,13 @@
COLUMN_PRIVILEGES
TABLE_CONSTRAINTS
KEY_COLUMN_USAGE
+TRIGGERS
show tables from INFORMATION_SCHEMA like 'T%';
Tables_in_information_schema (T%)
TABLES
TABLE_PRIVILEGES
TABLE_CONSTRAINTS
+TRIGGERS
create database `inf%`;
use `inf%`;
show tables;
| Thread |
|---|
| • bk commit into 5.0 tree (gluh:1.1956) BUG#9586 | gluh | 3 Jun |