From 7b383cc537ef21485ba1d905bbd76134e377fbfe Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Fri, 23 Mar 2018 19:13:52 +0300 Subject: [PATCH] Don't fail when query_row() is called with an empty SELECT. --- src/lua/internal/sysbench.sql.lua | 2 +- tests/include/api_sql_common.sh | 15 ++++++++++++++- tests/t/api_sql_mysql.t | 1 + tests/t/api_sql_pgsql.t | 1 + 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/lua/internal/sysbench.sql.lua b/src/lua/internal/sysbench.sql.lua index 6e5f226..6f33d33 100644 --- a/src/lua/internal/sysbench.sql.lua +++ b/src/lua/internal/sysbench.sql.lua @@ -299,7 +299,7 @@ end function connection_methods.query_row(self, query) local rs = self:query(query) - if rs == nil then + if rs == nil or rs.nrows == 0 then return nil end diff --git a/tests/include/api_sql_common.sh b/tests/include/api_sql_common.sh index 6582728..6b31546 100644 --- a/tests/include/api_sql_common.sh +++ b/tests/include/api_sql_common.sh @@ -210,13 +210,26 @@ sysbench $SB_ARGS run ######################################################################## cat >$CRAMTMP/api_sql.lua <$CRAMTMP/api_sql.lua <