restore some styles as before.

This commit is contained in:
Hanlei Qin
2019-10-29 15:29:28 +08:00
committed by 云风
parent 49c21916a2
commit 58291a2a48

View File

@@ -102,13 +102,10 @@ local function _from_cstring(data, i)
end
local function _dumphex(bytes)
return strgsub(
bytes,
".",
return strgsub(bytes, ".",
function(x)
return strformat("%02x ", strbyte(x))
end
)
end)
end
local function _compute_token(password, scramble)
@@ -123,9 +120,7 @@ local function _compute_token(password, scramble)
local stage3 = sha1(scramble .. stage2)
local i = 0
return strgsub(
stage3,
".",
return strgsub(stage3, ".",
function(x)
i = i + 1
-- ~ is xor in lua 5.3
@@ -258,7 +253,7 @@ local function _parse_err_packet(packet)
local errno, pos = _get_byte2(packet, 2)
local marker = sub(packet, pos, pos)
local sqlstate
if marker == "#" then
if marker == '#' then
-- with sqlstate
pos = pos + 1
sqlstate = sub(packet, pos, pos + 5 - 1)
@@ -413,9 +408,7 @@ local function _mysql_login(self, user, password, database, on_connect)
local scramble = scramble1 .. scramble_part2
local token = _compute_token(password, scramble)
local client_flags = 260047
local req =
strpack(
"<I4I4c24zs1z",
local req = strpack("<I4I4c24zs1z",
client_flags,
self._max_packet_size,
strrep("\0", 24), -- TODO: add support for charset encoding
@@ -921,7 +914,7 @@ end
]]
function _M.execute(self, stmt, ...)
-- 检查参数不能为nil
local p_n = select("#", ...)
local p_n = select('#', ...)
local p_v
for i = 1, p_n do
p_v = select(i, ...)
@@ -970,19 +963,19 @@ function _M.server_ver(self)
end
local escape_map = {
["\0"] = "\\0",
["\b"] = "\\b",
["\n"] = "\\n",
["\r"] = "\\r",
["\t"] = "\\t",
["\26"] = "\\Z",
["\\"] = "\\\\",
['\0'] = "\\0",
['\b'] = "\\b",
['\n'] = "\\n",
['\r'] = "\\r",
['\t'] = "\\t",
['\26'] = "\\Z",
['\\'] = "\\\\",
["'"] = "\\'",
['"'] = '\\"'
['"'] = '\\"',
}
function _M.quote_sql_str( str)
return strformat("'%s'", strgsub(str, '[\0\b\n\r\t\26\\\'"]', escape_map))
return strformat("'%s'", strgsub(str, "[\0\b\n\r\t\26\\\'\"]", escape_map))
end
function _M.set_compact_arrays(self, value)