From 06992c2bd096049e39d2819ae5e7d364310271cf Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 6 Feb 2026 00:48:22 +0100 Subject: [PATCH] Fix behaviour of fetch() without any data for MySQL too Same fix is required for MySQL as for PostgreSQL, see the previous commit message for explanation. --- src/backends/mysql/statement.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/backends/mysql/statement.cpp b/src/backends/mysql/statement.cpp index dff72dcf..261877e0 100644 --- a/src/backends/mysql/statement.cpp +++ b/src/backends/mysql/statement.cpp @@ -314,6 +314,7 @@ mysql_statement_backend::execute(int number) else { // it was not a SELECT + numberOfRows_ = 0; return ef_no_data; } } @@ -321,6 +322,13 @@ mysql_statement_backend::execute(int number) statement_backend::exec_fetch_result mysql_statement_backend::fetch(int number) { + if (numberOfRows_ == 0) + { + // There is nothing to fetch and normally we shouldn't be even called + // in this case, but don't do anything stupid if we are. + return ef_no_data; + } + // Note: This function does not actually fetch anything from anywhere // - the data was already retrieved from the server in the execute() // function, and the actual consumption of this data will take place