mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Fixed BUG#6027: Stored procedures can be renamed.
Removed the support for renaming SPs. It's non-standard, conflicted with a standard syntax, and was a bit broken anyway. mysql-test/r/sp-error.result: Removed test for renaming procedures with alter. mysql-test/r/sp.result: Removed test for renaming procedures with alter. mysql-test/t/sp-error.test: Removed test for renaming procedures with alter. mysql-test/t/sp.test: Removed test for renaming procedures with alter. sql/sp.cc: Removed support for renaming SPs. It's non-standard, conflicted with a standard syntax, and was a bit broken anyway. sql/sp.h: Removed support for renaming SPs. It's non-standard, conflicted with a standard syntax, and was a bit broken anyway. sql/sql_parse.cc: Removed support for renaming SPs. It's non-standard, conflicted with a standard syntax, and was a bit broken anyway. sql/sql_yacc.yy: Removed support for renaming SPs. It's non-standard, conflicted with a standard syntax, and was a bit broken anyway.
This commit is contained in:
@ -235,9 +235,6 @@ ERROR 24000: Cursor is not open
|
|||||||
drop procedure p|
|
drop procedure p|
|
||||||
alter procedure bar3 sql security invoker|
|
alter procedure bar3 sql security invoker|
|
||||||
ERROR 42000: PROCEDURE test.bar3 does not exist
|
ERROR 42000: PROCEDURE test.bar3 does not exist
|
||||||
alter procedure bar3 name
|
|
||||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA|
|
|
||||||
ERROR 42000: Identifier name 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' is too long
|
|
||||||
drop table t1|
|
drop table t1|
|
||||||
drop table if exists t1|
|
drop table if exists t1|
|
||||||
create table t1 (val int, x float)|
|
create table t1 (val int, x float)|
|
||||||
|
@ -893,15 +893,15 @@ select * from t1|
|
|||||||
id data
|
id data
|
||||||
chistics 1
|
chistics 1
|
||||||
delete from t1|
|
delete from t1|
|
||||||
alter procedure chistics sql security invoker name chistics2|
|
alter procedure chistics sql security invoker|
|
||||||
show create procedure chistics2|
|
show create procedure chistics|
|
||||||
Procedure sql_mode Create Procedure
|
Procedure sql_mode Create Procedure
|
||||||
chistics2 CREATE PROCEDURE `test`.`chistics2`()
|
chistics CREATE PROCEDURE `test`.`chistics`()
|
||||||
MODIFIES SQL DATA
|
MODIFIES SQL DATA
|
||||||
SQL SECURITY INVOKER
|
SQL SECURITY INVOKER
|
||||||
COMMENT 'Characteristics procedure test'
|
COMMENT 'Characteristics procedure test'
|
||||||
insert into t1 values ("chistics", 1)
|
insert into t1 values ("chistics", 1)
|
||||||
drop procedure chistics2|
|
drop procedure chistics|
|
||||||
create function chistics() returns int
|
create function chistics() returns int
|
||||||
language sql
|
language sql
|
||||||
deterministic
|
deterministic
|
||||||
@ -918,18 +918,18 @@ return 42
|
|||||||
select chistics()|
|
select chistics()|
|
||||||
chistics()
|
chistics()
|
||||||
42
|
42
|
||||||
alter function chistics name chistics2
|
alter function chistics
|
||||||
no sql
|
no sql
|
||||||
comment 'Characteristics function test'|
|
comment 'Characteristics function test'|
|
||||||
show create function chistics2|
|
show create function chistics|
|
||||||
Function sql_mode Create Function
|
Function sql_mode Create Function
|
||||||
chistics2 CREATE FUNCTION `test`.`chistics2`() RETURNS int
|
chistics CREATE FUNCTION `test`.`chistics`() RETURNS int
|
||||||
NO SQL
|
NO SQL
|
||||||
DETERMINISTIC
|
DETERMINISTIC
|
||||||
SQL SECURITY INVOKER
|
SQL SECURITY INVOKER
|
||||||
COMMENT 'Characteristics function test'
|
COMMENT 'Characteristics function test'
|
||||||
return 42
|
return 42
|
||||||
drop function chistics2|
|
drop function chistics|
|
||||||
insert into t1 values ("foo", 1), ("bar", 2), ("zip", 3)|
|
insert into t1 values ("foo", 1), ("bar", 2), ("zip", 3)|
|
||||||
set @@sql_mode = 'ANSI'|
|
set @@sql_mode = 'ANSI'|
|
||||||
create procedure modes(out c1 int, out c2 int)
|
create procedure modes(out c1 int, out c2 int)
|
||||||
@ -2136,8 +2136,8 @@ insert into test.t1 values (x, y)|
|
|||||||
show procedure status like 'bar'|
|
show procedure status like 'bar'|
|
||||||
Db Name Type Definer Modified Created Security_type Comment
|
Db Name Type Definer Modified Created Security_type Comment
|
||||||
test bar PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 INVOKER 111111111111
|
test bar PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 INVOKER 111111111111
|
||||||
alter procedure bar name bar2 comment "2222222222" sql security definer|
|
alter procedure bar comment "2222222222" sql security definer|
|
||||||
alter procedure bar2 name bar comment "3333333333"|
|
alter procedure bar comment "3333333333"|
|
||||||
alter procedure bar|
|
alter procedure bar|
|
||||||
show create procedure bar|
|
show create procedure bar|
|
||||||
Procedure sql_mode Create Procedure
|
Procedure sql_mode Create Procedure
|
||||||
|
@ -307,9 +307,6 @@ drop procedure p|
|
|||||||
|
|
||||||
--error 1305
|
--error 1305
|
||||||
alter procedure bar3 sql security invoker|
|
alter procedure bar3 sql security invoker|
|
||||||
--error 1059
|
|
||||||
alter procedure bar3 name
|
|
||||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA|
|
|
||||||
|
|
||||||
drop table t1|
|
drop table t1|
|
||||||
|
|
||||||
|
@ -990,9 +990,9 @@ show create procedure chistics|
|
|||||||
call chistics()|
|
call chistics()|
|
||||||
select * from t1|
|
select * from t1|
|
||||||
delete from t1|
|
delete from t1|
|
||||||
alter procedure chistics sql security invoker name chistics2|
|
alter procedure chistics sql security invoker|
|
||||||
show create procedure chistics2|
|
show create procedure chistics|
|
||||||
drop procedure chistics2|
|
drop procedure chistics|
|
||||||
|
|
||||||
create function chistics() returns int
|
create function chistics() returns int
|
||||||
language sql
|
language sql
|
||||||
@ -1004,11 +1004,11 @@ create function chistics() returns int
|
|||||||
show create function chistics|
|
show create function chistics|
|
||||||
# Call it, just to make sure.
|
# Call it, just to make sure.
|
||||||
select chistics()|
|
select chistics()|
|
||||||
alter function chistics name chistics2
|
alter function chistics
|
||||||
no sql
|
no sql
|
||||||
comment 'Characteristics function test'|
|
comment 'Characteristics function test'|
|
||||||
show create function chistics2|
|
show create function chistics|
|
||||||
drop function chistics2|
|
drop function chistics|
|
||||||
|
|
||||||
|
|
||||||
# Check mode settings
|
# Check mode settings
|
||||||
@ -2268,8 +2268,8 @@ create procedure bar(x char(16), y int)
|
|||||||
insert into test.t1 values (x, y)|
|
insert into test.t1 values (x, y)|
|
||||||
--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
|
--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
|
||||||
show procedure status like 'bar'|
|
show procedure status like 'bar'|
|
||||||
alter procedure bar name bar2 comment "2222222222" sql security definer|
|
alter procedure bar comment "2222222222" sql security definer|
|
||||||
alter procedure bar2 name bar comment "3333333333"|
|
alter procedure bar comment "3333333333"|
|
||||||
alter procedure bar|
|
alter procedure bar|
|
||||||
show create procedure bar|
|
show create procedure bar|
|
||||||
--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
|
--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
|
||||||
|
22
sql/sp.cc
22
sql/sp.cc
@ -442,9 +442,7 @@ db_drop_routine(THD *thd, int type, sp_name *name)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
db_update_routine(THD *thd, int type, sp_name *name,
|
db_update_routine(THD *thd, int type, sp_name *name, st_sp_chistics *chistics)
|
||||||
char *newname, uint newnamelen,
|
|
||||||
st_sp_chistics *chistics)
|
|
||||||
{
|
{
|
||||||
TABLE *table;
|
TABLE *table;
|
||||||
int ret;
|
int ret;
|
||||||
@ -462,10 +460,6 @@ db_update_routine(THD *thd, int type, sp_name *name,
|
|||||||
if (chistics->suid != SP_IS_DEFAULT_SUID)
|
if (chistics->suid != SP_IS_DEFAULT_SUID)
|
||||||
table->field[MYSQL_PROC_FIELD_SECURITY_TYPE]->
|
table->field[MYSQL_PROC_FIELD_SECURITY_TYPE]->
|
||||||
store((longlong)chistics->suid);
|
store((longlong)chistics->suid);
|
||||||
if (newname)
|
|
||||||
table->field[MYSQL_PROC_FIELD_NAME]->store(newname,
|
|
||||||
newnamelen,
|
|
||||||
system_charset_info);
|
|
||||||
if (chistics->daccess != SP_DEFAULT_ACCESS)
|
if (chistics->daccess != SP_DEFAULT_ACCESS)
|
||||||
table->field[MYSQL_PROC_FIELD_ACCESS]->
|
table->field[MYSQL_PROC_FIELD_ACCESS]->
|
||||||
store((longlong)chistics->daccess);
|
store((longlong)chistics->daccess);
|
||||||
@ -772,9 +766,7 @@ sp_drop_procedure(THD *thd, sp_name *name)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
sp_update_procedure(THD *thd, sp_name *name,
|
sp_update_procedure(THD *thd, sp_name *name, st_sp_chistics *chistics)
|
||||||
char *newname, uint newnamelen,
|
|
||||||
st_sp_chistics *chistics)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
bool found;
|
bool found;
|
||||||
@ -782,8 +774,7 @@ sp_update_procedure(THD *thd, sp_name *name,
|
|||||||
DBUG_PRINT("enter", ("name: %*s", name->m_name.length, name->m_name.str));
|
DBUG_PRINT("enter", ("name: %*s", name->m_name.length, name->m_name.str));
|
||||||
|
|
||||||
found= sp_cache_remove(&thd->sp_proc_cache, name);
|
found= sp_cache_remove(&thd->sp_proc_cache, name);
|
||||||
ret= db_update_routine(thd, TYPE_ENUM_PROCEDURE, name,
|
ret= db_update_routine(thd, TYPE_ENUM_PROCEDURE, name, chistics);
|
||||||
newname, newnamelen, chistics);
|
|
||||||
if (!found && !ret)
|
if (!found && !ret)
|
||||||
sp_cache_invalidate();
|
sp_cache_invalidate();
|
||||||
DBUG_RETURN(ret);
|
DBUG_RETURN(ret);
|
||||||
@ -870,9 +861,7 @@ sp_drop_function(THD *thd, sp_name *name)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
sp_update_function(THD *thd, sp_name *name,
|
sp_update_function(THD *thd, sp_name *name, st_sp_chistics *chistics)
|
||||||
char *newname, uint newnamelen,
|
|
||||||
st_sp_chistics *chistics)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
bool found;
|
bool found;
|
||||||
@ -880,8 +869,7 @@ sp_update_function(THD *thd, sp_name *name,
|
|||||||
DBUG_PRINT("enter", ("name: %*s", name->m_name.length, name->m_name.str));
|
DBUG_PRINT("enter", ("name: %*s", name->m_name.length, name->m_name.str));
|
||||||
|
|
||||||
found= sp_cache_remove(&thd->sp_func_cache, name);
|
found= sp_cache_remove(&thd->sp_func_cache, name);
|
||||||
ret= db_update_routine(thd, TYPE_ENUM_FUNCTION, name,
|
ret= db_update_routine(thd, TYPE_ENUM_FUNCTION, name, chistics);
|
||||||
newname, newnamelen, chistics);
|
|
||||||
if (!found && !ret)
|
if (!found && !ret)
|
||||||
sp_cache_invalidate();
|
sp_cache_invalidate();
|
||||||
DBUG_RETURN(ret);
|
DBUG_RETURN(ret);
|
||||||
|
8
sql/sp.h
8
sql/sp.h
@ -44,9 +44,7 @@ sp_drop_procedure(THD *thd, sp_name *name);
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
sp_update_procedure(THD *thd, sp_name *name,
|
sp_update_procedure(THD *thd, sp_name *name, st_sp_chistics *chistics);
|
||||||
char *newname, uint newnamelen,
|
|
||||||
st_sp_chistics *chistics);
|
|
||||||
|
|
||||||
int
|
int
|
||||||
sp_show_create_procedure(THD *thd, sp_name *name);
|
sp_show_create_procedure(THD *thd, sp_name *name);
|
||||||
@ -64,9 +62,7 @@ int
|
|||||||
sp_drop_function(THD *thd, sp_name *name);
|
sp_drop_function(THD *thd, sp_name *name);
|
||||||
|
|
||||||
int
|
int
|
||||||
sp_update_function(THD *thd, sp_name *name,
|
sp_update_function(THD *thd, sp_name *name, st_sp_chistics *chistics);
|
||||||
char *newname, uint newnamelen,
|
|
||||||
st_sp_chistics *chistics);
|
|
||||||
|
|
||||||
int
|
int
|
||||||
sp_show_create_function(THD *thd, sp_name *name);
|
sp_show_create_function(THD *thd, sp_name *name);
|
||||||
|
@ -3766,20 +3766,10 @@ purposes internal to the MySQL server", MYF(0));
|
|||||||
case SQLCOM_ALTER_FUNCTION:
|
case SQLCOM_ALTER_FUNCTION:
|
||||||
{
|
{
|
||||||
res= -1;
|
res= -1;
|
||||||
uint newname_len= 0;
|
|
||||||
if (lex->name)
|
|
||||||
newname_len= strlen(lex->name);
|
|
||||||
if (newname_len > NAME_LEN)
|
|
||||||
{
|
|
||||||
net_printf(thd, ER_TOO_LONG_IDENT, lex->name);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
if (lex->sql_command == SQLCOM_ALTER_PROCEDURE)
|
if (lex->sql_command == SQLCOM_ALTER_PROCEDURE)
|
||||||
res= sp_update_procedure(thd, lex->spname,
|
res= sp_update_procedure(thd, lex->spname, &lex->sp_chistics);
|
||||||
lex->name, newname_len, &lex->sp_chistics);
|
|
||||||
else
|
else
|
||||||
res= sp_update_function(thd, lex->spname,
|
res= sp_update_function(thd, lex->spname, &lex->sp_chistics);
|
||||||
lex->name, newname_len, &lex->sp_chistics);
|
|
||||||
switch (res)
|
switch (res)
|
||||||
{
|
{
|
||||||
case SP_OK:
|
case SP_OK:
|
||||||
|
@ -789,7 +789,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
|
|||||||
opt_extended_describe
|
opt_extended_describe
|
||||||
prepare prepare_src execute deallocate
|
prepare prepare_src execute deallocate
|
||||||
statement sp_suid opt_view_list view_list or_replace algorithm
|
statement sp_suid opt_view_list view_list or_replace algorithm
|
||||||
sp_c_chistics sp_a_chistics sp_chistic sp_c_chistic sp_a_chistic
|
sp_c_chistics sp_a_chistics sp_chistic sp_c_chistic
|
||||||
END_OF_INPUT
|
END_OF_INPUT
|
||||||
|
|
||||||
%type <NONE> call sp_proc_stmts sp_proc_stmt
|
%type <NONE> call sp_proc_stmts sp_proc_stmt
|
||||||
@ -1371,7 +1371,7 @@ create_function_tail:
|
|||||||
|
|
||||||
sp_a_chistics:
|
sp_a_chistics:
|
||||||
/* Empty */ {}
|
/* Empty */ {}
|
||||||
| sp_a_chistics sp_a_chistic {}
|
| sp_a_chistics sp_chistic {}
|
||||||
;
|
;
|
||||||
|
|
||||||
sp_c_chistics:
|
sp_c_chistics:
|
||||||
@ -1397,12 +1397,6 @@ sp_chistic:
|
|||||||
{ }
|
{ }
|
||||||
;
|
;
|
||||||
|
|
||||||
/* Alter characteristics */
|
|
||||||
sp_a_chistic:
|
|
||||||
sp_chistic { }
|
|
||||||
| NAME_SYM ident { Lex->name= $2.str; }
|
|
||||||
;
|
|
||||||
|
|
||||||
/* Create characteristics */
|
/* Create characteristics */
|
||||||
sp_c_chistic:
|
sp_c_chistic:
|
||||||
sp_chistic { }
|
sp_chistic { }
|
||||||
@ -3195,7 +3189,6 @@ alter:
|
|||||||
LEX *lex= Lex;
|
LEX *lex= Lex;
|
||||||
|
|
||||||
bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics));
|
bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics));
|
||||||
lex->name= 0;
|
|
||||||
}
|
}
|
||||||
sp_a_chistics
|
sp_a_chistics
|
||||||
{
|
{
|
||||||
@ -3210,7 +3203,6 @@ alter:
|
|||||||
LEX *lex= Lex;
|
LEX *lex= Lex;
|
||||||
|
|
||||||
bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics));
|
bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics));
|
||||||
lex->name= 0;
|
|
||||||
}
|
}
|
||||||
sp_a_chistics
|
sp_a_chistics
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user