diff options
-rw-r--r-- | mysql-test/main/trigger.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/funcs_1/r/innodb_trig_0407.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/funcs_1/r/memory_trig_0407.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/funcs_1/r/myisam_trig_0407.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/sql_sequence/create.result | 6 | ||||
-rw-r--r-- | mysql-test/suite/sql_sequence/create.test | 8 | ||||
-rw-r--r-- | sql/share/errmsg-utf8.txt | 4 | ||||
-rw-r--r-- | sql/sql_trigger.cc | 12 |
8 files changed, 30 insertions, 8 deletions
diff --git a/mysql-test/main/trigger.result b/mysql-test/main/trigger.result index 756fd8591dd..571d78aa9e2 100644 --- a/mysql-test/main/trigger.result +++ b/mysql-test/main/trigger.result @@ -319,7 +319,7 @@ drop table t1; drop table t3; create temporary table t1 (i int); create trigger trg before insert on t1 for each row set @a:=1; -ERROR HY000: Trigger's 't1' is view or temporary table +ERROR HY000: Trigger's 't1' is view, temporary table or sequence drop table t1; create table t1 (x1col char); create trigger tx1 before insert on t1 for each row set new.x1col = 'x'; diff --git a/mysql-test/suite/funcs_1/r/innodb_trig_0407.result b/mysql-test/suite/funcs_1/r/innodb_trig_0407.result index 4753efd1794..b2ea135e011 100644 --- a/mysql-test/suite/funcs_1/r/innodb_trig_0407.result +++ b/mysql-test/suite/funcs_1/r/innodb_trig_0407.result @@ -237,7 +237,7 @@ Testcase 3.5.5.2: Create temporary table t1_temp (f1 bigint signed, f2 bigint unsigned); Create trigger trg2 before INSERT on t1_temp for each row set new.f2=9999; -ERROR HY000: Trigger's 't1_temp' is view or temporary table +ERROR HY000: Trigger's 't1_temp' is view, temporary table or sequence drop table t1_temp; Testcase 3.5.5.3: diff --git a/mysql-test/suite/funcs_1/r/memory_trig_0407.result b/mysql-test/suite/funcs_1/r/memory_trig_0407.result index c21c206f118..48858e8787a 100644 --- a/mysql-test/suite/funcs_1/r/memory_trig_0407.result +++ b/mysql-test/suite/funcs_1/r/memory_trig_0407.result @@ -237,7 +237,7 @@ Testcase 3.5.5.2: Create temporary table t1_temp (f1 bigint signed, f2 bigint unsigned); Create trigger trg2 before INSERT on t1_temp for each row set new.f2=9999; -ERROR HY000: Trigger's 't1_temp' is view or temporary table +ERROR HY000: Trigger's 't1_temp' is view, temporary table or sequence drop table t1_temp; Testcase 3.5.5.3: diff --git a/mysql-test/suite/funcs_1/r/myisam_trig_0407.result b/mysql-test/suite/funcs_1/r/myisam_trig_0407.result index c21c206f118..48858e8787a 100644 --- a/mysql-test/suite/funcs_1/r/myisam_trig_0407.result +++ b/mysql-test/suite/funcs_1/r/myisam_trig_0407.result @@ -237,7 +237,7 @@ Testcase 3.5.5.2: Create temporary table t1_temp (f1 bigint signed, f2 bigint unsigned); Create trigger trg2 before INSERT on t1_temp for each row set new.f2=9999; -ERROR HY000: Trigger's 't1_temp' is view or temporary table +ERROR HY000: Trigger's 't1_temp' is view, temporary table or sequence drop table t1_temp; Testcase 3.5.5.3: diff --git a/mysql-test/suite/sql_sequence/create.result b/mysql-test/suite/sql_sequence/create.result index a2f63042cd6..beb1561f9d5 100644 --- a/mysql-test/suite/sql_sequence/create.result +++ b/mysql-test/suite/sql_sequence/create.result @@ -711,3 +711,9 @@ CREATE TEMPORARY TABLE s1 (s1 INT); CREATE TEMPORARY SEQUENCE s1 (s1 INT); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(s1 INT)' at line 1 DROP TEMPORARY TABLE s1; +# Task 6: +CREATE SEQUENCE seq1 START WITH 2; +CREATE TRIGGER s1 BEFORE UPDATE ON seq1 FOR EACH ROW SET @a= 5; +ERROR HY000: Trigger's 'seq1' is view, temporary table or sequence +DROP SEQUENCE seq1; +# End of 10.4 test diff --git a/mysql-test/suite/sql_sequence/create.test b/mysql-test/suite/sql_sequence/create.test index 7e0c8f373dd..aa58b0c5fec 100644 --- a/mysql-test/suite/sql_sequence/create.test +++ b/mysql-test/suite/sql_sequence/create.test @@ -545,3 +545,11 @@ CREATE TEMPORARY TABLE s1 (s1 INT); --error ER_PARSE_ERROR CREATE TEMPORARY SEQUENCE s1 (s1 INT); DROP TEMPORARY TABLE s1; + +--echo # Task 6: +CREATE SEQUENCE seq1 START WITH 2; +--error ER_TRG_ON_VIEW_OR_TEMP_TABLE +CREATE TRIGGER s1 BEFORE UPDATE ON seq1 FOR EACH ROW SET @a= 5; +DROP SEQUENCE seq1; + +--echo # End of 10.4 test diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index d913563dae3..40d99ec86b3 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -5421,8 +5421,8 @@ ER_TRG_DOES_NOT_EXIST ger "Trigger existiert nicht" hindi "TRIGGER मौजूद नहीं है" ER_TRG_ON_VIEW_OR_TEMP_TABLE - eng "Trigger's '%-.192s' is view or temporary table" - ger "'%-.192s' des Triggers ist View oder temporäre Tabelle" + eng "Trigger's '%-.192s' is view, temporary table or sequence" + hindi "'%-.192s' एक व्यू, टेम्पररी टेबल या सीक्वेंस है" ER_TRG_CANT_CHANGE_ROW eng "Updating of %s row is not allowed in %strigger" ger "Aktualisieren einer %s-Zeile ist in einem %s-Trigger nicht erlaubt" diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 08cc2113706..8df3cdc6a2e 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -413,6 +413,11 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) bool lock_upgrade_done= FALSE; MDL_ticket *mdl_ticket= NULL; Query_tables_list backup; + char path[FN_REFLEN + 1]; + char engine_name_buf[NAME_CHAR_LEN + 1]; + LEX_CSTRING engine_name= { engine_name_buf, 0 }; + bool is_sequence= 0; + DBUG_ENTER("mysql_create_or_drop_trigger"); /* Charset of the buffer for statement must be system one. */ @@ -529,8 +534,11 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) /* We should have only one table in table list. */ DBUG_ASSERT(tables->next_global == 0); - /* We do not allow creation of triggers on temporary tables. */ - if (create && thd->find_tmp_table_share(tables)) + build_table_filename(path, sizeof(path) - 1, tables->db.str, tables->alias.str, ".frm", 0); + tables->required_type= dd_frm_type(NULL, path, &engine_name, &is_sequence); + + /* We do not allow creation of triggers on temporary tables or sequence. */ + if (is_sequence || (create && thd->find_tmp_table_share(tables))) { my_error(ER_TRG_ON_VIEW_OR_TEMP_TABLE, MYF(0), tables->alias.str); goto end; |