• Dmitry Lenev's avatar
    Follow-up for the fix for bug #46947 "Embedded SELECT without · 705b98df
    Dmitry Lenev authored
    FOR UPDATE is causing a lock".
     
    This patch tries to address problems which were exposed 
    during backporting of original patch to 5.1 tree.
     
    - It ensures that we don't change locking behavior of simple
      SELECT statements on InnoDB tables when they are executed
      under LOCK TABLES ... READ and with @@innodb_table_locks=0.
      Also we no longer pass TL_READ_DEFAULT/TL_WRITE_DEFAULT 
      lock types, which are supposed to be parser-only, to 
      handler::start_stmt() method.
    - It makes check_/no_concurrent_insert.inc auxiliary scripts 
      more robust against changes in test cases that use them
      and also ensures that they don't unnecessarily change 
      environment of caller.
    
    mysql-test/include/check_concurrent_insert.inc:
      Reset DEBUG_SYNC facility before and after using it in
      auxiliary script. This makes this script more robust against
      changes in test cases calling it. It also ensures that script
      does not unnecessarily change environment of caller.
    mysql-test/include/check_no_concurrent_insert.inc:
      Reset DEBUG_SYNC facility before and after using it in
      auxiliary script. This makes this script more robust against
      changes in test cases calling it. It also ensures that script
      does not unnecessarily change environment of caller.
    mysql-test/r/innodb-lock.result:
      Added coverage for LOCK TABLES ... READ behavior in
      @@innodb_table_locks = 0 mode. This test also checks
      that an appropriate type of lock is passed to
      handler::start_stmt() method.
    mysql-test/t/innodb-lock.test:
      Added coverage for LOCK TABLES ... READ behavior in
      @@innodb_table_locks = 0 mode. This test also checks
      that an appropriate type of lock is passed to
      handler::start_stmt() method.
    sql/sql_base.cc:
      Since we no longer set TL_READ as lock type for tables used  
      in simple SELECT right in the parser, in order to preserve  
      behavior for such statements on InnoDB tables when in  
      LOCK TABLES mode with @innodb_table_locks = 0,  
      check_lock_and_start_stmt() had to be changed to convert  
      TL_READ_DEFAULT to an appropriate type of read lock before  
      passing it to handler::start_stmt() method.  
      We do similar thing for TL_WRITE_DEFAULT as this lock type  
      is also supposed to be parser-only type.  
      As consequence read_lock_type_for_table() had to be  
      adjusted to behave properly when it is called from  
      check_lock_and_start_stmt() in prelocked mode.
    705b98df
check_no_concurrent_insert.inc 2.06 KB