1
0
mirror of https://github.com/luapower/mysql.git synced 2024-12-28 20:00:33 +01:00

prevent loading libmariadb if not needed

This commit is contained in:
Cosmin Apreuetsei 2014-11-06 19:28:10 +02:00
parent 30196804b4
commit 76c4901733

View File

@ -8,9 +8,16 @@
local ffi = require'ffi' local ffi = require'ffi'
local bit = require'bit' local bit = require'bit'
require'mysql_h' require'mysql_h'
local myok, myC = pcall(ffi.load, ffi.abi'win' and 'libmysql' or 'mysqlclient')
local maok, maC = pcall(ffi.load, ffi.abi'win' and 'libmariadb' or 'mariadb') --find a libmysql implementation
local C = assert((myok and myC) or (maok and maC), 'mysql or mariadb client library not found') local myok, myC, maok, maC
myok, myC = pcall(ffi.load, ffi.abi'win' and 'libmysql' or 'mysqlclient')
if not myok then
maok, maC = pcall(ffi.load, ffi.abi'win' and 'libmariadb' or 'mariadb')
end
local C = assert((myok and myC) or (maok and maC),
'mysql or mariadb client library not found')
local M = {C = C} local M = {C = C}
--we compare NULL pointers against NULL instead of nil for compatibility with luaffi. --we compare NULL pointers against NULL instead of nil for compatibility with luaffi.