• V Narayanan's avatar
    Bug#40675 MySQL 5.1 crash with index merge algorithm and Merge tables · e80537b7
    V Narayanan authored
                
    A Query in the MyISAM merge table was crashing 
    if the index merge algorithm was being used
    
    Index Merge optimization requires the reading of 
    multiple indexes at the same time. Reading multiple 
    indexes at once with current SE API means that we 
    need to have handler instance for each to-be-read 
    index. This is done by creating clones of the handlers 
    instances. The clone internally does a open of the handler.
    
    The open for a MERGE engine is handled in the following 
    phases
    
    1) open parent table
    2) generate list of underlying
       table
    3) attach underlying tables
    
    But the current implementation does only the first 
    phase (i.e.) open parent table.
    
    The current patch fixes this at the MERGE engine level, 
    by handling the clone operation within the MERGE engine 
    rather than in the storage engine API. It opens and 
    attaches the MyISAM tables on the MyISAM storage engine 
    interface directly within the MERGE engine. The new MyISAM 
    table instances, as well as the MERGE clone itself, are not 
    visible in the table cache. This is not a problem because
    all locking is handled by the original MERGE table from which
    this is cloned of.
    
    mysql-test/r/merge.result:
      updated the result file to reflect the new tests
      added to test the fix
    mysql-test/t/merge.test:
      Added new tests to verify that the index merge
      algorithm does not crash in the merge engine.
    storage/myisammrg/ha_myisammrg.cc:
      Implement the clone method, that handles
      
      1) Cloning the handler
      2) Opening underlying MYISAM child tables
      3) Copies the state of the original handler and the children
         into the cloned instances
      4) Sets the appropriate flags
    storage/myisammrg/ha_myisammrg.h:
      Added a flag that is set to indicate that the current 
      instance is cloned. Also added the prototype or the clone 
      method.
    storage/myisammrg/myrg_open.c:
      Since we do now again use myrg_open() in the server
      removed the comments marking this as deadcode.
    e80537b7
ha_myisammrg.h 4.08 KB