From c661b4d0fb38c103fc0b659a95e8552ea72574cf Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 14 Jun 2017 00:48:34 +0200 Subject: [PATCH] MDEV-13017 LOCK TABLE fails with irrelevant error while working with tables affected by ANSI_QUOTES --- mysql-test/suite/parts/r/quoting.result | 6 ++++++ mysql-test/suite/parts/t/quoting.test | 10 ++++++++++ sql/sql_partition.cc | 3 +++ 3 files changed, 19 insertions(+) create mode 100644 mysql-test/suite/parts/r/quoting.result create mode 100644 mysql-test/suite/parts/t/quoting.test diff --git a/mysql-test/suite/parts/r/quoting.result b/mysql-test/suite/parts/r/quoting.result new file mode 100644 index 00000000000..ba6a155e6ac --- /dev/null +++ b/mysql-test/suite/parts/r/quoting.result @@ -0,0 +1,6 @@ +set sql_mode=ansi_quotes; +create table t1 (i int) partition by range (i) (partition flush values less than maxvalue); +set sql_mode=default; +lock tables t1 read local; +unlock tables; +drop table t1; diff --git a/mysql-test/suite/parts/t/quoting.test b/mysql-test/suite/parts/t/quoting.test new file mode 100644 index 00000000000..297896fd9cf --- /dev/null +++ b/mysql-test/suite/parts/t/quoting.test @@ -0,0 +1,10 @@ +# +# MDEV-13017 LOCK TABLE fails with irrelevant error while working with tables affected by ANSI_QUOTES +# +--source include/have_partition.inc +set sql_mode=ansi_quotes; +create table t1 (i int) partition by range (i) (partition flush values less than maxvalue); +set sql_mode=default; +lock tables t1 read local; +unlock tables; +drop table t1; diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 43f9797eb62..e6513fc7476 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1918,9 +1918,12 @@ static int add_name_string(File fptr, const char *name) int err; String name_string("", 0, system_charset_info); THD *thd= current_thd; + ulonglong save_sql_mode= thd->variables.sql_mode; + thd->variables.sql_mode&= ~MODE_ANSI_QUOTES; ulonglong save_options= thd->variables.option_bits; thd->variables.option_bits&= ~OPTION_QUOTE_SHOW_CREATE; append_identifier(thd, &name_string, name, strlen(name)); + thd->variables.sql_mode= save_sql_mode; thd->variables.option_bits= save_options; err= add_string_object(fptr, &name_string); return err;