Skip to content

Commit edea0c4

Browse files
author
Mattias Jonsson
committed
Bug#60039: crash when exchanging a partition on
nonpartitioned table with a view Since the table was a view, it was never opened. Due to this it crashed on null pointer reference. Fixed by checking the tables before using it.
1 parent a867509 commit edea0c4

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

mysql-test/r/partition_error.result

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
drop table if exists t1, t2;
22
#
3+
# Bug#60039: crash when exchanging a partition on
4+
# nonpartitioned table with a view
5+
#
6+
CREATE TABLE t1 (a int);
7+
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1;
8+
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE v1;
9+
ERROR 42000: Can't open table
10+
DROP VIEW v1;
11+
DROP TABLE t1;
12+
#
313
# Bug#57924: crash when creating partitioned table with
414
# multiple columns in the partition key
515
#

mysql-test/t/partition_error.test

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ drop table if exists t1, t2;
1010

1111
let $MYSQLD_DATADIR= `SELECT @@datadir`;
1212

13+
--echo #
14+
--echo # Bug#60039: crash when exchanging a partition on
15+
--echo # nonpartitioned table with a view
16+
--echo #
17+
CREATE TABLE t1 (a int);
18+
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1;
19+
--error ER_CHECK_NO_SUCH_TABLE
20+
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE v1;
21+
DROP VIEW v1;
22+
DROP TABLE t1;
23+
1324
--echo #
1425
--echo # Bug#57924: crash when creating partitioned table with
1526
--echo # multiple columns in the partition key

sql/sql_partition_admin.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,11 +527,12 @@ bool Sql_cmd_alter_table_exchange_partition::
527527

528528
part_table= table_list->table;
529529
swap_table= swap_table_list->table;
530-
table_hton= swap_table->file->ht;
531530

532531
if (check_exchange_partition(swap_table, part_table))
533532
DBUG_RETURN(TRUE);
534533

534+
table_hton= swap_table->file->ht;
535+
535536
thd_proc_info(thd, "verifying table");
536537

537538
/* Will append the partition name later in part_info->get_part_elem() */

0 commit comments

Comments
 (0)