summaryrefslogtreecommitdiff
path: root/sql/sql_view.cc
diff options
context:
space:
mode:
authorRucha Deodhar <rucha.deodhar@mariadb.com>2021-04-30 23:14:57 +0530
committerRucha Deodhar <rucha.deodhar@mariadb.com>2021-04-30 23:36:02 +0530
commitfc0602c244f77bc10cd9517359095812ad311126 (patch)
tree46c26d5f3bbe134cd346f3c95a629b0a1387f3d7 /sql/sql_view.cc
parentfb96ac0a496f0665b3feca3cf85aeeedf4bd1e23 (diff)
downloadmariadb-git-bb-10.2-MDEV-25462.tar.gz
MDEV-25462: Assertion `m_status == DA_ERROR || m_status == DA_OK ||bb-10.2-MDEV-25462
m_status == DA_OK_BULK' failed in Diagnostics_area::message from get_schema_tables_record Analysis: SET NAMES changes character set for character_set_client, character_set_connection, character_set_results to 'filename'. The .frm file of view has @xx sequences in the SELECT query, which give parsing error because 'filename' character set is not parser friendly. When we get parsing error (ER_PARSE_ERROR), we directly return true without setting error status. This is caught later in assertion. Fix: If we have 'filename' chracterset for client then while making .frm file, change it to utf8. After .frm file is formed, change the client character set to 'filename' again.
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);
}