• Dmitry Lenev's avatar
    Fix for bug #11762012 - "54553: INNODB ASSERTS IN · 861291f1
    Dmitry Lenev authored
    HA_INNOBASE::UPDATE_ROW, TEMPORARY TABLE, TABLE LOCK".
    
    Attempt to update an InnoDB temporary table under LOCK TABLES
    led to assertion failure in both debug and production builds
    if this temporary table was explicitly locked for READ. The 
    same scenario works fine for MyISAM temporary tables.
    
    The assertion failure was caused by discrepancy between lock 
    that was requested on the rows of temporary table at LOCK TABLES
    time and by update operation. Since SQL-layer requested a 
    read-lock at LOCK TABLES time InnoDB engine assumed that upcoming
    statements which are going to be executed under LOCK TABLES will 
    only read table and therefore should acquire only S-lock.
    An update operation broken this assumption by requesting X-lock.
    
    Possible approaches to fixing this problem are:
    
    1) Skip locking of temporary tables as locking doesn't make any
       sense for connection-local objects.
    2) Prohibit changing of temporary table locked by LOCK TABLES ... 
       READ.
    
    Unfortunately both of these approaches have drawbacks which make 
    them unviable for stable versions of server.
    
    So this patch takes another approach and changes code in such way
    that LOCK TABLES for a temporary table will always request write
    lock. In 5.1 version of this patch switch from read lock to write
    lock is done inside of InnoDBs handler methods as doing it on 
    SQL-layer causes compatibility troubles with FLUSH TABLES WITH
    READ LOCK.
    
    mysql-test/suite/innodb/r/innodb_mysql.result:
      Added test for bug #11762012 - "54553: INNODB ASSERTS IN 
      HA_INNOBASE::UPDATE_ROW, TEMPORARY TABLE, TABLE LOCK".
    mysql-test/suite/innodb/t/innodb_mysql.test:
      Added test for bug #11762012 - "54553: INNODB ASSERTS IN 
      HA_INNOBASE::UPDATE_ROW, TEMPORARY TABLE, TABLE LOCK".
    mysql-test/suite/innodb_plugin/r/innodb_mysql.result:
      Added test for bug #11762012 - "54553: INNODB ASSERTS IN 
      HA_INNOBASE::UPDATE_ROW, TEMPORARY TABLE, TABLE LOCK".
    mysql-test/suite/innodb_plugin/t/innodb_mysql.test:
      Added test for bug #11762012 - "54553: INNODB ASSERTS IN 
      HA_INNOBASE::UPDATE_ROW, TEMPORARY TABLE, TABLE LOCK".
    storage/innobase/handler/ha_innodb.cc:
      Assume that a temporary table locked by LOCK TABLES can be updated
      even if it was only locked for read and therefore an X-lock should 
      be always requested for such tables.
    storage/innodb_plugin/handler/ha_innodb.cc:
      Assume that a temporary table locked by LOCK TABLES can be updated
      even if it was only locked for read and therefore an X-lock should 
      be always requested for such tables.
    861291f1
innodb_mysql.result 67.2 KB