Below is the list of changes that have just been committed into a local
5.1 repository of mattiasj. When mattiasj does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-10-17 20:40:23+02:00, mattiasj@mattiasj-laptop.(none) +3 -0
Bug #30878: Crashing when alter an auto_increment non partitioned
table to partitioned
Problem:
Crashed because usage of an uninitialised mutex when auto_incrementing
a partitioned temporary table
Fix:
Only locking (using the mutex) if not temporary table.
mysql-test/r/partition.result@stripped, 2007-10-17 20:40:22+02:00, mattiasj@mattiasj-laptop.(none) +12 -0
Bug #30878: Crashing when alter an auto_increment non partitioned
table to partitioned
test result
mysql-test/t/partition.test@stripped, 2007-10-17 20:40:22+02:00, mattiasj@mattiasj-laptop.(none) +18 -0
Bug #30878: Crashing when alter an auto_increment non partitioned
table to partitioned
testcase
sql/ha_partition.cc@stripped, 2007-10-17 20:40:22+02:00, mattiasj@mattiasj-laptop.(none) +15 -5
Bug #30878: Crashing when alter an auto_increment non partitioned
table to partitioned
If the table is a temporary table, the table_share->mutex is not
initialised.
Checking if not temporary table, then OK to lock (else no need
to lock)
diff -Nrup a/mysql-test/r/partition.result b/mysql-test/r/partition.result
--- a/mysql-test/r/partition.result 2007-10-04 14:56:29 +02:00
+++ b/mysql-test/r/partition.result 2007-10-17 20:40:22 +02:00
@@ -1,4 +1,16 @@
drop table if exists t1;
+create table t1 (id int auto_increment, s1 int, primary key (id));
+insert into t1 values (null,1);
+insert into t1 values (null,6);
+select * from t1;
+id s1
+1 1
+2 6
+alter table t1 partition by range (id) (
+partition p0 values less than (3),
+partition p1 values less than maxvalue
+);
+drop table t1;
create table t1 (a int)
partition by key(a)
partitions 0.2+e1;
diff -Nrup a/mysql-test/t/partition.test b/mysql-test/t/partition.test
--- a/mysql-test/t/partition.test 2007-10-04 14:56:29 +02:00
+++ b/mysql-test/t/partition.test 2007-10-17 20:40:22 +02:00
@@ -10,6 +10,24 @@ drop table if exists t1;
--enable_warnings
#
+# Bug 30878: crashing when alter an auto_increment non partitioned
+# table to partitioned
+
+create table t1 (id int auto_increment, s1 int, primary key (id));
+
+insert into t1 values (null,1);
+insert into t1 values (null,6);
+
+select * from t1;
+
+alter table t1 partition by range (id) (
+ partition p0 values less than (3),
+ partition p1 values less than maxvalue
+);
+
+drop table t1;
+
+#
# Bug 15890: Strange number of partitions accepted
#
-- error 1064
diff -Nrup a/sql/ha_partition.cc b/sql/ha_partition.cc
--- a/sql/ha_partition.cc 2007-10-10 21:25:16 +02:00
+++ b/sql/ha_partition.cc 2007-10-17 20:40:22 +02:00
@@ -2678,7 +2678,8 @@ int ha_partition::write_row(uchar * buf)
uint32 part_id;
int error;
longlong func_value;
- bool autoincrement_lock= false;
+ bool autoincrement_lock= FALSE;
+ my_bitmap_map *old_map;
#ifdef NOT_NEEDED
uchar *rec0= m_rec0;
#endif
@@ -2705,8 +2706,17 @@ int ha_partition::write_row(uchar * buf)
use autoincrement_lock variable to avoid unnecessary locks.
Probably not an ideal solution.
*/
- autoincrement_lock= true;
- pthread_mutex_lock(&table_share->mutex);
+ if (table_share->tmp_table == NO_TMP_TABLE)
+ {
+ /*
+ Bug#30878 crash when alter table from non partitioned table
+ to partitioned.
+ Checking if tmp table then there is no need to lock,
+ and the table_share->mutex may not be initialised.
+ */
+ autoincrement_lock= TRUE;
+ pthread_mutex_lock(&table_share->mutex);
+ }
error= update_auto_increment();
/*
@@ -2715,10 +2725,10 @@ int ha_partition::write_row(uchar * buf)
the correct partition. We must check and fail if neccessary.
*/
if (error)
- DBUG_RETURN(error);
+ goto exit;
}
- my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
+ old_map= dbug_tmp_use_all_columns(table, table->read_set);
#ifdef NOT_NEEDED
if (likely(buf == rec0))
#endif
| Thread |
|---|
| • bk commit into 5.1 tree (mattiasj:1.2576) BUG#30878 | mattiasj | 17 Oct |