diff --git a/mysql-test/suite/versioning/r/partition.result b/mysql-test/suite/versioning/r/partition.result index 8bf9bc79183..afed90c8e76 100644 --- a/mysql-test/suite/versioning/r/partition.result +++ b/mysql-test/suite/versioning/r/partition.result @@ -251,6 +251,15 @@ x 3 4 5 +### Assertion in ALTER on warning from partitioning LIMIT [#446] +create or replace table t1 (x int) with system versioning; +insert into t1 values (1), (2); +delete from t1; +alter table t1 partition by system_time limit 1 ( +partition p1 history, +partition pn current); +Warnings: +Note 4113 Versioned table `test`.`t1`: partition `p1` is full, add more HISTORY partitions ## rotation by INTERVAL create or replace table t1 (x int) with system versioning diff --git a/mysql-test/suite/versioning/t/partition.test b/mysql-test/suite/versioning/t/partition.test index 570b1f44d58..aba93a72067 100644 --- a/mysql-test/suite/versioning/t/partition.test +++ b/mysql-test/suite/versioning/t/partition.test @@ -216,6 +216,14 @@ insert into t1 values (4), (5); delete from t1; select * from t1 partition (p1) order by x; +--echo ### Assertion in ALTER on warning from partitioning LIMIT [#446] +create or replace table t1 (x int) with system versioning; +insert into t1 values (1), (2); +delete from t1; +alter table t1 partition by system_time limit 1 ( + partition p1 history, + partition pn current); + --echo ## rotation by INTERVAL --error ER_PART_WRONG_VALUE create or replace table t1 (x int) diff --git a/sql/partition_info.cc b/sql/partition_info.cc index e1e83db7b31..fe9377674f1 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -897,10 +897,12 @@ partition_info::vers_part_rotate(THD * thd) { DBUG_ASSERT(table->s->hist_part_id == vers_info->now_part->id - 1); push_warning_printf(thd, - Sql_condition::WARN_LEVEL_WARN, + thd->lex->sql_command == SQLCOM_ALTER_TABLE ? + Sql_condition::WARN_LEVEL_NOTE : + Sql_condition::WARN_LEVEL_WARN, WARN_VERS_PART_FULL, ER_THD(thd, WARN_VERS_PART_FULL), - table->s->db.str, table->s->table_name.str, + table->s->db.str, table->s->error_table_name(), vers_info->hist_part->partition_name); return vers_info->hist_part; } @@ -913,7 +915,7 @@ partition_info::vers_part_rotate(THD * thd) Sql_condition::WARN_LEVEL_NOTE, WARN_VERS_PART_ROTATION, ER_THD(thd, WARN_VERS_PART_ROTATION), - table->s->db.str, table->s->table_name.str, + table->s->db.str, table->s->error_table_name(), old_part_name, vers_info->hist_part->partition_name); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 0ae2b6ff749..3ee4073ca7a 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -9780,6 +9780,7 @@ bool mysql_alter_table(THD *thd, const char *new_db, const char *new_name, } if (!new_table) goto err_new_table_cleanup; + new_table->s->orig_table_name= table->s->table_name.str; new_versioned= new_table->versioned(); /* Note: In case of MERGE table, we do not attach children. We do not diff --git a/sql/table.h b/sql/table.h index 17d0f257ebb..1c361d6830a 100644 --- a/sql/table.h +++ b/sql/table.h @@ -648,6 +648,16 @@ struct TABLE_SHARE LEX_CSTRING normalized_path; /* unpack_filename(path) */ LEX_CSTRING connect_string; + const char* orig_table_name; /* Original table name for this tmp table */ + const char* error_table_name() const /* Get table name for error messages */ + { + return tmp_table ? ( + orig_table_name ? + orig_table_name : + "(temporary)") : + table_name.str; + } + /* Set of keys in use, implemented as a Bitmap. Excludes keys disabled by ALTER TABLE ... DISABLE KEYS.