summaryrefslogtreecommitdiff
path: root/sql/sql_view.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_view.cc')
-rw-r--r--sql/sql_view.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 0701c5233ac..d4170a30556 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -877,6 +877,8 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
enum_view_create_mode mode)
{
LEX *lex= thd->lex;
+ bool has_charset_filename= false;
+ CHARSET_INFO *csname_client, *collation_connection_name, *saved_charset;
/*
View definition query -- a SELECT statement that fully defines view. It
@@ -903,6 +905,15 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
View definition query is stored in the client character set.
*/
+ if (!strcasecmp(thd->charset()->csname,"filename"))
+ {
+ has_charset_filename= true;
+ saved_charset= thd->charset();
+ csname_client = get_charset_by_csname("utf8", MY_CS_PRIMARY, MYF(MY_WME));
+ collation_connection_name = get_charset_by_name("utf8_general_ci", MYF(0));
+ thd->update_charset(csname_client, collation_connection_name);
+ }
+
StringBuffer<4096> view_query(thd->charset());
StringBuffer<4096> is_query(system_charset_info);
@@ -1121,12 +1132,16 @@ loop_out:
error= thd->is_error() ? -1 : 1;
goto err;
}
+ if (has_charset_filename)
+ thd->update_charset(saved_charset,saved_charset);
DBUG_RETURN(0);
err:
view->select_stmt.str= NULL;
view->select_stmt.length= 0;
view->md5.str= NULL;
view->md5.length= 0;
+ if (has_charset_filename)
+ thd->update_charset(saved_charset,saved_charset);
DBUG_RETURN(error);
}