From 447eff2d98af4bd229f71e109ae568d4155c30cf Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Thu, 1 Nov 2007 14:42:14 +0200 Subject: [PATCH] Bug #31866: MySQL Server crashes on SHOW CREATE TRIGGER statement SHOW CREATE TRIGGER was not checking for detected errors opening/reading the trigger file. Fixed to return the already generated error. --- mysql-test/r/trigger.result | 6 ++++++ mysql-test/t/trigger.test | 12 ++++++++++++ sql/sql_show.cc | 3 +++ 3 files changed, 21 insertions(+) diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index 189722bfe9b..47ffc90e3cd 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -1978,3 +1978,9 @@ a 1 drop table table_25411_a; drop table table_25411_b; +DROP TRIGGER IF EXISTS trg; +Warnings: +Note 1360 Trigger does not exist +SHOW CREATE TRIGGER trg; +ERROR HY000: Trigger does not exist +End of 5.1 tests. diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index 9f4634e1e17..1c98a0f8d29 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -2246,3 +2246,15 @@ select * from table_25411_a; drop table table_25411_a; drop table table_25411_b; +# +# Bug #31866: MySQL Server crashes on SHOW CREATE TRIGGER statement +# + +--disable-warnings +DROP TRIGGER IF EXISTS trg; +--enable-warnings + +--error ER_TRG_DOES_NOT_EXIST +SHOW CREATE TRIGGER trg; + +--echo End of 5.1 tests. diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 049c050c288..1969472dff4 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -6862,6 +6862,9 @@ bool show_create_trigger(THD *thd, const sp_name *trg_name) { TABLE_LIST *lst= get_trigger_table(thd, trg_name); + if (!lst) + return TRUE; + /* Open the table by name in order to load Table_triggers_list object.