Skip to content

Commit 6e5b0b1

Browse files
committed
Properly update row_num in mariadb_st_more_results()
For statements without result set use mysql_affected_rows() function and for statements with result set use mysql_num_rows() function.
1 parent 01341eb commit 6e5b0b1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

dbdimp.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3778,6 +3778,7 @@ mariadb_st_prepare_sv(
37783778
imp_sth->done_desc = FALSE;
37793779
imp_sth->result = NULL;
37803780
imp_sth->currow = 0;
3781+
imp_sth->row_num = 0;
37813782

37823783
if (DBIc_TRACE_LEVEL(imp_xxh) >= 2)
37833784
PerlIO_printf(DBIc_LOGPIO(imp_xxh),
@@ -4127,6 +4128,9 @@ bool mariadb_st_more_results(SV* sth, imp_sth_t* imp_sth)
41274128
imp_sth->result= NULL;
41284129
}
41294130

4131+
imp_sth->currow = 0;
4132+
imp_sth->row_num = 0;
4133+
41304134
if (DBIc_ACTIVE(imp_sth))
41314135
DBIc_ACTIVE_off(imp_sth);
41324136

@@ -4169,10 +4173,10 @@ bool mariadb_st_more_results(SV* sth, imp_sth_t* imp_sth)
41694173
return FALSE;
41704174
}
41714175

4172-
imp_sth->row_num= mysql_affected_rows(imp_dbh->pmysql);
4173-
41744176
if (imp_sth->result == NULL)
41754177
{
4178+
imp_sth->row_num = mysql_affected_rows(imp_dbh->pmysql);
4179+
41764180
imp_dbh->insertid = imp_sth->insertid = mysql_insert_id(imp_dbh->pmysql);
41774181
/* No "real" rowset*/
41784182
DBIS->set_attr_k(sth, sv_2mortal(newSVpvs("NUM_OF_FIELDS")), 0,
@@ -4182,8 +4186,7 @@ bool mariadb_st_more_results(SV* sth, imp_sth_t* imp_sth)
41824186
else
41834187
{
41844188
/* We have a new rowset */
4185-
imp_sth->currow=0;
4186-
4189+
imp_sth->row_num = mysql_num_rows(imp_sth->result);
41874190

41884191
/* delete cached handle attributes */
41894192
/* XXX should be driven by a list to ease maintenance */

0 commit comments

Comments
 (0)