summaryrefslogtreecommitdiff
path: root/sql/sql_trigger.h
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2011-11-21 19:13:14 +0200
committerMichael Widenius <monty@askmonty.org>2011-11-21 19:13:14 +0200
commita8d03ab23519d4afc288a6490676ddb8745e3e72 (patch)
treee55f53ff3cc4b044769ca269561a933e3c93f05f /sql/sql_trigger.h
parent04f3ecf632816a940e2838949e0216d638436fd8 (diff)
parent13fefeb04ade34418cd9d99aa93bffb69fdae27e (diff)
downloadmariadb-git-a8d03ab23519d4afc288a6490676ddb8745e3e72.tar.gz
Initail merge with MySQL 5.1 (XtraDB still needs to be merged)
Fixed up copyright messages.
Diffstat (limited to 'sql/sql_trigger.h')
-rw-r--r--sql/sql_trigger.h41
1 files changed, 38 insertions, 3 deletions
diff --git a/sql/sql_trigger.h b/sql/sql_trigger.h
index f6754a75284..a7224bd74bd 100644
--- a/sql/sql_trigger.h
+++ b/sql/sql_trigger.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 2004-2005 MySQL AB
+/*
+ Copyright (c) 2004, 2011, Oracle and/or its affiliates.
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
@@ -11,7 +12,8 @@
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 */
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
/**
@@ -62,6 +64,27 @@ class Table_triggers_list: public Sql_alloc
*/
GRANT_INFO subject_table_grants[TRG_EVENT_MAX][TRG_ACTION_MAX];
+ /**
+ This flag indicates that one of the triggers was not parsed successfully,
+ and as a precaution the object has entered a state where all trigger
+ access results in errors until all such triggers are dropped. It is not
+ safe to add triggers since we don't know if the broken trigger has the
+ same name or event type. Nor is it safe to invoke any trigger for the
+ aforementioned reasons. The only safe operations are drop_trigger and
+ drop_all_triggers.
+
+ @see Table_triggers_list::set_parse_error
+ */
+ bool m_has_unparseable_trigger;
+
+ /**
+ This error will be displayed when the user tries to manipulate or invoke
+ triggers on a table that has broken triggers. It will get set only once
+ per statement and thus will contain the first parse error encountered in
+ the trigger file.
+ */
+ char m_parse_error_message[MYSQL_ERRMSG_SIZE];
+
public:
/**
Field responsible for storing triggers definitions in file.
@@ -84,7 +107,7 @@ public:
/* End of character ser context. */
Table_triggers_list(TABLE *table_arg):
- record1_field(0), trigger_table(table_arg)
+ record1_field(0), trigger_table(table_arg), m_has_unparseable_trigger(false)
{
bzero((char *)bodies, sizeof(bodies));
bzero((char *)trigger_fields, sizeof(trigger_fields));
@@ -140,6 +163,8 @@ public:
void mark_fields_used(trg_event_type event);
+ void set_parse_error_message(char *error_message);
+
friend class Item_trigger_field;
friend int sp_cache_routines_and_add_tables_for_triggers(THD *thd, LEX *lex,
TABLE_LIST *table);
@@ -155,6 +180,16 @@ private:
const char *new_db_name,
LEX_STRING *old_table_name,
LEX_STRING *new_table_name);
+
+ bool check_for_broken_triggers()
+ {
+ if (m_has_unparseable_trigger)
+ {
+ my_message(ER_PARSE_ERROR, m_parse_error_message, MYF(0));
+ return true;
+ }
+ return false;
+ }
};
extern const LEX_STRING trg_action_time_type_names[];