diff --git a/mysql-test/r/partition_error.result b/mysql-test/r/partition_error.result index ce304b136d0..c0dc891480a 100644 --- a/mysql-test/r/partition_error.result +++ b/mysql-test/r/partition_error.result @@ -1,5 +1,13 @@ drop table if exists t1; # +# Bug#49477: Assertion `0' failed in ha_partition.cc:5530 +# with temporary table and partitions +# +CREATE TABLE t1 (a INT) PARTITION BY HASH(a); +CREATE TEMPORARY TABLE tmp_t1 LIKE t1; +ERROR HY000: Cannot create temporary table with partitions +DROP TABLE t1; +# # Bug#50392: insert_id is not reset for partitioned tables # auto_increment on duplicate entry CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY); diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test index bfa1206fe2d..1efb8847e5e 100644 --- a/mysql-test/t/partition_error.test +++ b/mysql-test/t/partition_error.test @@ -8,6 +8,15 @@ drop table if exists t1; --enable_warnings +--echo # +--echo # Bug#49477: Assertion `0' failed in ha_partition.cc:5530 +--echo # with temporary table and partitions +--echo # +CREATE TABLE t1 (a INT) PARTITION BY HASH(a); +--error ER_PARTITION_NO_TEMPORARY +CREATE TEMPORARY TABLE tmp_t1 LIKE t1; +DROP TABLE t1; + --echo # --echo # Bug#50392: insert_id is not reset for partitioned tables --echo # auto_increment on duplicate entry diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 06bee47c7ef..352f23f56ea 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -90,7 +90,9 @@ static int partition_initialize(void *p) partition_hton->create= partition_create_handler; partition_hton->partition_flags= partition_flags; partition_hton->alter_table_flags= alter_table_flags; - partition_hton->flags= HTON_NOT_USER_SELECTABLE | HTON_HIDDEN; + partition_hton->flags= HTON_NOT_USER_SELECTABLE | + HTON_HIDDEN | + HTON_TEMPORARY_NOT_SUPPORTED; return 0; } @@ -1896,6 +1898,13 @@ uint ha_partition::del_ren_cre_table(const char *from, handler **file, **abort_file; DBUG_ENTER("del_ren_cre_table()"); + /* Not allowed to create temporary partitioned tables */ + if (create_info && create_info->options & HA_LEX_CREATE_TMP_TABLE) + { + my_error(ER_PARTITION_NO_TEMPORARY, MYF(0)); + DBUG_RETURN(TRUE); + } + if (get_from_handler_file(from, ha_thd()->mem_root)) DBUG_RETURN(TRUE); DBUG_ASSERT(m_file_buffer); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index b4ad5e2c2f9..0b35a57bd95 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2958,7 +2958,7 @@ end_with_restore_list: access is granted. We need to check if first_table->grant.privilege contains any table-specific privilege. */ - DBUG_PRINT("debug", ("first_table->grant.privilege: %x", + DBUG_PRINT("debug", ("first_table->grant.privilege: %lx", first_table->grant.privilege)); if (check_some_access(thd, SHOW_CREATE_TABLE_ACLS, first_table) || (first_table->grant.privilege & SHOW_CREATE_TABLE_ACLS) == 0)