From 63e732fe6140f1ca9dbfacb18bff5119c3c67647 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 29 Oct 2009 10:51:04 -0600 Subject: [PATCH] Bug#33637 SHOW PROCEDURE CODE/SHOW FUNCTION CODE sp_name gives a syntax error. Backport for 5.5 In non debug builds, the statements: - SHOW PROCEDURE CODE - SHOW FUNCTION CODE used to fail with a "syntax error", which is misleading. These statements have been changed to return the following error for non debug builds: ERROR HY000: The 'SHOW PROCEDURE|FUNCTION CODE' feature is disabled; you need MySQL built with '--with-debug' to have it working For debug builds (./configure --with-debug), nothing is changed. --- mysql-test/include/have_nodebug.inc | 4 ++++ mysql-test/r/have_nodebug.require | 2 ++ mysql-test/r/sp-no-code.result | 4 ++++ mysql-test/t/sp-no-code.test | 12 ++++++++++++ sql/sql_parse.cc | 8 ++++++-- sql/sql_yacc.yy | 10 ---------- 6 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 mysql-test/include/have_nodebug.inc create mode 100644 mysql-test/r/have_nodebug.require create mode 100644 mysql-test/r/sp-no-code.result create mode 100644 mysql-test/t/sp-no-code.test diff --git a/mysql-test/include/have_nodebug.inc b/mysql-test/include/have_nodebug.inc new file mode 100644 index 00000000000..3a5b073cd2e --- /dev/null +++ b/mysql-test/include/have_nodebug.inc @@ -0,0 +1,4 @@ +-- require r/have_nodebug.require +disable_query_log; +select (version() like '%debug%') as debug; +enable_query_log; diff --git a/mysql-test/r/have_nodebug.require b/mysql-test/r/have_nodebug.require new file mode 100644 index 00000000000..ff251521aa8 --- /dev/null +++ b/mysql-test/r/have_nodebug.require @@ -0,0 +1,2 @@ +debug +0 diff --git a/mysql-test/r/sp-no-code.result b/mysql-test/r/sp-no-code.result new file mode 100644 index 00000000000..77d2c93eaf6 --- /dev/null +++ b/mysql-test/r/sp-no-code.result @@ -0,0 +1,4 @@ +show procedure code foo; +ERROR HY000: The 'SHOW PROCEDURE|FUNCTION CODE' feature is disabled; you need MySQL built with '--with-debug' to have it working +show function code foo; +ERROR HY000: The 'SHOW PROCEDURE|FUNCTION CODE' feature is disabled; you need MySQL built with '--with-debug' to have it working diff --git a/mysql-test/t/sp-no-code.test b/mysql-test/t/sp-no-code.test new file mode 100644 index 00000000000..ce16c32a270 --- /dev/null +++ b/mysql-test/t/sp-no-code.test @@ -0,0 +1,12 @@ +# +# Test the debugging feature "show procedure/function code " +# + +-- source include/have_nodebug.inc + +--error ER_FEATURE_DISABLED +show procedure code foo; + +--error ER_FEATURE_DISABLED +show function code foo; + diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 285cd7d0bc3..08af00bb024 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4658,10 +4658,10 @@ create_sp_error: } break; } -#ifndef DBUG_OFF case SQLCOM_SHOW_PROC_CODE: case SQLCOM_SHOW_FUNC_CODE: { +#ifndef DBUG_OFF sp_head *sp; if (lex->sql_command == SQLCOM_SHOW_PROC_CODE) @@ -4678,8 +4678,12 @@ create_sp_error: goto error; } break; - } +#else + my_error(ER_FEATURE_DISABLED, MYF(0), + "SHOW PROCEDURE|FUNCTION CODE", "--with-debug"); + goto error; #endif // ifndef DBUG_OFF + } case SQLCOM_SHOW_CREATE_TRIGGER: { if (lex->spname->m_name.length > NAME_LEN) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 60c40ec05d6..6eb0d152617 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -10469,23 +10469,13 @@ show_param: } | PROCEDURE CODE_SYM sp_name { -#ifdef DBUG_OFF - my_parse_error(ER(ER_SYNTAX_ERROR)); - MYSQL_YYABORT; -#else Lex->sql_command= SQLCOM_SHOW_PROC_CODE; Lex->spname= $3; -#endif } | FUNCTION_SYM CODE_SYM sp_name { -#ifdef DBUG_OFF - my_parse_error(ER(ER_SYNTAX_ERROR)); - MYSQL_YYABORT; -#else Lex->sql_command= SQLCOM_SHOW_FUNC_CODE; Lex->spname= $3; -#endif } | CREATE EVENT_SYM sp_name {