Skip to content

Commit

Permalink
modify mysql for socketdispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
findstr committed Sep 30, 2017
1 parent 4b3e64e commit d7ba615
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lualib/mysql.lua
Original file line number Diff line number Diff line change
Expand Up @@ -751,11 +751,11 @@ local function _query_response(self, est_nrows)
badresult.err = err
badresult.errno = errno
badresult.sqlstate = sqlstate
return true, false, badresult
return false, badresult
end

if err ~= "again" then
return true, true, res
return true, res
end

local multiresultset = {res}
Expand All @@ -764,12 +764,12 @@ local function _query_response(self, est_nrows)
while err == "again" do
res, err, errno, sqlstate = read_result(self, est_nrows)
if not res then
return true, true, multiresultset
return true, multiresultset
end
multiresultset[i] = res
i = i + 1
end
return true, true, multiresultset
return true, multiresultset
end
end

Expand Down
3 changes: 2 additions & 1 deletion test/test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ local modules = {
"testnetpacket",
"testchannel",
"testcrypt",
"testredis",
"testhttp",
"testredis",
"testmysql",
}

local M = ""
Expand Down
3 changes: 2 additions & 1 deletion test/testmysql.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ local mysql = require "mysql"

return function()
local db = mysql.create {
host="192.168.2.118@3306",
host="127.0.0.1@3306",
user="root",
password="root",
}
db:connect()
local status, res = db:query("show databases;")
assert(status, res)
print("query databases:", status, res)
for _, v in pairs(res) do
print(v.Database)
Expand Down

0 comments on commit d7ba615

Please sign in to comment.