diff options
Diffstat (limited to 'sql/sql_trigger.cc')
-rw-r--r-- | sql/sql_trigger.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 7d9dc25f483..59c70880baf 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2004, 2012, Oracle and/or its affiliates. - Copyright (c) 2010, 2021, MariaDB + Copyright (c) 2010, 2022, MariaDB 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 @@ -415,6 +415,10 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) MDL_ticket *mdl_ticket= NULL; MDL_request mdl_request_for_trn; 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 }; + DBUG_ENTER("mysql_create_or_drop_trigger"); /* Charset of the buffer for statement must be system one. */ @@ -540,8 +544,12 @@ 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); + + /* We do not allow creation of triggers on temporary tables or sequence. */ + if (tables->required_type == TABLE_TYPE_SEQUENCE || + (create && thd->find_tmp_table_share(tables))) { my_error(ER_TRG_ON_VIEW_OR_TEMP_TABLE, MYF(0), tables->alias.str); goto end; |