1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-31721: Cursor protocol increases the counter of "Empty_queries" for select

Problem:
  Empty queries are incremented if no rows are sent to the client in the
  EXECUTE phase of select query. With cursor protocol, rows are not sent
  during EXECUTE phase; they are sent later in FETCH phase. Hence,
  queries executed with cursor protocol are always falsely treated as
  empty in EXECUTE phase.

Fix:
  For cursor protocol, empty queries are now counted during the FETCH
  phase. This ensures counter correctly reflects whether any rows were
  actually sent to the client.

Tests included in `mysql-test/main/show.test`.
This commit is contained in:
Raghunandan Bhat
2025-06-24 12:59:16 +05:30
committed by Raghunandan Bhat
parent 7ab205b009
commit 2c7cea28da
8 changed files with 154 additions and 67 deletions

View File

@@ -56,6 +56,7 @@
#include "sql_test.h" // mysql_print_status
#include "sql_select.h" // handle_select, mysql_select,
// mysql_explain_union
#include "sql_cursor.h" // Select_materialzie
#include "sql_load.h" // mysql_load
#include "sql_servers.h" // create_servers, alter_servers,
// drop_servers, servers_reload
@@ -6443,7 +6444,7 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables)
}
}
/* Count number of empty select queries */
if (!thd->get_sent_row_count() && !res)
if (!thd->is_cursor_execution() && !thd->get_sent_row_count() && !res)
status_var_increment(thd->status_var.empty_queries);
else
status_var_add(thd->status_var.rows_sent, thd->get_sent_row_count());