Skip to content
  • Martin Hansson's avatar
    419c714e
    Bug#27289282: ACTUALLY CONSTRUCT TABLE_LIST OBJECTS · 419c714e
    Martin Hansson authored
    Mainly, C-casting of the result of a mem_root malloc or
    calloc is replaced with actually calling the
    constructor. Sometimes, however, the TABLE_LIST is part of a
    larger chunk of memory. In these cases, that practice is
    untouched and a placement-new is used instead.
    
    MyISAM code still commits the above atrocities since we
    don't want to touch it.
    
    Fortunately, most members of TABLE_LIST already have default
    initializers which keeps the constructor lithe and readable
    even without the zero-initializations.
    
    Sometimes TABLE_LIST objects are copied, and this has been
    replaced with the obvious choice of copy-construction. This
    revealed that MDL_key objects (member of MDL_request objects
    which is a member of TABLE_LIST) forbade copy-construction
    but were copied behind our backs using memcpy(). This
    copying is now made visible by enabling the copy-constructor
    and it's also possible to break in a debugger.
    
    Another hack also got uncovered: dd::enum_table_type has a
    fourth value of 0 which is invisible since it's a
    side-effect of the zeroing-out. This is probably why the
    enum explicitly starts on 1. This is fixed by adding the
    enum value INVALID_TABLE.
    
    Change-Id: Ic9d1f58dca36deba6a9be33fd5e2c2e8b3dcd49d
    419c714e
    Bug#27289282: ACTUALLY CONSTRUCT TABLE_LIST OBJECTS
    Martin Hansson authored
    Mainly, C-casting of the result of a mem_root malloc or
    calloc is replaced with actually calling the
    constructor. Sometimes, however, the TABLE_LIST is part of a
    larger chunk of memory. In these cases, that practice is
    untouched and a placement-new is used instead.
    
    MyISAM code still commits the above atrocities since we
    don't want to touch it.
    
    Fortunately, most members of TABLE_LIST already have default
    initializers which keeps the constructor lithe and readable
    even without the zero-initializations.
    
    Sometimes TABLE_LIST objects are copied, and this has been
    replaced with the obvious choice of copy-construction. This
    revealed that MDL_key objects (member of MDL_request objects
    which is a member of TABLE_LIST) forbade copy-construction
    but were copied behind our backs using memcpy(). This
    copying is now made visible by enabling the copy-constructor
    and it's also possible to break in a debugger.
    
    Another hack also got uncovered: dd::enum_table_type has a
    fourth value of 0 which is invisible since it's a
    side-effect of the zeroing-out. This is probably why the
    enum explicitly starts on 1. This is fixed by adding the
    enum value INVALID_TABLE.
    
    Change-Id: Ic9d1f58dca36deba6a9be33fd5e2c2e8b3dcd49d
Loading