summaryrefslogtreecommitdiff
path: root/sql/sql_trigger.cc
diff options
context:
space:
mode:
authorunknown <gbichot@quadita2.mysql.com>2005-05-06 18:52:19 +0200
committerunknown <gbichot@quadita2.mysql.com>2005-05-06 18:52:19 +0200
commit6f83de163b311f05aa95c5d79879425fa1326535 (patch)
tree4f486a352732a6b1f04e190b6cf3f4d62fc3a5df /sql/sql_trigger.cc
parentf1def25a89e3dc2ed191335e9d5f7843de245e0a (diff)
downloadmariadb-git-6f83de163b311f05aa95c5d79879425fa1326535.tar.gz
Dmitri please review. Fix for BUG#10417 "CREATE TRIGGER not written to binlog":
writing DROP and CREATE TRIGGER to binlog, disabling binlogging of substatements, testing. mysql-test/r/rpl_sp.result: result update mysql-test/t/rpl_sp.test: removing useless lines, plus testing replication of triggers sql/sql_trigger.cc: trigger can be used to destroy slave, so only SUPER can create it by default. If create|drop goes ok, binlog CREATE TRIGGER and DROP TRIGGER. sql/sql_trigger.h: disable binlogging of substatements of triggers (even if now triggers can't do updates)
Diffstat (limited to 'sql/sql_trigger.cc')
-rw-r--r--sql/sql_trigger.cc26
1 files changed, 25 insertions, 1 deletions
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index 5b6f12eab52..ebf46a34896 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -98,6 +98,21 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
if (wait_if_global_read_lock(thd, 0, 0))
DBUG_RETURN(TRUE);
+ /*
+ There is no DETERMINISTIC clause for triggers, so can't check it.
+ But a trigger can in theory be used to do nasty things (if it supported
+ DROP for example) so we do the check for privileges. For now there is
+ already a stronger test above (see start of the function); but when this
+ stronger test will be removed, the test below will hold.
+ */
+ if (!trust_routine_creators && mysql_bin_log.is_open() &&
+ !(thd->master_access & SUPER_ACL))
+ {
+ my_message(ER_BINLOG_CREATE_ROUTINE_NEED_SUPER,
+ ER(ER_BINLOG_CREATE_ROUTINE_NEED_SUPER), MYF(0));
+ DBUG_RETURN(TRUE);
+ }
+
VOID(pthread_mutex_lock(&LOCK_open));
result= (create ?
table->triggers->create_trigger(thd, tables):
@@ -109,7 +124,16 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
start_waiting_global_read_lock(thd);
if (!result)
- send_ok(thd);
+ {
+ if (mysql_bin_log.is_open())
+ {
+ thd->clear_error();
+ /* Such a statement can always go directly to binlog, no trans cache */
+ Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE);
+ mysql_bin_log.write(&qinfo);
+ }
+ send_ok(thd);
+ }
DBUG_RETURN(result);
}