@@ -4089,6 +4089,19 @@ bool mariadb_st_more_results(SV* sth, imp_sth_t* imp_sth)
4089
4089
if (!SvROK (sth ) || SvTYPE (SvRV (sth )) != SVt_PVHV )
4090
4090
croak ("Expected hash array" );
4091
4091
4092
+ if (imp_sth -> use_server_side_prepare )
4093
+ {
4094
+ mariadb_dr_do_error (sth , CR_NOT_IMPLEMENTED , "Processing of multiple result set is not possible with server side prepare" , "HY000" );
4095
+ return FALSE;
4096
+ }
4097
+
4098
+ if (imp_dbh -> async_query_in_flight && imp_dbh -> async_query_in_flight != imp_sth )
4099
+ {
4100
+ mariadb_dr_do_error (sth , CR_UNKNOWN_ERROR , "Gathering async_query_in_flight results for the wrong handle" , "HY000" );
4101
+ return FALSE;
4102
+ }
4103
+ imp_dbh -> async_query_in_flight = NULL ;
4104
+
4092
4105
if (!imp_dbh -> pmysql && !mariadb_db_reconnect (sth , NULL ))
4093
4106
{
4094
4107
mariadb_dr_do_error (sth , CR_SERVER_GONE_ERROR , "MySQL server has gone away" , "HY000" );
@@ -4104,12 +4117,6 @@ bool mariadb_st_more_results(SV* sth, imp_sth_t* imp_sth)
4104
4117
return FALSE;
4105
4118
}
4106
4119
4107
- if (imp_sth -> use_server_side_prepare )
4108
- {
4109
- mariadb_dr_do_error (sth , CR_NOT_IMPLEMENTED , "Processing of multiple result set is not possible with server side prepare" , "HY000" );
4110
- return FALSE;
4111
- }
4112
-
4113
4120
/*
4114
4121
* Free cached array attributes
4115
4122
*/
@@ -4203,7 +4210,6 @@ bool mariadb_st_more_results(SV* sth, imp_sth_t* imp_sth)
4203
4210
imp_sth -> row_num = mysql_affected_rows (imp_dbh -> pmysql );
4204
4211
4205
4212
imp_dbh -> insertid = imp_sth -> insertid = mysql_insert_id (imp_dbh -> pmysql );
4206
- return TRUE;
4207
4213
}
4208
4214
else
4209
4215
{
@@ -4217,6 +4223,10 @@ bool mariadb_st_more_results(SV* sth, imp_sth_t* imp_sth)
4217
4223
4218
4224
DBIc_ACTIVE_on (imp_sth );
4219
4225
}
4226
+
4227
+ if (imp_sth -> is_async && mysql_more_results (imp_dbh -> pmysql ))
4228
+ imp_dbh -> async_query_in_flight = imp_sth ;
4229
+
4220
4230
imp_dbh -> pmysql -> net .last_errno = 0 ;
4221
4231
return TRUE;
4222
4232
}
@@ -6475,7 +6485,7 @@ my_ulonglong mariadb_db_async_result(SV* h, MYSQL_RES** resp)
6475
6485
D_imp_xxh (h );
6476
6486
imp_dbh_t * dbh ;
6477
6487
MYSQL * svsock = NULL ;
6478
- MYSQL_RES * _res ;
6488
+ MYSQL_RES * _res = NULL ;
6479
6489
my_ulonglong retval = 0 ;
6480
6490
unsigned int num_fields ;
6481
6491
int htype ;
@@ -6517,6 +6527,12 @@ my_ulonglong mariadb_db_async_result(SV* h, MYSQL_RES** resp)
6517
6527
return -1 ;
6518
6528
}
6519
6529
6530
+ if (* resp )
6531
+ {
6532
+ mysql_free_result (* resp );
6533
+ * resp = NULL ;
6534
+ }
6535
+
6520
6536
if (!mysql_read_query_result (svsock ))
6521
6537
{
6522
6538
* resp = mysql_store_result (svsock );
@@ -6561,7 +6577,15 @@ my_ulonglong mariadb_db_async_result(SV* h, MYSQL_RES** resp)
6561
6577
mysql_free_result (* resp );
6562
6578
* resp = NULL ;
6563
6579
}
6580
+
6581
+ if (mysql_more_results (svsock ))
6582
+ dbh -> async_query_in_flight = imp_xxh ;
6564
6583
} else {
6584
+ #if MYSQL_VERSION_ID < 50025
6585
+ /* Cover a protocol design error: error packet does not contain the server status.
6586
+ * Luckily, an error always aborts execution of a statement, so it is safe to turn off the flag. */
6587
+ svsock -> server_status &= ~SERVER_MORE_RESULTS_EXISTS ;
6588
+ #endif
6565
6589
mariadb_dr_do_error (h , mysql_errno (svsock ), mysql_error (svsock ),
6566
6590
mysql_sqlstate (svsock ));
6567
6591
return (my_ulonglong )- 1 ;
0 commit comments