Skip to content

Commit 01341eb

Browse files
committed
Properly update statement row_num for asynchronous result
Without this change row_num variable used by $sth->rows() method was not properly updated when $sth->fetch was called directly without calling $sth->mariadb_async_result() method.
1 parent 30b33cf commit 01341eb

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

MariaDB.xs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,6 @@ mariadb_async_result(sth)
273273
if (retval == (my_ulonglong)-1)
274274
XSRETURN_UNDEF;
275275

276-
imp_sth->row_num = retval;
277-
278276
if (retval == 0)
279277
XSRETURN_PV("0E0");
280278

dbdimp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6539,6 +6539,8 @@ my_ulonglong mariadb_db_async_result(SV* h, MYSQL_RES** resp)
65396539
D_imp_sth(h);
65406540
D_imp_dbh_from_sth;
65416541

6542+
imp_sth->row_num = retval;
6543+
65426544
if(! *resp) {
65436545
imp_sth->insertid = dbh->insertid;
65446546
if(! mysql_more_results(svsock))

t/87async.t

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ my $dbh = DbiTestConnect($test_dsn, $test_user, $test_password,
1616
if ($dbh->{mariadb_serverversion} < 50012) {
1717
plan skip_all => "Servers < 5.0.12 do not support SLEEP()";
1818
}
19-
plan tests => 92;
19+
plan tests => 96;
2020

2121
is $dbh->get_info($GetInfoType{'SQL_ASYNC_MODE'}), 2; # statement-level async
2222
is $dbh->get_info($GetInfoType{'SQL_MAX_ASYNC_CONCURRENT_STATEMENTS'}), 1;
@@ -214,22 +214,26 @@ $sth->finish;
214214
$sth->execute(1);
215215
$row = $sth->fetch;
216216
is_deeply $row, [1, 1, 2, 3];
217+
is $sth->rows, 1;
217218
$sth->finish;
218219

219220
$sth->execute(1);
220221
$row = $sth->fetchrow_arrayref;
221222
is_deeply $row, [1, 1, 2, 3];
223+
is $sth->rows, 1;
222224
$sth->finish;
223225

224226
$sth->execute(1);
225227
my @row = $sth->fetchrow_array;
226228
is_deeply \@row, [1, 1, 2, 3];
229+
is $sth->rows, 1;
227230
$sth->finish;
228231

229232
$sth->execute(1);
230233
$row = $sth->fetchrow_hashref;
231234
cmp_bag [ keys %$row ], [qw/1 value0 value1 value2/];
232235
cmp_bag [ values %$row ], [1, 1, 2, 3];
236+
is $sth->rows, 1;
233237
$sth->finish;
234238

235239
undef $sth;

0 commit comments

Comments
 (0)