mirror of
https://github.com/luapower/mysql.git
synced 2025-01-01 14:00:27 +01:00
unimportant
This commit is contained in:
parent
323299b34c
commit
21ba9c41c4
@ -969,12 +969,16 @@ function mysql.note (...) mysql.log('note', ...) end
|
|||||||
|
|
||||||
function mysql.connect(opt)
|
function mysql.connect(opt)
|
||||||
|
|
||||||
|
local host = opt.host
|
||||||
|
local port = opt.port or 3306
|
||||||
|
|
||||||
mysql.note('connect', 'host=%s:%s user=%s schema=%s',
|
mysql.note('connect', 'host=%s:%s user=%s schema=%s',
|
||||||
opt.host, opt.port or 3306, opt.user, opt.schema or '')
|
host, port, opt.user, opt.schema or '')
|
||||||
|
|
||||||
local tcp = opt and opt.tcp or require'sock'.tcp
|
local tcp = opt and opt.tcp or require'sock'.tcp
|
||||||
local tcp = check_io(self, tcp())
|
tcp = check_io(self, tcp())
|
||||||
local self = setmetatable({tcp = tcp}, conn_mt)
|
|
||||||
|
local self = setmetatable({tcp = tcp, host = host, port = port}, conn_mt)
|
||||||
|
|
||||||
self.max_packet_size = opt.max_packet_size or 16 * 1024 * 1024 --16 MB
|
self.max_packet_size = opt.max_packet_size or 16 * 1024 * 1024 --16 MB
|
||||||
local ok, err
|
local ok, err
|
||||||
@ -994,9 +998,7 @@ function mysql.connect(opt)
|
|||||||
assert(self.collation, 'charset and/or collation required')
|
assert(self.collation, 'charset and/or collation required')
|
||||||
end
|
end
|
||||||
|
|
||||||
self.host = opt.host
|
check_io(self, tcp:connect(host, port))
|
||||||
self.port = opt.port or 3306
|
|
||||||
check_io(self, self.tcp:connect(self.host, self.port))
|
|
||||||
|
|
||||||
local typ, buf = recv_packet(self)
|
local typ, buf = recv_packet(self)
|
||||||
if typ == 'ERR' then
|
if typ == 'ERR' then
|
||||||
|
Loading…
Reference in New Issue
Block a user