summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2016-09-23 20:27:58 +0200
committerSergei Golubchik <serg@mariadb.org>2016-09-23 20:27:58 +0200
commit677c44f0c37973ad70550d9b807781e688764fae (patch)
tree348951761ef4ec0afb2b6ec5f97dc44c5384e6e7
parente56a53920b0075f9a534610032ee05f2e249e3ae (diff)
downloadmariadb-git-677c44f0c37973ad70550d9b807781e688764fae.tar.gz
MDEV-10775 System table in InnoDB format allowed in MariaDB could lead to crash
when opening a system table for a SELECT-like read, pretend (for the sake of engines) it's SQLCOM_SELECT
-rw-r--r--mysql-test/suite/innodb/r/system_tables.result8
-rw-r--r--mysql-test/suite/innodb/t/system_tables.test12
-rw-r--r--sql/sql_base.cc1
3 files changed, 21 insertions, 0 deletions
diff --git a/mysql-test/suite/innodb/r/system_tables.result b/mysql-test/suite/innodb/r/system_tables.result
new file mode 100644
index 00000000000..79a24f7e455
--- /dev/null
+++ b/mysql-test/suite/innodb/r/system_tables.result
@@ -0,0 +1,8 @@
+alter table mysql.time_zone_name engine=InnoDB;
+create table envois3 (starttime datetime) engine=InnoDB;
+insert envois3 values ('2008-08-11 22:43:00');
+select convert_tz(starttime,'UTC','Europe/Moscow') starttime from envois3;
+starttime
+2008-08-12 02:43:00
+drop table envois3;
+alter table mysql.time_zone_name engine=MyISAM;
diff --git a/mysql-test/suite/innodb/t/system_tables.test b/mysql-test/suite/innodb/t/system_tables.test
new file mode 100644
index 00000000000..90cb8c59fbd
--- /dev/null
+++ b/mysql-test/suite/innodb/t/system_tables.test
@@ -0,0 +1,12 @@
+--source include/have_innodb.inc
+
+#
+# MDEV-10775 System table in InnoDB format allowed in MariaDB could lead to crash
+#
+alter table mysql.time_zone_name engine=InnoDB;
+create table envois3 (starttime datetime) engine=InnoDB;
+insert envois3 values ('2008-08-11 22:43:00');
+--source include/restart_mysqld.inc
+select convert_tz(starttime,'UTC','Europe/Moscow') starttime from envois3;
+drop table envois3;
+alter table mysql.time_zone_name engine=MyISAM;
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 6ec94016366..b9cc4e5d69a 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -9223,6 +9223,7 @@ open_system_tables_for_read(THD *thd, TABLE_LIST *table_list,
*/
lex->reset_n_backup_query_tables_list(&query_tables_list_backup);
thd->reset_n_backup_open_tables_state(backup);
+ thd->lex->sql_command= SQLCOM_SELECT;
if (open_and_lock_tables(thd, table_list, FALSE,
MYSQL_OPEN_IGNORE_FLUSH |