lua-resty-mysql icon indicating copy to clipboard operation
lua-resty-mysql copied to clipboard

64bit bigint fully supported?

Open coollofty opened this issue 9 years ago • 1 comments

local function _get_byte8(data, i) local a, b, c, d, e, f, g, h = strbyte(data, i, i + 7)

-- XXX workaround for the lack of 64-bit support in bitop:
local lo = bor(a, lshift(b, 8), lshift(c, 16), lshift(d, 24))
local hi = bor(e, lshift(f, 8), lshift(g, 16), lshift(h, 24))
return lo + hi * 4294967296, i + 8

end

current resty.mysql code is above when read 8byte integer. but LuaJIT use a boxed int64 for 64bit ineger support, so the "lo + hi * 4294967296" upper is 2^53, exceed will lost some bits

coollofty avatar Sep 14 '16 06:09 coollofty

@coollofty Yeah that piece of code was written when bitop had no support for 64-bit integers (like in LuaJIT 2.0). You're welcome to submit a patch for LuaJIT 2.1 (we still need backward compatibility with LuaJIT 2.0 though). Thanks!

agentzh avatar Sep 14 '16 18:09 agentzh