diff options
author | unknown <mattiasj@mattias-jonssons-macbook.local> | 2007-11-20 11:21:00 +0100 |
---|---|---|
committer | unknown <mattiasj@mattias-jonssons-macbook.local> | 2007-11-20 11:21:00 +0100 |
commit | 4c31c41fdc3e105197f3e76476243e6c3210ba93 (patch) | |
tree | feeac50020914d1a4642df600d412a328930cb18 | |
parent | 011eb3dffe068db46ea4144eee242a4f2b203cf8 (diff) | |
download | mariadb-git-4c31c41fdc3e105197f3e76476243e6c3210ba93.tar.gz |
Bug#30822: ALTER TABLE COALESCE PARTITION causes segmentation fault
Problem was for LINEAR HASH/KEY. Crashes because of wrong partition id
returned when creating the new altered partitions. (because of wrong
linear hash mask)
Solution: Update the linear hash mask before using it for the new
altered table.
mysql-test/r/partition_hash.result:
Bug#30822: ALTER TABLE COALESCE PARTITION causes segmentation fault
test result
mysql-test/t/partition_hash.test:
Bug#30822: ALTER TABLE COALESCE PARTITION causes segmentatition fault
test case
sql/ha_partition.cc:
Bug#30822: ALTER TABLE COALESCE PARTITION causes segmentation fault
Updating the linear hash mask before using it.
sql/sql_partition.cc:
Bug#30822: ALTER TABLE COALESCE PARTITION causes segmentation fault
exporting the set_linear_hash_mask function (static -> non static)
sql/sql_partition.h:
Bug#30822: ALTER TABLE COALESCE PARTITION causes segmentation fault
exporting the set_linear_hash_mask function (static -> non static)
-rw-r--r-- | mysql-test/r/partition_hash.result | 12 | ||||
-rw-r--r-- | mysql-test/t/partition_hash.test | 16 | ||||
-rw-r--r-- | sql/ha_partition.cc | 8 | ||||
-rw-r--r-- | sql/sql_partition.cc | 2 | ||||
-rw-r--r-- | sql/sql_partition.h | 1 |
5 files changed, 38 insertions, 1 deletions
diff --git a/mysql-test/r/partition_hash.result b/mysql-test/r/partition_hash.result index 72f036be099..94fefe77a77 100644 --- a/mysql-test/r/partition_hash.result +++ b/mysql-test/r/partition_hash.result @@ -1,4 +1,16 @@ drop table if exists t1; +CREATE TABLE t1 (c1 INT) +PARTITION BY HASH (c1) +PARTITIONS 15; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +ALTER TABLE t1 COALESCE PARTITION 13; +DROP TABLE t1; +CREATE TABLE t1 (c1 INT) +PARTITION BY LINEAR HASH (c1) +PARTITIONS 5; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +ALTER TABLE t1 COALESCE PARTITION 3; +DROP TABLE t1; create table t1 (a int unsigned) partition by hash(a div 2) partitions 4; diff --git a/mysql-test/t/partition_hash.test b/mysql-test/t/partition_hash.test index 52caaa8c8e9..362d5f747e9 100644 --- a/mysql-test/t/partition_hash.test +++ b/mysql-test/t/partition_hash.test @@ -10,6 +10,22 @@ drop table if exists t1; --enable_warnings # +# Bug#30822: crash when COALESCE +# +CREATE TABLE t1 (c1 INT) + PARTITION BY HASH (c1) + PARTITIONS 15; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +ALTER TABLE t1 COALESCE PARTITION 13; +DROP TABLE t1; +CREATE TABLE t1 (c1 INT) + PARTITION BY LINEAR HASH (c1) + PARTITIONS 5; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +ALTER TABLE t1 COALESCE PARTITION 3; +DROP TABLE t1; + +# # More partition pruning tests, especially on interval walking # create table t1 (a int unsigned) diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index b53a5e3da97..d1b20896d9a 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -1531,6 +1531,14 @@ int ha_partition::copy_partitions(ulonglong *copied, ulonglong *deleted) longlong func_value; DBUG_ENTER("ha_partition::copy_partitions"); + if (m_part_info->linear_hash_ind) + { + if (m_part_info->part_type == HASH_PARTITION) + set_linear_hash_mask(m_part_info, m_part_info->no_parts); + else + set_linear_hash_mask(m_part_info, m_part_info->no_subparts); + } + while (reorg_part < m_reorged_parts) { handler *file= m_reorged_file[reorg_part]; diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 94b58bf913f..8d5732dfd94 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1402,7 +1402,7 @@ static void set_up_partition_func_pointers(partition_info *part_info) NONE */ -static void set_linear_hash_mask(partition_info *part_info, uint no_parts) +void set_linear_hash_mask(partition_info *part_info, uint no_parts) { uint mask; diff --git a/sql/sql_partition.h b/sql/sql_partition.h index 56f24181b93..282e24f1853 100644 --- a/sql/sql_partition.h +++ b/sql/sql_partition.h @@ -65,6 +65,7 @@ int get_part_for_delete(const uchar *buf, const uchar *rec0, void prune_partition_set(const TABLE *table, part_id_range *part_spec); bool check_partition_info(partition_info *part_info,handlerton **eng_type, TABLE *table, handler *file, HA_CREATE_INFO *info); +void set_linear_hash_mask(partition_info *part_info, uint no_parts); bool fix_partition_func(THD *thd, TABLE *table, bool create_table_ind); char *generate_partition_syntax(partition_info *part_info, uint *buf_length, bool use_sql_alloc, |