Bug #39227 | Maria: crash with ALTER TABLE PARTITION | ||
---|---|---|---|
Submitted: | 3 Sep 2008 21:01 | Modified: | 9 Jan 2009 15:27 |
Reporter: | Guilhem Bichot | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Maria storage engine | Severity: | S3 (Non-critical) |
Version: | 5.1-maria, 6.0-bk | OS: | Linux |
Assigned to: | Michael Widenius | CPU Architecture: | Any |
[3 Sep 2008 21:01]
Guilhem Bichot
[4 Oct 2008 16:34]
Michael Widenius
Suggested patch: === modified file 'mysql-test/r/maria.result' --- mysql-test/r/maria.result 2008-09-26 13:49:51 +0000 +++ mysql-test/r/maria.result 2008-10-04 16:33:01 +0000 @@ -2284,3 +2284,8 @@ insert into v1 (f1) values (3) on duplic insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10; drop table t1,t2; drop view v1; +create table t1 (s1 int); +insert into t1 values (1); +alter table t1 partition by list (s1) (partition p1 values in (2)); +ERROR HY000: Table has no partition for value 1 +drop table t1; === modified file 'mysql-test/t/maria.test' --- mysql-test/t/maria.test 2008-09-26 13:49:51 +0000 +++ mysql-test/t/maria.test 2008-10-04 16:31:19 +0000 @@ -1575,3 +1575,13 @@ insert into v1 (f1) values (3) on duplic insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10; drop table t1,t2; drop view v1; + +# +# Bug #39227 Maria: crash with ALTER TABLE PARTITION +# + +create table t1 (s1 int); +insert into t1 values (1); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +alter table t1 partition by list (s1) (partition p1 values in (2)); +drop table t1; === modified file 'sql/ha_partition.cc' --- sql/ha_partition.cc 2008-06-28 12:45:15 +0000 +++ sql/ha_partition.cc 2008-10-04 16:31:53 +0000 @@ -4950,12 +4950,13 @@ int ha_partition::extra(enum ha_extra_fu /* Category 3), used by MyISAM handlers */ case HA_EXTRA_PREPARE_FOR_RENAME: DBUG_RETURN(prepare_for_rename()); + case HA_EXTRA_PREPARE_FOR_DROP: + DBUG_RETURN(prepare_for_drop()); case HA_EXTRA_NORMAL: case HA_EXTRA_QUICK: case HA_EXTRA_NO_READCHECK: case HA_EXTRA_PREPARE_FOR_UPDATE: case HA_EXTRA_FORCE_REOPEN: - case HA_EXTRA_PREPARE_FOR_DROP: case HA_EXTRA_FLUSH_CACHE: { if (m_myisam) @@ -5104,7 +5105,7 @@ void ha_partition::prepare_extra_cache(u /* - Prepares our new and reorged handlers for rename or delete + Prepares our new and reorged handlers for rename SYNOPSIS prepare_for_delete() @@ -5134,6 +5135,37 @@ int ha_partition::prepare_for_rename() DBUG_RETURN(loop_extra(HA_EXTRA_PREPARE_FOR_RENAME)); } + +/** + Send extra call to all files that will be droped based on reorg + + SYNOPSIS + prepare_for_drop() + + RETURN VALUE + >0 Error code + 0 Success +*/ + +int ha_partition::prepare_for_drop() +{ + int result= 0, tmp; + handler **file; + DBUG_ENTER("ha_partition::prepare_for_drop()"); + + /* If alter table */ + if (m_new_file != NULL) + { + /* Signal drop for all parts that will be dropped */ + for (file= m_reorged_file; *file; file++) + if ((tmp= (*file)->extra(HA_EXTRA_PREPARE_FOR_DROP))) + result= tmp; + DBUG_RETURN(result); + } + DBUG_RETURN(loop_extra(HA_EXTRA_PREPARE_FOR_DROP)); +} + + /* Call extra on all partitions @@ -5153,8 +5185,8 @@ int ha_partition::loop_extra(enum ha_ext DBUG_ENTER("ha_partition::loop_extra()"); /* - TODO, 5.2: this is where you could possibly add optimisations to add the bitmap - _if_ a SELECT. + TODO, 5.2: this is where you could possibly add optimisations to add the + bitmap _if_ a SELECT. */ for (file= m_file; *file; file++) { === modified file 'sql/ha_partition.h' --- sql/ha_partition.h 2008-05-29 18:39:25 +0000 +++ sql/ha_partition.h 2008-10-04 16:24:06 +0000 @@ -212,6 +212,7 @@ public: virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share); private: int prepare_for_rename(); + int prepare_for_drop(); int copy_partitions(ulonglong *copied, ulonglong *deleted); void cleanup_new_partition(uint part_count); int prepare_new_partition(TABLE *table, HA_CREATE_INFO *create_info,
[14 Oct 2008 20:32]
Michael Widenius
Pushed in 5.1-maria tree
[26 Oct 2008 22:20]
Bugs System
Pushed into 6.0.8-alpha (revid:monty@mysql.com-20081012100952-h39szt1kgq6j0tj4) (version source revid:guilhem@mysql.com-20081020191322-i0e65e3k8044kkce) (pib:5)
[9 Jan 2009 15:27]
MC Brown
Added a note to the 6.0.8 changelog: Using Maria, executing FLUSH TABLES WITH READ LOCK after a LOCK TABLES statement would lead to a crash.
[9 Jan 2009 15:27]
MC Brown
Correction, changelog message is: Running ALTER TABLE PARTITION on a Maria table would lead to a crash.