From: Remi Gacogne Date: Mon, 31 Aug 2020 08:25:04 +0000 (+0200) Subject: auth: Handle the extra single-row result set of MySQL stored procedures X-Git-Tag: rec-4.5.0-alpha0~29^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F9423%2Fhead;p=thirdparty%2Fpdns.git auth: Handle the extra single-row result set of MySQL stored procedures --- diff --git a/modules/gmysqlbackend/smysql.cc b/modules/gmysqlbackend/smysql.cc index 6f2cb0dab6..d5e8199529 100644 --- a/modules/gmysqlbackend/smysql.cc +++ b/modules/gmysqlbackend/smysql.cc @@ -301,7 +301,10 @@ public: d_resnum = mysql_stmt_num_rows(d_stmt); // XXX: For some reason mysql_stmt_result_metadata returns NULL here, so we cannot // ensure row field count matches first result set. - if (d_resnum > 0) { // ignore empty result set + // We need to check the field count as stored procedure return the final values of OUT and INOUT parameters + // as an extra single-row result set following any result sets produced by the procedure itself. + // mysql_stmt_field_count() will return 0 for those. + if (mysql_stmt_field_count(d_stmt) > 0 && d_resnum > 0) { // ignore empty result set if (d_res_bind != nullptr && mysql_stmt_bind_result(d_stmt, d_res_bind) != 0) { string error(mysql_stmt_error(d_stmt)); releaseStatement();