On 5/25/11 4:36 AM, Andrei Elkin wrote:
>
> +static int32 incr_slave_open_temp_tables(THD *thd, int inc)
incr_slave_open_temp_tables -> inc_slave_open_temp_tables
Drop return value, it's not used.
> +{
> + int32 ret;
> +
> + if (thd->system_thread == SYSTEM_THREAD_SLAVE_WORKER)
> + {
> + my_atomic_rwlock_wrlock(&slave_open_temp_tables_lock);
> + ret= my_atomic_add32(&slave_open_temp_tables, inc);
> + my_atomic_rwlock_wrlock(&slave_open_temp_tables_unlock);
> + ret += inc;
> + }
> + else
> + ret= (slave_open_temp_tables += inc);
> +
> + return ret;
> +}
>
> /**
> Total number of TABLE instances for tables in the table definition cache
> @@ -2133,7 +2149,7 @@ void close_temporary_table(THD *thd, TAB
> {
> /* natural invariant of temporary_tables */
> DBUG_ASSERT(slave_open_temp_tables || !thd->temporary_tables);
> - slave_open_temp_tables--;
> + incr_slave_open_temp_tables(thd, -1);
> }
> close_temporary(table, free_share, delete_table);
> DBUG_VOID_RETURN;
> @@ -5858,7 +5874,7 @@ TABLE *open_table_uncached(THD *thd, con
> thd->temporary_tables= tmp_table;
> thd->temporary_tables->prev= 0;
> if (thd->slave_thread)
> - slave_open_temp_tables++;
> + incr_slave_open_temp_tables(thd, 1);
> }
> tmp_table->pos_in_table_list= 0;
> DBUG_PRINT("tmptable", ("opened table: '%s'.'%s' 0x%lx",
> tmp_table->s->db.str,