From d7ba6154e3cb8490938eeaa6d28c3ede53d6bb39 Mon Sep 17 00:00:00 2001 From: findstr Date: Sat, 30 Sep 2017 12:31:13 +0800 Subject: [PATCH] modify mysql for socketdispatch --- lualib/mysql.lua | 8 ++++---- test/test.lua | 3 ++- test/testmysql.lua | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lualib/mysql.lua b/lualib/mysql.lua index d4b6716c..14f77835 100644 --- a/lualib/mysql.lua +++ b/lualib/mysql.lua @@ -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} @@ -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 diff --git a/test/test.lua b/test/test.lua index e57592d8..4022242d 100644 --- a/test/test.lua +++ b/test/test.lua @@ -13,8 +13,9 @@ local modules = { "testnetpacket", "testchannel", "testcrypt", - "testredis", "testhttp", + "testredis", + "testmysql", } local M = "" diff --git a/test/testmysql.lua b/test/testmysql.lua index 8196b4de..8e321fcf 100644 --- a/test/testmysql.lua +++ b/test/testmysql.lua @@ -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)