List:Commits« Previous MessageNext Message »
From:Sergei Golubchik Date:January 6 2009 2:35pm
Subject:Re: bzr commit into mysql-5.1-bugteam branch (davi:2739) Bug#41348
View as plain text  
Hi, Davi!

On Dec 17, Davi Arnaut wrote:
> # At a local mysql-5.1-bugteam repository of davi
> 
>  2739 Davi Arnaut	2008-12-17
>       Bug#41348: INSERT INTO tbl SELECT * FROM temp_tbl overwrites
>                   locking type of temp table
>       
>       The problem is that INSERT INTO .. SELECT FROM .. and CREATE
>       TABLE .. SELECT FROM a temporary table could inadvertently
>       overwrite the locking type of the temporary table. The lock
>       type of temporary tables should be a write lock by default.

why here ?
You've added the code that overwrites tables->table->reginfo.lock_type,
perhaps you should fix what you've added ? Something like

-    if (tables->lock_type != TL_UNLOCK && ! thd->locked_tables)
+    if (tables->lock_type != TL_UNLOCK && ! thd->locked_tables &&
+        tables->table->s->tmp_table == NO_TMP_TABLE)

The intention of "NO_TMP_TABLE" check was to "skip lock_type update
for temporary tables", but apparently it was placed too late.
       
> === modified file 'sql/sql_base.cc'
> --- a/sql/sql_base.cc	2008-11-27 15:03:13 +0000
> +++ b/sql/sql_base.cc	2008-12-17 11:38:12 +0000
> @@ -1111,6 +1111,27 @@ static void mark_temp_tables_as_free_for
>        */
>        if (table->child_l || table->parent)
>          detach_merge_children(table, TRUE);
> +      /*
> +        Reset temporary table lock type to it's default value (TL_WRITE).
> +
> +        Statements such as INSERT INTO .. SELECT FROM tmp, CREATE TABLE
> +        .. SELECT FROM tmp and UPDATE may under some circumstances modify
> +        the lock type of the tables participating in the statement. This
> +        isn't a problem for non-temporary tables since their lock type is
> +        reset at every open, but the same does not occur for temporary
> +        tables for historical reasons.
> +
> +        Furthermore, the lock type of temporary tables is not really that
> +        important because they can only be used by one query at a time and
> +        not even twice in a query -- a temporary table is represented by
> +        only one TABLE object. Nonetheless, it's safer from a maintenance
> +        point of view to reset the lock type of this singleton TABLE object
> +        as to not cause problems when the table is reused.
> +
> +        Even under LOCK TABLES mode its okay to reset the lock type as
> +        LOCK TABLES is allowed (but ignored) for a temporary table.
> +      */
> +      table->reginfo.lock_type= TL_WRITE;
>      }
>    }
>  }
> 
> 
> -- 
> MySQL Code Commits Mailing List
> For list archives: http://lists.mysql.com/commits
> To unsubscribe:    http://lists.mysql.com/commits?unsub=1
> 
Regards / Mit vielen Grüßen,
Sergei

-- 
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /   Sergei Golubchik <serg@stripped>
 / /|_/ / // /\ \/ /_/ / /__  Principal Software Engineer/Server Architect
/_/  /_/\_, /___/\___\_\___/  Sun Microsystems GmbH, HRB München 161028
       <___/                  Sonnenallee 1, 85551 Kirchheim-Heimstetten
Geschäftsführer: Thomas Schroeder, Wolfgang Engels, Dr. Roland Boemer
Vorsitzender des Aufsichtsrates: Martin Häring
Thread
bzr commit into mysql-5.1-bugteam branch (davi:2739) Bug#41348Davi Arnaut17 Dec
  • Re: bzr commit into mysql-5.1-bugteam branch (davi:2739) Bug#41348Sergei Golubchik6 Jan 2009
    • Re: bzr commit into mysql-5.1-bugteam branch (davi:2739) Bug#41348Davi Arnaut7 Jan 2009
      • Re: bzr commit into mysql-5.1-bugteam branch (davi:2739) Bug#41348Sergei Golubchik7 Jan 2009
        • Re: bzr commit into mysql-5.1-bugteam branch (davi:2739) Bug#41348Davi Arnaut7 Jan 2009