summaryrefslogtreecommitdiff
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
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.
-rw-r--r--mysql-test/r/ctype_filename.result28
-rw-r--r--mysql-test/t/ctype_filename.test25
-rw-r--r--sql/sql_view.cc15
3 files changed, 68 insertions, 0 deletions
diff --git a/mysql-test/r/ctype_filename.result b/mysql-test/r/ctype_filename.result
index c6d7d1e39b9..b547b7e5588 100644
--- a/mysql-test/r/ctype_filename.result
+++ b/mysql-test/r/ctype_filename.result
@@ -21,3 +21,31 @@ SET NAMES utf8;
SELECT @a:=CONVERT('aя' USING filename) AS `@a`, BINARY @a, REVERSE(@a), HEX(@a), HEX(REVERSE(@a));
@a BINARY @a REVERSE(@a) HEX(@a) HEX(REVERSE(@a))
aя a@r1 яa 61407231 40723161
+#
+# Beginning of 10.2 test.
+#
+# MDEV-25462: Assertion `m_status == DA_ERROR || m_status == DA_OK ||
+# m_status == DA_OK_BULK' failed in Diagnostics_area::message from
+# get_schema_tables_record
+#
+SELECT @@character_set_client, @@character_set_connection, @@character_set_results;
+@@character_set_client @@character_set_connection @@character_set_results
+utf8 utf8 utf8
+SET @old_character_set_client= @@character_set_client;
+SET @old_character_set_connection= @@character_set_connection;
+SET @old_character_set_results= @@character_set_results;
+SET NAMES 'filename';
+SELECT @@character_set_client, @@character_set_connection, @@character_set_results;
+@@character_set_client @@character_set_connection @@character_set_results
+filename filename filename
+CREATE VIEW v2 AS SELECT 1;
+SHOW TABLE STATUS;
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
+v2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL VIEW
+DROP VIEW v2;
+SET @@character_set_client= @old_character_set_client;
+SET @@character_set_connection= @old_character_set_connection;
+SET @@character_set_results= @old_character_set_results;
+#
+# End of 10.2 test
+#
diff --git a/mysql-test/t/ctype_filename.test b/mysql-test/t/ctype_filename.test
index 7ec07293a2b..d75ece29808 100644
--- a/mysql-test/t/ctype_filename.test
+++ b/mysql-test/t/ctype_filename.test
@@ -27,3 +27,28 @@ select convert(convert(',' using filename) using binary);
--echo #
SET NAMES utf8;
SELECT @a:=CONVERT('aя' USING filename) AS `@a`, BINARY @a, REVERSE(@a), HEX(@a), HEX(REVERSE(@a));
+
+--echo #
+--echo # Beginning of 10.2 test.
+--echo #
+--echo # MDEV-25462: Assertion `m_status == DA_ERROR || m_status == DA_OK ||
+--echo # m_status == DA_OK_BULK' failed in Diagnostics_area::message from
+--echo # get_schema_tables_record
+--echo #
+
+SELECT @@character_set_client, @@character_set_connection, @@character_set_results;
+SET @old_character_set_client= @@character_set_client;
+SET @old_character_set_connection= @@character_set_connection;
+SET @old_character_set_results= @@character_set_results;
+SET NAMES 'filename';
+SELECT @@character_set_client, @@character_set_connection, @@character_set_results;
+CREATE VIEW v2 AS SELECT 1;
+SHOW TABLE STATUS;
+DROP VIEW v2;
+SET @@character_set_client= @old_character_set_client;
+SET @@character_set_connection= @old_character_set_connection;
+SET @@character_set_results= @old_character_set_results;
+
+--echo #
+--echo # End of 10.2 test
+--echo #
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);
}