diff --git a/mysql-test/suite/parts/r/show_create.result b/mysql-test/suite/parts/r/show_create.result index 596233fdf8b..17f89161f5e 100644 --- a/mysql-test/suite/parts/r/show_create.result +++ b/mysql-test/suite/parts/r/show_create.result @@ -109,9 +109,5 @@ alter table t1 add partition (partition p1 values less than (10)); set sql_mode= default; 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 -t1 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '"p0" VALUES LESS THAN (5) ENGINE = MyISAM, - PARTITION "p1" VALUES LESS THAN (10)' at line 2 -Warnings: -Warning 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '"p0" VALUES LESS THAN (5) ENGINE = MyISAM, - PARTITION "p1" VALUES LESS THAN (10)' at line 2 +t1 MyISAM 10 Fixed 0 0 0 0 2048 0 NULL X X NULL latin1_swedish_ci NULL partitioned drop table t1; diff --git a/mysql-test/suite/parts/t/show_create.test b/mysql-test/suite/parts/t/show_create.test index 4a54b6b41b3..3f62ee11757 100644 --- a/mysql-test/suite/parts/t/show_create.test +++ b/mysql-test/suite/parts/t/show_create.test @@ -47,5 +47,6 @@ create table t1 (a int) partition by range(a) (partition p0 values less than (5) set sql_mode='ansi_quotes'; alter table t1 add partition (partition p1 values less than (10)); set sql_mode= default; +--replace_column 12 X 13 X show table status; drop table t1; diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 43f936cf200..c05f55e457d 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -9092,11 +9092,9 @@ int ha_partition::check_for_upgrade(HA_CHECK_OPT *check_opt) } m_part_info->key_algorithm= partition_info::KEY_ALGORITHM_51; if (skip_generation || - !(part_buf= generate_partition_syntax(thd, m_part_info, + !(part_buf= generate_partition_syntax_for_frm(thd, m_part_info, &part_buf_len, - true, - NULL, - NULL)) || + NULL, NULL)) || print_admin_msg(thd, SQL_ADMIN_MSG_TEXT_SIZE + 1, "error", table_share->db.str, table->alias, diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index f5467e85f62..153c1e0ff2e 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -2219,6 +2219,18 @@ static int add_key_with_algorithm(String *str, partition_info *part_info) return err; } +char *generate_partition_syntax_for_frm(THD *thd, partition_info *part_info, + uint *buf_length, + HA_CREATE_INFO *create_info, + Alter_info *alter_info) +{ + sql_mode_t old_mode= thd->variables.sql_mode; + thd->variables.sql_mode &= ~MODE_ANSI_QUOTES; + char *res= generate_partition_syntax(thd, part_info, buf_length, + true, create_info, alter_info); + thd->variables.sql_mode= old_mode; + return res; +} /* Generate the partition syntax from the partition data structure. diff --git a/sql/sql_partition.h b/sql/sql_partition.h index acca6f61f01..d1eb208cbd1 100644 --- a/sql/sql_partition.h +++ b/sql/sql_partition.h @@ -272,6 +272,10 @@ char *generate_partition_syntax(THD *thd, partition_info *part_info, bool show_partition_options, HA_CREATE_INFO *create_info, Alter_info *alter_info); +char *generate_partition_syntax_for_frm(THD *thd, partition_info *part_info, + uint *buf_length, + HA_CREATE_INFO *create_info, + Alter_info *alter_info); bool verify_data_with_partition(TABLE *table, TABLE *part_table, uint32 part_id); bool compare_partition_options(HA_CREATE_INFO *table_create_info, diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 4aed06e3590..02780e7d1e0 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -30,7 +30,6 @@ #include "strfunc.h" // find_type2, find_set #include "sql_truncate.h" // regenerate_locked_table #include "sql_partition.h" // mem_alloc_error, - // generate_partition_syntax, // partition_info // NOT_A_PARTITION_ID #include "sql_db.h" // load_db_opt_by_name @@ -1820,13 +1819,10 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) partition_info *part_info= lpt->table->part_info; if (part_info) { - if (!(part_syntax_buf= generate_partition_syntax(lpt->thd, part_info, - &syntax_len, TRUE, - lpt->create_info, - lpt->alter_info))) - { + part_syntax_buf= generate_partition_syntax_for_frm(lpt->thd, part_info, + &syntax_len, lpt->create_info, lpt->alter_info); + if (!part_syntax_buf) DBUG_RETURN(TRUE); - } part_info->part_info_string= part_syntax_buf; part_info->part_info_len= syntax_len; } @@ -1902,10 +1898,9 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) { TABLE_SHARE *share= lpt->table->s; char *tmp_part_syntax_str; - if (!(part_syntax_buf= generate_partition_syntax(lpt->thd, part_info, - &syntax_len, TRUE, - lpt->create_info, - lpt->alter_info))) + part_syntax_buf= generate_partition_syntax_for_frm(lpt->thd, + part_info, &syntax_len, lpt->create_info, lpt->alter_info); + if (!part_syntax_buf) { error= 1; goto err; @@ -4564,11 +4559,8 @@ handler *mysql_create_frm_image(THD *thd, We reverse the partitioning parser and generate a standard format for syntax stored in frm file. */ - sql_mode_t old_mode= thd->variables.sql_mode; - thd->variables.sql_mode &= ~MODE_ANSI_QUOTES; - part_syntax_buf= generate_partition_syntax(thd, part_info, &syntax_len, - true, create_info, alter_info); - thd->variables.sql_mode= old_mode; + part_syntax_buf= generate_partition_syntax_for_frm(thd, part_info, + &syntax_len, create_info, alter_info); if (!part_syntax_buf) goto err; part_info->part_info_string= part_syntax_buf;