mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
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.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -9,6 +9,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
|
||||
#
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user