From cb4129332006356ece02293745efb8a4d1759845 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Mon, 5 Jan 2015 21:33:06 +0800 Subject: [PATCH] update mysql driver for lua 5.3 --- lualib/mysql.lua | 135 ++++++++++++++--------------------------------- 1 file changed, 39 insertions(+), 96 deletions(-) diff --git a/lualib/mysql.lua b/lualib/mysql.lua index 58843e68..f78f529b 100755 --- a/lualib/mysql.lua +++ b/lualib/mysql.lua @@ -2,27 +2,22 @@ -- Copyright (C) 2014 Chang Feng -- This file is modified version from https://github.com/openresty/lua-resty-mysql -- The license is under the BSD license. +-- Modified by Cloud Wu (remove bit32 for lua 5.3) local socketchannel = require "socketchannel" -local bit = require "bit32" local mysqlaux = require "mysqlaux.c" local crypt = require "crypt" local sub = string.sub +local strgsub = string.gsub +local strformat = string.format local strbyte = string.byte local strchar = string.char -local strfind = string.find local strrep = string.rep -local null = nil -local band = bit.band -local bxor = bit.bxor -local bor = bit.bor -local lshift = bit.lshift -local rshift = bit.rshift +local strunpack = string.unpack +local strpack = string.pack local sha1= crypt.sha1 -local concat = table.concat -local unpack = unpack local setmetatable = setmetatable local error = error local tonumber = tonumber @@ -53,105 +48,53 @@ for i = 0x01, 0x05 do -- tiny, short, long, float, double converters[i] = tonumber end --- converters[0x08] = tonumber -- long long +converters[0x08] = tonumber -- long long converters[0x09] = tonumber -- int24 converters[0x0d] = tonumber -- year converters[0xf6] = tonumber -- newdecimal local function _get_byte2(data, i) - local a, b = strbyte(data, i, i + 1) - return bor(a, lshift(b, 8)), i + 2 + return strunpack("