diff options
-rw-r--r-- | sql/sql_lex.cc | 83 | ||||
-rw-r--r-- | sql/sql_lex.h | 14 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 58 | ||||
-rw-r--r-- | sql/sql_yacc_ora.yy | 58 |
4 files changed, 113 insertions, 100 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 070a2dd8189..34dcb0bcbe9 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -10394,6 +10394,89 @@ bool LEX::stmt_create_stored_function_start(const DDL_options_st &options, } +bool LEX::stmt_drop_function(const DDL_options_st &options, + const Lex_ident_sys_st &db, + const Lex_ident_sys_st &name) +{ + if (unlikely(db.str && check_db_name((LEX_STRING*) &db))) + { + my_error(ER_WRONG_DB_NAME, MYF(0), db.str); + return true; + } + if (unlikely(sphead)) + { + my_error(ER_SP_NO_DROP_SP, MYF(0), "FUNCTION"); + return true; + } + set_command(SQLCOM_DROP_FUNCTION, options); + spname= new (thd->mem_root) sp_name(&db, &name, true); + return spname == NULL; +} + + +bool LEX::stmt_drop_function(const DDL_options_st &options, + const Lex_ident_sys_st &name) +{ + LEX_CSTRING db= {0, 0}; + if (unlikely(sphead)) + { + my_error(ER_SP_NO_DROP_SP, MYF(0), "FUNCTION"); + return true; + } + if (thd->db.str && unlikely(copy_db_to(&db))) + return true; + set_command(SQLCOM_DROP_FUNCTION, options); + spname= new (thd->mem_root) sp_name(&db, &name, false); + return spname == NULL; +} + + +bool LEX::stmt_drop_procedure(const DDL_options_st &options, + sp_name *name) +{ + if (unlikely(sphead)) + { + my_error(ER_SP_NO_DROP_SP, MYF(0), "PROCEDURE"); + return true; + } + set_command(SQLCOM_DROP_PROCEDURE, options); + spname= name; + return false; +} + + +bool LEX::stmt_alter_function_start(sp_name *name) +{ + if (unlikely(sphead)) + { + my_error(ER_SP_NO_DROP_SP, MYF(0), "FUNCTION"); + return true; + } + if (main_select_push()) + return true; + sp_chistics.init(); + sql_command= SQLCOM_ALTER_FUNCTION; + spname= name; + return false; +} + + +bool LEX::stmt_alter_procedure_start(sp_name *name) +{ + if (unlikely(sphead)) + { + my_error(ER_SP_NO_DROP_SP, MYF(0), "PROCEDURE"); + return true; + } + if (main_select_push()) + return true; + sp_chistics.init(); + sql_command= SQLCOM_ALTER_PROCEDURE; + spname= name; + return false; +} + + Spvar_definition *LEX::row_field_name(THD *thd, const Lex_ident_sys_st &name) { Spvar_definition *res; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 3aa458d47e5..e34cd2ebfd7 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -4572,6 +4572,20 @@ public: const Lex_ident_sys_st &name, Item_result return_type, const LEX_CSTRING &soname); + + bool stmt_drop_function(const DDL_options_st &options, + const Lex_ident_sys_st &db, + const Lex_ident_sys_st &name); + + bool stmt_drop_function(const DDL_options_st &options, + const Lex_ident_sys_st &name); + + bool stmt_drop_procedure(const DDL_options_st &options, + sp_name *name); + + bool stmt_alter_function_start(sp_name *name); + bool stmt_alter_procedure_start(sp_name *name); + Spvar_definition *row_field_name(THD *thd, const Lex_ident_sys_st &name); bool set_field_type_udt(Lex_field_type_st *type, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 853bdb3cd28..e111b268e65 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -7892,38 +7892,18 @@ alter: } | ALTER PROCEDURE_SYM sp_name { - LEX *lex= Lex; - - if (unlikely(lex->sphead)) - my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "PROCEDURE")); - if (Lex->main_select_push()) + if (Lex->stmt_alter_procedure_start($3)) MYSQL_YYABORT; - lex->sp_chistics.init(); } sp_a_chistics - { - LEX *lex=Lex; - - lex->sql_command= SQLCOM_ALTER_PROCEDURE; - lex->spname= $3; - } stmt_end {} + stmt_end {} | ALTER FUNCTION_SYM sp_name { - LEX *lex= Lex; - - if (unlikely(lex->sphead)) - my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "FUNCTION")); - if (Lex->main_select_push()) + if (Lex->stmt_alter_function_start($3)) MYSQL_YYABORT; - lex->sp_chistics.init(); } sp_a_chistics - { - LEX *lex=Lex; - - lex->sql_command= SQLCOM_ALTER_FUNCTION; - lex->spname= $3; - } stmt_end {} + stmt_end {} | ALTER view_algorithm definer_opt opt_view_suid VIEW_SYM table_ident { if (Lex->main_select_push()) @@ -13343,40 +13323,18 @@ drop: } | DROP FUNCTION_SYM opt_if_exists ident '.' ident { - LEX *lex= thd->lex; - sp_name *spname; - if (unlikely($4.str && check_db_name((LEX_STRING*) &$4))) - my_yyabort_error((ER_WRONG_DB_NAME, MYF(0), $4.str)); - if (unlikely(lex->sphead)) - my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "FUNCTION")); - lex->set_command(SQLCOM_DROP_FUNCTION, $3); - spname= new (thd->mem_root) sp_name(&$4, &$6, true); - if (unlikely(spname == NULL)) + if (Lex->stmt_drop_function($3, $4, $6)) MYSQL_YYABORT; - lex->spname= spname; } | DROP FUNCTION_SYM opt_if_exists ident { - LEX *lex= thd->lex; - LEX_CSTRING db= {0, 0}; - sp_name *spname; - if (unlikely(lex->sphead)) - my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "FUNCTION")); - if (thd->db.str && unlikely(lex->copy_db_to(&db))) + if (Lex->stmt_drop_function($3, $4)) MYSQL_YYABORT; - lex->set_command(SQLCOM_DROP_FUNCTION, $3); - spname= new (thd->mem_root) sp_name(&db, &$4, false); - if (unlikely(spname == NULL)) - MYSQL_YYABORT; - lex->spname= spname; } | DROP PROCEDURE_SYM opt_if_exists sp_name { - LEX *lex=Lex; - if (unlikely(lex->sphead)) - my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "PROCEDURE")); - lex->set_command(SQLCOM_DROP_PROCEDURE, $3); - lex->spname= $4; + if (Lex->stmt_drop_procedure($3, $4)) + MYSQL_YYABORT; } | DROP USER_SYM opt_if_exists clear_privileges user_list { diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index 35b709bd832..c3727c4819d 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -7855,38 +7855,18 @@ alter: } | ALTER PROCEDURE_SYM sp_name { - LEX *lex= Lex; - - if (unlikely(lex->sphead)) - my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "PROCEDURE")); - if (Lex->main_select_push()) + if (Lex->stmt_alter_procedure_start($3)) MYSQL_YYABORT; - lex->sp_chistics.init(); } sp_a_chistics - { - LEX *lex=Lex; - - lex->sql_command= SQLCOM_ALTER_PROCEDURE; - lex->spname= $3; - } stmt_end {} + stmt_end {} | ALTER FUNCTION_SYM sp_name { - LEX *lex= Lex; - - if (unlikely(lex->sphead)) - my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "FUNCTION")); - if (Lex->main_select_push()) + if (Lex->stmt_alter_function_start($3)) MYSQL_YYABORT; - lex->sp_chistics.init(); } sp_a_chistics - { - LEX *lex=Lex; - - lex->sql_command= SQLCOM_ALTER_FUNCTION; - lex->spname= $3; - } stmt_end {} + stmt_end {} | ALTER view_algorithm definer_opt opt_view_suid VIEW_SYM table_ident { if (Lex->main_select_push()) @@ -13331,40 +13311,18 @@ drop: } | DROP FUNCTION_SYM opt_if_exists ident '.' ident { - LEX *lex= thd->lex; - sp_name *spname; - if (unlikely($4.str && check_db_name((LEX_STRING*) &$4))) - my_yyabort_error((ER_WRONG_DB_NAME, MYF(0), $4.str)); - if (unlikely(lex->sphead)) - my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "FUNCTION")); - lex->set_command(SQLCOM_DROP_FUNCTION, $3); - spname= new (thd->mem_root) sp_name(&$4, &$6, true); - if (unlikely(spname == NULL)) + if (Lex->stmt_drop_function($3, $4, $6)) MYSQL_YYABORT; - lex->spname= spname; } | DROP FUNCTION_SYM opt_if_exists ident { - LEX *lex= thd->lex; - LEX_CSTRING db= {0, 0}; - sp_name *spname; - if (unlikely(lex->sphead)) - my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "FUNCTION")); - if (thd->db.str && unlikely(lex->copy_db_to(&db))) + if (Lex->stmt_drop_function($3, $4)) MYSQL_YYABORT; - lex->set_command(SQLCOM_DROP_FUNCTION, $3); - spname= new (thd->mem_root) sp_name(&db, &$4, false); - if (unlikely(spname == NULL)) - MYSQL_YYABORT; - lex->spname= spname; } | DROP PROCEDURE_SYM opt_if_exists sp_name { - LEX *lex=Lex; - if (unlikely(lex->sphead)) - my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "PROCEDURE")); - lex->set_command(SQLCOM_DROP_PROCEDURE, $3); - lex->spname= $4; + if (Lex->stmt_drop_procedure($3, $4)) + MYSQL_YYABORT; } | DROP USER_SYM opt_if_exists clear_privileges user_list { |