mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +00:00
restore some styles as before.
This commit is contained in:
@@ -102,13 +102,10 @@ local function _from_cstring(data, i)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function _dumphex(bytes)
|
local function _dumphex(bytes)
|
||||||
return strgsub(
|
return strgsub(bytes, ".",
|
||||||
bytes,
|
|
||||||
".",
|
|
||||||
function(x)
|
function(x)
|
||||||
return strformat("%02x ", strbyte(x))
|
return strformat("%02x ", strbyte(x))
|
||||||
end
|
end)
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function _compute_token(password, scramble)
|
local function _compute_token(password, scramble)
|
||||||
@@ -123,9 +120,7 @@ local function _compute_token(password, scramble)
|
|||||||
local stage3 = sha1(scramble .. stage2)
|
local stage3 = sha1(scramble .. stage2)
|
||||||
|
|
||||||
local i = 0
|
local i = 0
|
||||||
return strgsub(
|
return strgsub(stage3, ".",
|
||||||
stage3,
|
|
||||||
".",
|
|
||||||
function(x)
|
function(x)
|
||||||
i = i + 1
|
i = i + 1
|
||||||
-- ~ is xor in lua 5.3
|
-- ~ is xor in lua 5.3
|
||||||
@@ -258,7 +253,7 @@ local function _parse_err_packet(packet)
|
|||||||
local errno, pos = _get_byte2(packet, 2)
|
local errno, pos = _get_byte2(packet, 2)
|
||||||
local marker = sub(packet, pos, pos)
|
local marker = sub(packet, pos, pos)
|
||||||
local sqlstate
|
local sqlstate
|
||||||
if marker == "#" then
|
if marker == '#' then
|
||||||
-- with sqlstate
|
-- with sqlstate
|
||||||
pos = pos + 1
|
pos = pos + 1
|
||||||
sqlstate = sub(packet, pos, pos + 5 - 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 scramble = scramble1 .. scramble_part2
|
||||||
local token = _compute_token(password, scramble)
|
local token = _compute_token(password, scramble)
|
||||||
local client_flags = 260047
|
local client_flags = 260047
|
||||||
local req =
|
local req = strpack("<I4I4c24zs1z",
|
||||||
strpack(
|
|
||||||
"<I4I4c24zs1z",
|
|
||||||
client_flags,
|
client_flags,
|
||||||
self._max_packet_size,
|
self._max_packet_size,
|
||||||
strrep("\0", 24), -- TODO: add support for charset encoding
|
strrep("\0", 24), -- TODO: add support for charset encoding
|
||||||
@@ -921,7 +914,7 @@ end
|
|||||||
]]
|
]]
|
||||||
function _M.execute(self, stmt, ...)
|
function _M.execute(self, stmt, ...)
|
||||||
-- 检查参数,不能为nil
|
-- 检查参数,不能为nil
|
||||||
local p_n = select("#", ...)
|
local p_n = select('#', ...)
|
||||||
local p_v
|
local p_v
|
||||||
for i = 1, p_n do
|
for i = 1, p_n do
|
||||||
p_v = select(i, ...)
|
p_v = select(i, ...)
|
||||||
@@ -970,19 +963,19 @@ function _M.server_ver(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local escape_map = {
|
local escape_map = {
|
||||||
["\0"] = "\\0",
|
['\0'] = "\\0",
|
||||||
["\b"] = "\\b",
|
['\b'] = "\\b",
|
||||||
["\n"] = "\\n",
|
['\n'] = "\\n",
|
||||||
["\r"] = "\\r",
|
['\r'] = "\\r",
|
||||||
["\t"] = "\\t",
|
['\t'] = "\\t",
|
||||||
["\26"] = "\\Z",
|
['\26'] = "\\Z",
|
||||||
["\\"] = "\\\\",
|
['\\'] = "\\\\",
|
||||||
["'"] = "\\'",
|
["'"] = "\\'",
|
||||||
['"'] = '\\"'
|
['"'] = '\\"',
|
||||||
}
|
}
|
||||||
|
|
||||||
function _M.quote_sql_str( str)
|
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
|
end
|
||||||
|
|
||||||
function _M.set_compact_arrays(self, value)
|
function _M.set_compact_arrays(self, value)
|
||||||
|
|||||||
Reference in New Issue
Block a user