mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Fixed BUG#9529: Stored Procedures: No Warning on truncation of procedure name
during creation. Although it returns an error, consistent with the behaviour for other objects. (Unclear why we would allow the creation of SPs with truncated names.) mysql-test/r/sp-error.result: New test case for BUG#9529. mysql-test/t/sp-error.test: New test case for BUG#9529. sql/sp.cc: Check SP name length on creation (and drop). sql/sp.h: New status code for bad (too long) name. sql/sql_parse.cc: New status code for bad (too long) name.
This commit is contained in:
@ -654,4 +654,8 @@ flush tables;
|
|||||||
return 5;
|
return 5;
|
||||||
end|
|
end|
|
||||||
ERROR 0A000: FLUSH is not allowed in stored procedures
|
ERROR 0A000: FLUSH is not allowed in stored procedures
|
||||||
|
create procedure bug9529_90123456789012345678901234567890123456789012345678901234567890()
|
||||||
|
begin
|
||||||
|
end|
|
||||||
|
ERROR 42000: Identifier name 'bug9529_90123456789012345678901234567890123456789012345678901234567890' is too long
|
||||||
drop table t1|
|
drop table t1|
|
||||||
|
@ -920,6 +920,16 @@ begin
|
|||||||
end|
|
end|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# BUG#9529: Stored Procedures: No Warning on truncation of procedure name
|
||||||
|
# during creation.
|
||||||
|
#
|
||||||
|
--error ER_TOO_LONG_IDENT
|
||||||
|
create procedure bug9529_90123456789012345678901234567890123456789012345678901234567890()
|
||||||
|
begin
|
||||||
|
end|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# BUG#NNNN: New bug synopsis
|
# BUG#NNNN: New bug synopsis
|
||||||
#
|
#
|
||||||
|
@ -120,6 +120,10 @@ db_find_routine_aux(THD *thd, int type, sp_name *name,
|
|||||||
'db', 'name' and 'type' and the first key is the primary key over the
|
'db', 'name' and 'type' and the first key is the primary key over the
|
||||||
same fields.
|
same fields.
|
||||||
*/
|
*/
|
||||||
|
if (name->m_name.length > table->field[1]->field_length)
|
||||||
|
{
|
||||||
|
DBUG_RETURN(SP_KEY_NOT_FOUND);
|
||||||
|
}
|
||||||
table->field[0]->store(name->m_db.str, name->m_db.length, &my_charset_bin);
|
table->field[0]->store(name->m_db.str, name->m_db.length, &my_charset_bin);
|
||||||
table->field[1]->store(name->m_name.str, name->m_name.length,
|
table->field[1]->store(name->m_name.str, name->m_name.length,
|
||||||
&my_charset_bin);
|
&my_charset_bin);
|
||||||
@ -389,6 +393,11 @@ db_create_routine(THD *thd, int type, sp_head *sp)
|
|||||||
ret= SP_GET_FIELD_FAILED;
|
ret= SP_GET_FIELD_FAILED;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
if (sp->m_name.length > table->field[MYSQL_PROC_FIELD_NAME]->field_length)
|
||||||
|
{
|
||||||
|
ret= SP_BAD_IDENTIFIER;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
table->field[MYSQL_PROC_FIELD_DB]->
|
table->field[MYSQL_PROC_FIELD_DB]->
|
||||||
store(sp->m_db.str, sp->m_db.length, system_charset_info);
|
store(sp->m_db.str, sp->m_db.length, system_charset_info);
|
||||||
table->field[MYSQL_PROC_FIELD_NAME]->
|
table->field[MYSQL_PROC_FIELD_NAME]->
|
||||||
|
1
sql/sp.h
1
sql/sp.h
@ -28,6 +28,7 @@
|
|||||||
#define SP_PARSE_ERROR -6
|
#define SP_PARSE_ERROR -6
|
||||||
#define SP_INTERNAL_ERROR -7
|
#define SP_INTERNAL_ERROR -7
|
||||||
#define SP_NO_DB_ERROR -8
|
#define SP_NO_DB_ERROR -8
|
||||||
|
#define SP_BAD_IDENTIFIER -9
|
||||||
|
|
||||||
/* Drop all routines in database 'db' */
|
/* Drop all routines in database 'db' */
|
||||||
int
|
int
|
||||||
|
@ -4019,6 +4019,12 @@ unsent_create_error:
|
|||||||
delete lex->sphead;
|
delete lex->sphead;
|
||||||
lex->sphead= 0;
|
lex->sphead= 0;
|
||||||
goto error;
|
goto error;
|
||||||
|
case SP_BAD_IDENTIFIER:
|
||||||
|
my_error(ER_TOO_LONG_IDENT, MYF(0), name);
|
||||||
|
lex->unit.cleanup();
|
||||||
|
delete lex->sphead;
|
||||||
|
lex->sphead= 0;
|
||||||
|
goto error;
|
||||||
default:
|
default:
|
||||||
my_error(ER_SP_STORE_FAILED, MYF(0), SP_TYPE_STRING(lex), name);
|
my_error(ER_SP_STORE_FAILED, MYF(0), SP_TYPE_STRING(lex), name);
|
||||||
lex->unit.cleanup();
|
lex->unit.cleanup();
|
||||||
|
Reference in New Issue
Block a user