summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <thek@kpdesk.mysql.com>2006-11-29 12:57:43 +0100
committerunknown <thek@kpdesk.mysql.com>2006-11-29 12:57:43 +0100
commit8ac71ce7ea4a5ed6eac776c0d3e2e7b20716e4d7 (patch)
tree9d17af7abaa0b93d6a4c505ee0a9490d6aab2900 /sql
parent89d106c1a4efad141e7850373335482ad46aeec5 (diff)
parent9a87702b033bc9bab337e716a52532c4e4599057 (diff)
downloadmariadb-git-8ac71ce7ea4a5ed6eac776c0d3e2e7b20716e4d7.tar.gz
Merge kpdesk.mysql.com:/home/thek/dev/bug22043/my50-bug22043
into kpdesk.mysql.com:/home/thek/dev/mysql-5.0-maint sql/sql_parse.cc: Auto merged mysql-test/r/rpl_sp.result: - merged mysql-test/t/rpl_sp.test: -merged
Diffstat (limited to 'sql')
-rw-r--r--sql/sp.cc9
-rw-r--r--sql/sql_parse.cc24
2 files changed, 24 insertions, 9 deletions
diff --git a/sql/sp.cc b/sql/sp.cc
index 283f43f55b2..f7c086061d3 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -494,17 +494,10 @@ db_create_routine(THD *thd, int type, sp_head *sp)
char definer[USER_HOST_BUFF_SIZE];
char old_db_buf[NAME_LEN+1];
LEX_STRING old_db= { old_db_buf, sizeof(old_db_buf) };
- bool dbchanged;
DBUG_ENTER("db_create_routine");
DBUG_PRINT("enter", ("type: %d name: %.*s",type,sp->m_name.length,
sp->m_name.str));
- if ((ret= sp_use_new_db(thd, sp->m_db, &old_db, 0, &dbchanged)))
- {
- ret= SP_NO_DB_ERROR;
- goto done;
- }
-
if (!(table= open_proc_table_for_update(thd)))
ret= SP_OPEN_TABLE_FAILED;
else
@@ -629,8 +622,6 @@ db_create_routine(THD *thd, int type, sp_head *sp)
done:
close_thread_tables(thd);
- if (dbchanged)
- (void) mysql_change_db(thd, old_db.str, 1);
DBUG_RETURN(ret);
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 02bb595b3dc..4d1d36a5dd7 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -4249,6 +4249,30 @@ end_with_restore_list:
DBUG_ASSERT(lex->sphead != 0);
DBUG_ASSERT(lex->sphead->m_db.str); /* Must be initialized in the parser */
+ /*
+ Verify that the database name is allowed, optionally
+ lowercase it.
+ */
+ if (check_db_name(lex->sphead->m_db.str))
+ {
+ my_error(ER_WRONG_DB_NAME, MYF(0), lex->sphead->m_db.str);
+ delete lex->sphead;
+ lex->sphead= 0;
+ goto error;
+ }
+
+ /*
+ Check that a database with this name
+ exists.
+ */
+ if (check_db_dir_existence(lex->sphead->m_db.str))
+ {
+ my_error(ER_BAD_DB_ERROR, MYF(0), lex->sphead->m_db.str);
+ delete lex->sphead;
+ lex->sphead= 0;
+ goto error;
+ }
+
if (check_access(thd, CREATE_PROC_ACL, lex->sphead->m_db.str, 0, 0, 0,
is_schema_db(lex->sphead->m_db.str)))
{