Hi!
On Oct 15, mattiasj@stripped wrote:
> ChangeSet@stripped, 2007-10-15 10:30:57+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.
Ok to push with one change, see below
> 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-15 10:30:53 +02:00
> @@ -2705,17 +2705,29 @@ 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();
> -
> /*
> If we have failed to set the auto-increment value for this row,
> it is highly likely that we will not be able to insert it into
> the correct partition. We must check and fail if neccessary.
> */
> if (error)
> + {
> + if (table_share->tmp_table == NO_TMP_TABLE)
> + pthread_mutex_unlock(&table_share->mutex);
> DBUG_RETURN(error);
> + }
remove this { } block compeltely, and put "goto exit;" here
> }
>
Regards / Mit vielen Grüssen,
Sergei
--
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Sergei Golubchik <serg@stripped>
/ /|_/ / // /\ \/ /_/ / /__ Principal Software Developer
/_/ /_/\_, /___/\___\_\___/ MySQL GmbH, Dachauer Str. 37, D-80335 München
<___/ Geschäftsführer: Kaj Arnö - HRB
München 162140