• unknown's avatar
    A fix and a test case for Bug#12243 "MySQL Server crashes with 2 · 6861b1bf
    unknown authored
    cursors (+ commit)" and Bug#11832 "Server crash with InnoDB + Cursors"
    See comments to the changed files.
    
    
    innobase/include/read0read.h:
      - add cursor_view_t::n_mysql_tables_in_use
    innobase/read/read0read.c:
      - maintain cursor_view_t::n_mysql_tables_in_use. InnoDB
      maintains trx->n_mysql_tables_in_use to know when it can auto-commit
      a read-only statement. When this count drops to zero,
      MySQL has ended processing of such statement and InnoDB can commit.
      Cursors should not break this invariant, and should exclude the tables
      used in a cursor from the count of active tables.
      When a cursor is closed, the number of its tables is added back, 
      to ensure that close_thread_tables->unlock_external->
      ha_innobase::external_lock(F_UNLCK) won't drop the count in trx 
      below zero.
    innobase/row/row0sel.c:
      - remove the restoration of the global read view from 
      row_search_for_mysql: MySQL may call row_search_for_mysql
      more than once when fetching a row for a cursor (e.g. if there
      is a WHERE clause that filters out some rows).
    sql/ha_innodb.cc:
      - add more verbose printout for the case when we close an InnoDB
      connection without priorlly issuing a commit or rollback. The problem
      should be investigated.
    tests/mysql_client_test.c:
      - add a test case for Bug#12243 "MySQL Server crashes with 2 cursors 
      (+ commit)"
    6861b1bf
read0read.c 10.1 KB