xiezhenye / mysql-plugin-disable-myisam

MySQL plugin to disable creating MYISAM tables.
GNU General Public License v2.0
25 stars 7 forks source link

Plugin not work on mariadb #7

Open lefoyer opened 9 years ago

lefoyer commented 9 years ago

I am compile and include plugin

# cat 009-disable-myisam.cnf
[mariadb]
plugin-load-add=disable_myisam.so

But mariadb in log write:

[ERROR] Can't open shared library '/usr/lib/mysql/plugin/disable_myisam.so' (errno: 0, undefined symbol: _ZN9ha_myisam5cloneEPKcP11st_mem_root)
[ERROR] Couldn't load plugins from 'disable_myisam.so'.

I am find:

This happens because in MariaDB statically linked plugins don't export all their symbols. This helps to avoid name clashes with dynamically oaded plugins (like, when InnoDB is loaded and XtraDB is compiled in). Unlike MySQL we have a lot more of community developed storage engines, and we have to take these issues seriously.

Because of that, the symbol _ZN9ha_myisam5cloneEPKcP11st_mem_root is local in MariaDB, and your plugin doesn't see it. In MySQL this symbol is global.

I'll see if I can remove this.

Alternatively, you can try to link your plugin explicitly with libmyisam.a

libmyisam.a in storage/myisam folder

What need add to CMakeList.txt for compile disable_myisam static linked with libmyisam.a.

lefoyer commented 9 years ago

find work varint first add 'TARGET_LINK_LIBRARIES(disablemyisam myisam)' to end you CMakeList.txt next change instruction to

cp -r src /path/to/mysql-src/plugin/disable_myisam
cd /path/to/mysql-src
sed -i 's/SET(MYISAM_SOURCES/ADD_DEFINITIONS( -fPIC )\n\nSET(MYISAM_SOURCES/' storage/myisam/CMakeLists.txt
cmake . -DBUILD_CONFIG=mysql_release
cd storage/myisam
make
cd ../../
cd plugin/disable_myisam
make
make install
qubedynamics commented 8 years ago

I use this plugin with mariadb-5.5.49, but I am unable to compile it. I see following error on cmake.

-- Looking for event.h - not found CMake Error at CMakeLists.txt:490 (TARGET_LINK_LIBRARIES): Attempt to add link library "myisam" to target "disablemyisam" which is not built in this directory.

Please help, thanks.

qubedynamics commented 8 years ago

And gets following error when I follow https://github.com/xiezhenye/mysql-plugin-disable-myisam

[ 94%] Building CXX object plugin/disable_myisam/CMakeFiles/disablemyisam.dir/disable_myisam.cc.o In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_tree.h:62, from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/set:60, from /opt/src/mariadb-5.5.49/plugin/disable_myisam/disable_myisam.cc:23: /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h:232:56: error: macro "min" passed 3 arguments, but takes just 2 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h:253:56: error: macro "max" passed 3 arguments, but takes just 2 In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_tree.h:62, from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/set:60, from /opt/src/mariadb-5.5.49/plugin/disable_myisam/disable_myisam.cc:23: /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h:186: error: expected unqualified-id before ‘const’ /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h:186: error: expected ‘)’ before ‘const’ /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h:186: error: expected ‘)’ before ‘const’ /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h:186: error: expected initializer before ‘const’ /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h:209: error: expected unqualified-id before ‘const’ /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h:209: error: expected ‘)’ before ‘const’ /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h:209: error: expected ‘)’ before ‘const’ /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h:209: error: expected initializer before ‘const’ /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h:232: error: ‘std::min’ declared as an ‘inline’ variable /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h:232: error: template declaration of ‘const _Tp& std::min’ /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h:235: error: expected primary-expression before ‘if’ /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h:235: error: expected ‘}’ before ‘if’ /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h:237: error: expected unqualified-id before ‘return’ /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h:253: error: ‘max’ declared as an ‘inline’ variable /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h:253: error: template declaration of ‘const _Tp& max’ /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h:256: error: expected primary-expression before ‘if’ /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h:256: error: expected ‘}’ before ‘if’ /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h:258: error: expected unqualified-id before ‘return’ /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h:259: error: expected declaration before ‘}’ token make[2]: * [plugin/disable_myisam/CMakeFiles/disablemyisam.dir/disable_myisam.cc.o] Error 1 make[1]: * [plugin/disable_myisam/CMakeFiles/disablemyisam.dir/all] Error 2 make: *\ [all] Error 2

xiezhenye commented 8 years ago

I've tried append 'TARGET_LINK_LIBRARIES(disablemyisam myisam)' to CMakeList.txt It works with Mariadb 10