MDEV-20985 Add LEX methods stmt_drop_{function|procedure}() and stmt_alter_{function|procedure}_start()
Adding a few helper LEX methods, to unify sql_yacc.yy and sql_yacc_ora.yy easier
This commit is contained in:
parent
79e295b601
commit
46f2f24ec4
@ -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 *LEX::row_field_name(THD *thd, const Lex_ident_sys_st &name)
|
||||||
{
|
{
|
||||||
Spvar_definition *res;
|
Spvar_definition *res;
|
||||||
|
@ -4572,6 +4572,20 @@ public:
|
|||||||
const Lex_ident_sys_st &name,
|
const Lex_ident_sys_st &name,
|
||||||
Item_result return_type,
|
Item_result return_type,
|
||||||
const LEX_CSTRING &soname);
|
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);
|
Spvar_definition *row_field_name(THD *thd, const Lex_ident_sys_st &name);
|
||||||
|
|
||||||
bool set_field_type_udt(Lex_field_type_st *type,
|
bool set_field_type_udt(Lex_field_type_st *type,
|
||||||
|
@ -7892,38 +7892,18 @@ alter:
|
|||||||
}
|
}
|
||||||
| ALTER PROCEDURE_SYM sp_name
|
| ALTER PROCEDURE_SYM sp_name
|
||||||
{
|
{
|
||||||
LEX *lex= Lex;
|
if (Lex->stmt_alter_procedure_start($3))
|
||||||
|
|
||||||
if (unlikely(lex->sphead))
|
|
||||||
my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "PROCEDURE"));
|
|
||||||
if (Lex->main_select_push())
|
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
lex->sp_chistics.init();
|
|
||||||
}
|
}
|
||||||
sp_a_chistics
|
sp_a_chistics
|
||||||
{
|
stmt_end {}
|
||||||
LEX *lex=Lex;
|
|
||||||
|
|
||||||
lex->sql_command= SQLCOM_ALTER_PROCEDURE;
|
|
||||||
lex->spname= $3;
|
|
||||||
} stmt_end {}
|
|
||||||
| ALTER FUNCTION_SYM sp_name
|
| ALTER FUNCTION_SYM sp_name
|
||||||
{
|
{
|
||||||
LEX *lex= Lex;
|
if (Lex->stmt_alter_function_start($3))
|
||||||
|
|
||||||
if (unlikely(lex->sphead))
|
|
||||||
my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "FUNCTION"));
|
|
||||||
if (Lex->main_select_push())
|
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
lex->sp_chistics.init();
|
|
||||||
}
|
}
|
||||||
sp_a_chistics
|
sp_a_chistics
|
||||||
{
|
stmt_end {}
|
||||||
LEX *lex=Lex;
|
|
||||||
|
|
||||||
lex->sql_command= SQLCOM_ALTER_FUNCTION;
|
|
||||||
lex->spname= $3;
|
|
||||||
} stmt_end {}
|
|
||||||
| ALTER view_algorithm definer_opt opt_view_suid VIEW_SYM table_ident
|
| ALTER view_algorithm definer_opt opt_view_suid VIEW_SYM table_ident
|
||||||
{
|
{
|
||||||
if (Lex->main_select_push())
|
if (Lex->main_select_push())
|
||||||
@ -13343,40 +13323,18 @@ drop:
|
|||||||
}
|
}
|
||||||
| DROP FUNCTION_SYM opt_if_exists ident '.' ident
|
| DROP FUNCTION_SYM opt_if_exists ident '.' ident
|
||||||
{
|
{
|
||||||
LEX *lex= thd->lex;
|
if (Lex->stmt_drop_function($3, $4, $6))
|
||||||
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))
|
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
lex->spname= spname;
|
|
||||||
}
|
}
|
||||||
| DROP FUNCTION_SYM opt_if_exists ident
|
| DROP FUNCTION_SYM opt_if_exists ident
|
||||||
{
|
{
|
||||||
LEX *lex= thd->lex;
|
if (Lex->stmt_drop_function($3, $4))
|
||||||
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)))
|
|
||||||
MYSQL_YYABORT;
|
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
|
| DROP PROCEDURE_SYM opt_if_exists sp_name
|
||||||
{
|
{
|
||||||
LEX *lex=Lex;
|
if (Lex->stmt_drop_procedure($3, $4))
|
||||||
if (unlikely(lex->sphead))
|
MYSQL_YYABORT;
|
||||||
my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "PROCEDURE"));
|
|
||||||
lex->set_command(SQLCOM_DROP_PROCEDURE, $3);
|
|
||||||
lex->spname= $4;
|
|
||||||
}
|
}
|
||||||
| DROP USER_SYM opt_if_exists clear_privileges user_list
|
| DROP USER_SYM opt_if_exists clear_privileges user_list
|
||||||
{
|
{
|
||||||
|
@ -7855,38 +7855,18 @@ alter:
|
|||||||
}
|
}
|
||||||
| ALTER PROCEDURE_SYM sp_name
|
| ALTER PROCEDURE_SYM sp_name
|
||||||
{
|
{
|
||||||
LEX *lex= Lex;
|
if (Lex->stmt_alter_procedure_start($3))
|
||||||
|
|
||||||
if (unlikely(lex->sphead))
|
|
||||||
my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "PROCEDURE"));
|
|
||||||
if (Lex->main_select_push())
|
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
lex->sp_chistics.init();
|
|
||||||
}
|
}
|
||||||
sp_a_chistics
|
sp_a_chistics
|
||||||
{
|
stmt_end {}
|
||||||
LEX *lex=Lex;
|
|
||||||
|
|
||||||
lex->sql_command= SQLCOM_ALTER_PROCEDURE;
|
|
||||||
lex->spname= $3;
|
|
||||||
} stmt_end {}
|
|
||||||
| ALTER FUNCTION_SYM sp_name
|
| ALTER FUNCTION_SYM sp_name
|
||||||
{
|
{
|
||||||
LEX *lex= Lex;
|
if (Lex->stmt_alter_function_start($3))
|
||||||
|
|
||||||
if (unlikely(lex->sphead))
|
|
||||||
my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "FUNCTION"));
|
|
||||||
if (Lex->main_select_push())
|
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
lex->sp_chistics.init();
|
|
||||||
}
|
}
|
||||||
sp_a_chistics
|
sp_a_chistics
|
||||||
{
|
stmt_end {}
|
||||||
LEX *lex=Lex;
|
|
||||||
|
|
||||||
lex->sql_command= SQLCOM_ALTER_FUNCTION;
|
|
||||||
lex->spname= $3;
|
|
||||||
} stmt_end {}
|
|
||||||
| ALTER view_algorithm definer_opt opt_view_suid VIEW_SYM table_ident
|
| ALTER view_algorithm definer_opt opt_view_suid VIEW_SYM table_ident
|
||||||
{
|
{
|
||||||
if (Lex->main_select_push())
|
if (Lex->main_select_push())
|
||||||
@ -13331,40 +13311,18 @@ drop:
|
|||||||
}
|
}
|
||||||
| DROP FUNCTION_SYM opt_if_exists ident '.' ident
|
| DROP FUNCTION_SYM opt_if_exists ident '.' ident
|
||||||
{
|
{
|
||||||
LEX *lex= thd->lex;
|
if (Lex->stmt_drop_function($3, $4, $6))
|
||||||
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))
|
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
lex->spname= spname;
|
|
||||||
}
|
}
|
||||||
| DROP FUNCTION_SYM opt_if_exists ident
|
| DROP FUNCTION_SYM opt_if_exists ident
|
||||||
{
|
{
|
||||||
LEX *lex= thd->lex;
|
if (Lex->stmt_drop_function($3, $4))
|
||||||
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)))
|
|
||||||
MYSQL_YYABORT;
|
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
|
| DROP PROCEDURE_SYM opt_if_exists sp_name
|
||||||
{
|
{
|
||||||
LEX *lex=Lex;
|
if (Lex->stmt_drop_procedure($3, $4))
|
||||||
if (unlikely(lex->sphead))
|
MYSQL_YYABORT;
|
||||||
my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "PROCEDURE"));
|
|
||||||
lex->set_command(SQLCOM_DROP_PROCEDURE, $3);
|
|
||||||
lex->spname= $4;
|
|
||||||
}
|
}
|
||||||
| DROP USER_SYM opt_if_exists clear_privileges user_list
|
| DROP USER_SYM opt_if_exists clear_privileges user_list
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user