From 76c4901733a7745097a49db0ed20383a4fa69208 Mon Sep 17 00:00:00 2001 From: Cosmin Apreuetsei Date: Thu, 6 Nov 2014 19:28:10 +0200 Subject: [PATCH] prevent loading libmariadb if not needed --- mysql.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mysql.lua b/mysql.lua index e0b39ec..c03e164 100644 --- a/mysql.lua +++ b/mysql.lua @@ -8,9 +8,16 @@ local ffi = require'ffi' local bit = require'bit' 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') -local C = assert((myok and myC) or (maok and maC), 'mysql or mariadb client library not found') + +--find a libmysql implementation +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} --we compare NULL pointers against NULL instead of nil for compatibility with luaffi.