From 4793d319461e5a91cc3a25ab2d874f87adaf86a8 Mon Sep 17 00:00:00 2001 From: Akshay Suryawanshi Date: Mon, 16 Nov 2020 16:31:16 -0500 Subject: [PATCH] Drop trigger if exists error fix --- sql/sql_trigger.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 384f1c1ca28..7ce3a292d87 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -79,6 +79,7 @@ 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; + bool if_exists= thd->lex->drop_if_exists; DBUG_ENTER("mysql_create_or_drop_trigger"); @@ -129,8 +130,6 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) if (!create) { - bool if_exists= thd->lex->drop_if_exists; - /* Protect the query table list from the temporary and potentially destructive changes necessary to open the trigger's table. @@ -239,7 +238,9 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) { if (!create) { - my_error(ER_TRG_DOES_NOT_EXIST, MYF(0)); + if (!if_exists){ + my_error(ER_TRG_DOES_NOT_EXIST, MYF(0)); + } goto end; } -- 2.28.0