Commit 32dedbe6 authored by andrey@example.com's avatar andrey@example.com

Merge ahristov@bk-internal.mysql.com:/home/bk/mysql-5.1-maint

into  example.com:/work/bug24395-v2/my51
parents 8fcf1421 f74e1d26
...@@ -1077,7 +1077,7 @@ CREATE PROCEDURE p1 () ...@@ -1077,7 +1077,7 @@ CREATE PROCEDURE p1 ()
BEGIN BEGIN
SELECT 'foo' FROM DUAL; SELECT 'foo' FROM DUAL;
END | END |
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' ERROR 42000: Unknown database 'information_schema'
select ROUTINE_NAME from routines; select ROUTINE_NAME from routines;
ROUTINE_NAME ROUTINE_NAME
grant all on information_schema.* to 'user1'@'localhost'; grant all on information_schema.* to 'user1'@'localhost';
......
...@@ -468,6 +468,7 @@ drop table t1; ...@@ -468,6 +468,7 @@ drop table t1;
set global log_bin_trust_function_creators=0; set global log_bin_trust_function_creators=0;
set global log_bin_trust_function_creators=0; set global log_bin_trust_function_creators=0;
End of 5.0 tests End of 5.0 tests
reset master;
drop database if exists mysqltest; drop database if exists mysqltest;
drop database if exists mysqltest2; drop database if exists mysqltest2;
create database mysqltest; create database mysqltest;
...@@ -476,14 +477,15 @@ use mysqltest2; ...@@ -476,14 +477,15 @@ use mysqltest2;
create table t ( t integer ); create table t ( t integer );
create procedure mysqltest.test() begin end; create procedure mysqltest.test() begin end;
insert into t values ( 1 ); insert into t values ( 1 );
show binlog events in 'master-bin.000001' from 8657; show binlog events in 'master-bin.000001' from 102;
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 8657 Query 1 8760 drop database if exists mysqltest2 master-bin.000001 102 Query 1 203 drop database if exists mysqltest
master-bin.000001 8760 Query 1 8853 create database mysqltest master-bin.000001 203 Query 1 306 drop database if exists mysqltest2
master-bin.000001 8853 Query 1 8948 create database mysqltest2 master-bin.000001 306 Query 1 399 create database mysqltest
master-bin.000001 8948 Query 1 9045 use `mysqltest2`; create table t ( t integer ) master-bin.000001 399 Query 1 494 create database mysqltest2
master-bin.000001 9045 Query 1 9184 use `mysqltest2`; CREATE DEFINER=`root`@`localhost` procedure mysqltest.test() begin end master-bin.000001 494 Query 1 591 use `mysqltest2`; create table t ( t integer )
master-bin.000001 9184 Query 1 9279 use `mysqltest2`; insert into t values ( 1 ) master-bin.000001 591 Query 1 730 use `mysqltest2`; CREATE DEFINER=`root`@`localhost` procedure mysqltest.test() begin end
master-bin.000001 730 Query 1 825 use `mysqltest2`; insert into t values ( 1 )
create procedure `\\`.test() begin end; create procedure `\\`.test() begin end;
ERROR 42000: Unknown database '\\' ERROR 42000: Unknown database '\\'
drop database mysqltest; drop database mysqltest;
......
...@@ -721,7 +721,7 @@ create temporary table schemata(f1 char(10)); ...@@ -721,7 +721,7 @@ create temporary table schemata(f1 char(10));
# Bug #10708 SP's can use INFORMATION_SCHEMA as ROUTINE_SCHEMA # Bug #10708 SP's can use INFORMATION_SCHEMA as ROUTINE_SCHEMA
# #
delimiter |; delimiter |;
--error 1044 --error ER_BAD_DB_ERROR
CREATE PROCEDURE p1 () CREATE PROCEDURE p1 ()
BEGIN BEGIN
SELECT 'foo' FROM DUAL; SELECT 'foo' FROM DUAL;
......
...@@ -532,6 +532,7 @@ set global log_bin_trust_function_creators=0; ...@@ -532,6 +532,7 @@ set global log_bin_trust_function_creators=0;
# Bug22043: MySQL don't add "USE <DATABASE>" before "DROP PROCEDURE IF EXISTS" # Bug22043: MySQL don't add "USE <DATABASE>" before "DROP PROCEDURE IF EXISTS"
# #
connection master; connection master;
reset master;
--disable_warnings --disable_warnings
drop database if exists mysqltest; drop database if exists mysqltest;
drop database if exists mysqltest2; drop database if exists mysqltest2;
...@@ -542,7 +543,7 @@ use mysqltest2; ...@@ -542,7 +543,7 @@ use mysqltest2;
create table t ( t integer ); create table t ( t integer );
create procedure mysqltest.test() begin end; create procedure mysqltest.test() begin end;
insert into t values ( 1 ); insert into t values ( 1 );
show binlog events in 'master-bin.000001' from 8657; show binlog events in 'master-bin.000001' from 102;
--error ER_BAD_DB_ERROR --error ER_BAD_DB_ERROR
create procedure `\\`.test() begin end; create procedure `\\`.test() begin end;
# Clean up # Clean up
......
...@@ -4426,11 +4426,10 @@ end_with_restore_list: ...@@ -4426,11 +4426,10 @@ end_with_restore_list:
{ {
uint namelen; uint namelen;
char *name; char *name;
int result; int result= SP_INTERNAL_ERROR;
DBUG_ASSERT(lex->sphead != 0); DBUG_ASSERT(lex->sphead != 0);
DBUG_ASSERT(lex->sphead->m_db.str); /* Must be initialized in the parser */ DBUG_ASSERT(lex->sphead->m_db.str); /* Must be initialized in the parser */
/* /*
Verify that the database name is allowed, optionally Verify that the database name is allowed, optionally
lowercase it. lowercase it.
...@@ -4438,37 +4437,26 @@ end_with_restore_list: ...@@ -4438,37 +4437,26 @@ end_with_restore_list:
if (check_db_name(&lex->sphead->m_db)) if (check_db_name(&lex->sphead->m_db))
{ {
my_error(ER_WRONG_DB_NAME, MYF(0), lex->sphead->m_db.str); my_error(ER_WRONG_DB_NAME, MYF(0), lex->sphead->m_db.str);
delete lex->sphead; goto create_sp_error;
lex->sphead= 0;
goto error;
} }
/* /*
Check that a database with this name Check that a database directory with this name
exists. exists. Design note: This won't work on virtual databases
like information_schema.
*/ */
if (check_db_dir_existence(lex->sphead->m_db.str)) if (check_db_dir_existence(lex->sphead->m_db.str))
{ {
my_error(ER_BAD_DB_ERROR, MYF(0), lex->sphead->m_db.str); my_error(ER_BAD_DB_ERROR, MYF(0), lex->sphead->m_db.str);
delete lex->sphead; goto create_sp_error;
lex->sphead= 0;
goto error;
} }
if (check_access(thd, CREATE_PROC_ACL, lex->sphead->m_db.str, 0, 0, 0, if (check_access(thd, CREATE_PROC_ACL, lex->sphead->m_db.str, 0, 0, 0,
is_schema_db(lex->sphead->m_db.str))) is_schema_db(lex->sphead->m_db.str)))
{ goto create_sp_error;
delete lex->sphead;
lex->sphead= 0;
goto error;
}
if (end_active_trans(thd)) if (end_active_trans(thd))
{ goto create_sp_error;
delete lex->sphead;
lex->sphead= 0;
goto error;
}
name= lex->sphead->name(&namelen); name= lex->sphead->name(&namelen);
#ifdef HAVE_DLOPEN #ifdef HAVE_DLOPEN
...@@ -4479,9 +4467,7 @@ end_with_restore_list: ...@@ -4479,9 +4467,7 @@ end_with_restore_list:
if (udf) if (udf)
{ {
my_error(ER_UDF_EXISTS, MYF(0), name); my_error(ER_UDF_EXISTS, MYF(0), name);
delete lex->sphead; goto create_sp_error;
lex->sphead= 0;
goto error;
} }
} }
#endif #endif
...@@ -4523,13 +4509,9 @@ end_with_restore_list: ...@@ -4523,13 +4509,9 @@ end_with_restore_list:
if (ps_arena) if (ps_arena)
thd->restore_active_arena(ps_arena, &original_arena); thd->restore_active_arena(ps_arena, &original_arena);
if (res)
{
/* Error has been already reported. */ /* Error has been already reported. */
delete lex->sphead; if (res)
lex->sphead= 0; goto create_sp_error;
goto error;
}
if (thd->slave_thread) if (thd->slave_thread)
lex->sphead->m_chistics->suid= SP_IS_NOT_SUID; lex->sphead->m_chistics->suid= SP_IS_NOT_SUID;
...@@ -4549,9 +4531,7 @@ end_with_restore_list: ...@@ -4549,9 +4531,7 @@ end_with_restore_list:
if (check_global_access(thd, SUPER_ACL)) if (check_global_access(thd, SUPER_ACL))
{ {
my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER"); my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
delete lex->sphead; goto create_sp_error;
lex->sphead= 0;
goto error;
} }
} }
...@@ -4571,8 +4551,8 @@ end_with_restore_list: ...@@ -4571,8 +4551,8 @@ end_with_restore_list:
#endif /* NO_EMBEDDED_ACCESS_CHECKS */ #endif /* NO_EMBEDDED_ACCESS_CHECKS */
res= (result= lex->sphead->create(thd)); res= (result= lex->sphead->create(thd));
if (result == SP_OK) switch (result) {
{ case SP_OK:
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
/* only add privileges if really neccessary */ /* only add privileges if really neccessary */
if (sp_automatic_privileges && !opt_noacl && if (sp_automatic_privileges && !opt_noacl &&
...@@ -4588,20 +4568,10 @@ end_with_restore_list: ...@@ -4588,20 +4568,10 @@ end_with_restore_list:
close_thread_tables(thd); close_thread_tables(thd);
} }
#endif #endif
lex->unit.cleanup(); break;
delete lex->sphead;
lex->sphead= 0;
send_ok(thd);
}
else
{
switch (result) {
case SP_WRITE_ROW_FAILED: case SP_WRITE_ROW_FAILED:
my_error(ER_SP_ALREADY_EXISTS, MYF(0), SP_TYPE_STRING(lex), name); my_error(ER_SP_ALREADY_EXISTS, MYF(0), SP_TYPE_STRING(lex), name);
break; break;
case SP_NO_DB_ERROR:
my_error(ER_BAD_DB_ERROR, MYF(0), lex->sphead->m_db.str);
break;
case SP_BAD_IDENTIFIER: case SP_BAD_IDENTIFIER:
my_error(ER_TOO_LONG_IDENT, MYF(0), name); my_error(ER_TOO_LONG_IDENT, MYF(0), name);
break; break;
...@@ -4611,14 +4581,21 @@ end_with_restore_list: ...@@ -4611,14 +4581,21 @@ end_with_restore_list:
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);
break; break;
} } /* end switch */
/*
Capture all errors within this CASE and
clean up the environment.
*/
create_sp_error:
lex->unit.cleanup(); lex->unit.cleanup();
delete lex->sphead; delete lex->sphead;
lex->sphead= 0; lex->sphead= 0;
if (result != SP_OK )
goto error; goto error;
} send_ok(thd);
break; break; /* break super switch */
} } /* end case group bracket */
case SQLCOM_CALL: case SQLCOM_CALL:
{ {
sp_head *sp; sp_head *sp;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment