diff options
author | unknown <pem@mysql.comhem.se> | 2004-06-15 15:42:28 +0200 |
---|---|---|
committer | unknown <pem@mysql.comhem.se> | 2004-06-15 15:42:28 +0200 |
commit | 44d2934f0bf11d86ab7491142a4e5ca9d16f3259 (patch) | |
tree | ca16586fc071c4e4017d3e2098ebdb4e56eefc5d /sql/sp.cc | |
parent | 05f9e4dd0ec743b352eb480ec8eab3af046b745d (diff) | |
download | mariadb-git-44d2934f0bf11d86ab7491142a4e5ca9d16f3259.tar.gz |
Fixed BUG#3339: Stored procedures in nonexistent schemas are uncallable.
Also added some related security tests and corrected related error messages.
mysql-test/r/sp-error.result:
New test case for BUG#3339, and updated results for other modified error messages.
mysql-test/r/sp-security.result:
Added tests for creating procedures in another database with and wihout
access rights.
mysql-test/t/sp-error.test:
New test case for BUG#3339.
mysql-test/t/sp-security.test:
Added tests for creating procedures in another database with and wihout
access rights.
sql/sp.cc:
Check existance (and access rights) for database when creating a stored routine.
sql/sp.h:
New error return value for sp_create_* functions, for non existing database.
sql/sql_parse.cc:
Check error return for create stored routine (non existing database),
and corrected the error output for some other commands. (Use qualified
name, not just name.)
Diffstat (limited to 'sql/sp.cc')
-rw-r--r-- | sql/sp.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/sql/sp.cc b/sql/sp.cc index b77f60a32ad..d70da1b1421 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -314,9 +314,19 @@ db_create_routine(THD *thd, int type, sp_head *sp) TABLE *table; TABLE_LIST tables; char definer[HOSTNAME_LENGTH+USERNAME_LENGTH+2]; + char olddb[128]; + bool dbchanged; DBUG_ENTER("db_create_routine"); DBUG_PRINT("enter", ("type: %d name: %*s",type,sp->m_name.length,sp->m_name.str)); + dbchanged= FALSE; + if ((ret= sp_use_new_db(thd, sp->m_db.str, olddb, sizeof(olddb), + 0, &dbchanged))) + { + ret= SP_NO_DB_ERROR; + goto done; + } + memset(&tables, 0, sizeof(tables)); tables.db= (char*)"mysql"; tables.real_name= tables.alias= (char*)"proc"; @@ -370,6 +380,8 @@ db_create_routine(THD *thd, int type, sp_head *sp) done: close_thread_tables(thd); + if (dbchanged) + (void)sp_change_db(thd, olddb, 1); DBUG_RETURN(ret); } |