summaryrefslogtreecommitdiff
path: root/sql/ha_partition.cc
diff options
context:
space:
mode:
authorunknown <mattiasj@mattiasj-laptop.(none)>2007-10-17 20:40:23 +0200
committerunknown <mattiasj@mattiasj-laptop.(none)>2007-10-17 20:40:23 +0200
commitbfc41161b49dec93a1f59e15d5147b3f18fc3578 (patch)
tree54c2a09768bf727ffeae066e153aa0d84d1acbc2 /sql/ha_partition.cc
parent9105a1d90b78f125738d6fb720d4a1db1632abd6 (diff)
downloadmariadb-git-bfc41161b49dec93a1f59e15d5147b3f18fc3578.tar.gz
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: Bug #30878: Crashing when alter an auto_increment non partitioned table to partitioned test result mysql-test/t/partition.test: Bug #30878: Crashing when alter an auto_increment non partitioned table to partitioned testcase sql/ha_partition.cc: 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)
Diffstat (limited to 'sql/ha_partition.cc')
-rw-r--r--sql/ha_partition.cc20
1 files changed, 15 insertions, 5 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 1150cf41417..81d75c58d05 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -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