• Ingo Struewing's avatar
    Bug#37958 - test main.plugin crash on Mac OS X when selecting from EXAMPLE engine. · acaf211d
    Ingo Struewing authored
    This patch contains fixes for two problems:
    
    1. As originally reported, the server crashed on Mac OS X when trying to access
       an EXAMPLE table after the EXAMPLE plugin was installed.
    
       It turned out that the dynamically loaded EXAMPLE plugin called the
       function hash_earch() from a Mac OS X system library, instead of
       hash_earch() from MySQL's mysys library. Makefile.am in storage/example
       does not include libmysys. So the Mac OS X linker arranged the hash_search()
       function to be linked to the system library when the shared object is
       loaded.
    
       One possible solution would be to include libmysys into the linkage of
       dynamic plugins. But then we must have a libmysys.so, which must be
       used by the server too. This could have a minimal performance impact,
       but foremost the change seems to bee too risky at the current state of
       MySQL 5.1.
    
       The selected solution is to rename MySQL's hash_search() to my_hash_search()
       like it has been done before with hash_insert() and hash_reset().
    
       Since this is the third time, we need to rename a hash_*() function,
       I did renamed all hash_*() functions to my_hash_*().
    
       To avoid changing a zillion calls to these functions, and announcing
       this to hundreds of developers, I added defines that map the old names
       to the new names.
    
       This change is in hash.h and hash.c.
    
    2. The other problem was improper implementation of the handlerton-to-plugin
       mapping. We use a fixed-size array to hold a plugin reference for each
       handlerton. On every install of a handler plugin, we allocated a new slot
       of the array. On uninstall we did not free it. After some uninstall/install
       cycles the array overflowed. We did not check for overflow.
    
       One fix is to check for overflow to stop the crashes.
    
       Another fix is to free the array slot at uninstall and search for a free slot
       at plugin install.
    
       This change is in handler.cc.
    acaf211d
handler.cc 135 KB