Fix GH-282: Mysql's fetch_row() is broken

Fix both MySQL and PostgreSQL drivers to return an error when
fetch_row() is called after retrieving all rows in the result set.
This commit is contained in:
Alexey Kopytov
2018-12-16 17:21:39 +03:00
parent bb8c3b04c5
commit b017a998ef
5 changed files with 56 additions and 2 deletions

View File

@ -181,9 +181,11 @@ EOF
sysbench $SB_ARGS run
cat <<EOF
########################################################################
# Multiple connections test
########################################################################
EOF
cat >$CRAMTMP/api_sql.lua <<EOF
function thread_init()
drv = sysbench.sql.driver()
@ -209,9 +211,11 @@ EOF
sysbench $SB_ARGS run
cat <<EOF
########################################################################
# Incorrect bulk API usage
########################################################################
EOF
cat >$CRAMTMP/api_sql.lua <<EOF
c = sysbench.sql.driver():connect()
c:query("CREATE TABLE t1(a INT)")
@ -226,9 +230,11 @@ EOF
sysbench $SB_ARGS
cat <<EOF
########################################################################
# query_row() with an empty result set
########################################################################
EOF
cat >$CRAMTMP/api_sql.lua <<EOF
c = sysbench.sql.driver():connect()
c:query("CREATE TABLE t1(a INT)")
@ -237,3 +243,21 @@ c:query("DROP TABLE t1")
EOF
sysbench $SB_ARGS
cat <<EOF
########################################################################
# GH-282: Mysql's fetch_row() is broken
########################################################################
EOF
cat >$CRAMTMP/api_sql.lua <<EOF
connection = sysbench.sql.driver():connect()
rows = connection:query("select 1 union select 2")
r = rows:fetch_row();
while ( r ) do
print( r[ 1 ] )
r = rows:fetch_row()
end
EOF
sysbench $SB_ARGS