summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/field_conv.cc24
-rw-r--r--sql/handler.cc4
-rw-r--r--sql/sp.cc9
-rw-r--r--sql/sql_parse.cc24
4 files changed, 52 insertions, 9 deletions
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index 01b5306f5a4..5fde5ecb2e8 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -308,6 +308,21 @@ static void do_field_string(Copy_field *copy)
}
+static void do_field_varbinary_pre50(Copy_field *copy)
+{
+ char buff[MAX_FIELD_WIDTH];
+ copy->tmp.set_quick(buff,sizeof(buff),copy->tmp.charset());
+ copy->from_field->val_str(&copy->tmp);
+
+ /* Use the same function as in 4.1 to trim trailing spaces */
+ uint length= my_lengthsp_8bit(&my_charset_bin, copy->tmp.c_ptr_quick(),
+ copy->from_field->field_length);
+
+ copy->to_field->store(copy->tmp.c_ptr_quick(), length,
+ copy->tmp.charset());
+}
+
+
static void do_field_int(Copy_field *copy)
{
longlong value= copy->from_field->val_int();
@@ -570,6 +585,15 @@ void (*Copy_field::get_copy_func(Field *to,Field *from))(Copy_field*)
if (from->result_type() == STRING_RESULT)
{
/*
+ Detect copy from pre 5.0 varbinary to varbinary as of 5.0 and
+ use special copy function that removes trailing spaces and thus
+ repairs data.
+ */
+ if (from->type() == MYSQL_TYPE_VAR_STRING && !from->has_charset() &&
+ to->type() == MYSQL_TYPE_VARCHAR && !to->has_charset())
+ return do_field_varbinary_pre50;
+
+ /*
If we are copying date or datetime's we have to check the dates
if we don't allow 'all' dates.
*/
diff --git a/sql/handler.cc b/sql/handler.cc
index 85345c70e36..729333903f6 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -2304,6 +2304,10 @@ int handler::check_old_types()
{
return HA_ADMIN_NEEDS_ALTER;
}
+ if ((*field)->type() == MYSQL_TYPE_VAR_STRING)
+ {
+ return HA_ADMIN_NEEDS_ALTER;
+ }
}
}
return 0;
diff --git a/sql/sp.cc b/sql/sp.cc
index 45a177d3e7a..9e53aff742e 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -497,17 +497,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
@@ -631,8 +624,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 c188329b70a..ce59e334ab2 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -4431,6 +4431,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)))
{