cleanup: select ... into tests

* automatically disable ps2 and cursor protocol when the
  select statement returns no result set
* remove manual {disable|enable}_{ps2|cursor}_protocol from around
  `select ... into` in tests
* other misc collateral test cleanups

Cherry-pick from 11.8
This commit is contained in:
Sergei Golubchik 2024-12-13 11:56:31 +01:00
commit aef0468c18
80 changed files with 80 additions and 2323 deletions

View file

@ -8682,7 +8682,7 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command,
DYNAMIC_STRING ds_res_1st_execution;
my_bool ds_res_1st_execution_init = FALSE;
my_bool compare_2nd_execution = TRUE;
int query_match_ps2_re;
int query_match_ps2_re, query_match_cursor_re;
MYSQL_RES *res;
DBUG_ENTER("run_query_stmt");
DBUG_PRINT("query", ("'%-.60s'", query));
@ -8741,6 +8741,9 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command,
parameter markers.
*/
query_match_cursor_re= cursor_protocol_enabled && cn->stmt->field_count &&
match_re(&cursor_re, query);
if (cursor_protocol_enabled)
{
ps2_protocol_enabled = 0;
@ -8749,7 +8752,7 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command,
Use cursor for queries matching the filter,
else reset cursor type
*/
if (match_re(&cursor_re, query))
if (query_match_cursor_re)
{
/*
Use cursor when retrieving result
@ -8761,12 +8764,13 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command,
}
}
query_match_ps2_re = match_re(&ps2_re, query);
query_match_ps2_re = ps2_protocol_enabled && cn->stmt->field_count &&
match_re(&ps2_re, query);
/*
Execute the query first time if second execution enable
*/
if (ps2_protocol_enabled && query_match_ps2_re)
if (query_match_ps2_re)
{
if (do_stmt_execute(cn))
{
@ -8822,8 +8826,7 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command,
and keep them in a separate string for later. Cursor_protocol is used
only for queries matching the filter "cursor_re".
*/
if (cursor_protocol_enabled && match_re(&cursor_re, query) &&
!disable_warnings)
if (query_match_cursor_re && !disable_warnings)
append_warnings(&ds_execute_warnings, mysql);
if (read_stmt_results(stmt, ds, command))
@ -8835,7 +8838,7 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command,
The results of the first and second execution are compared
only if result logging is enabled
*/
if (compare_2nd_execution && ps2_protocol_enabled && query_match_ps2_re)
if (compare_2nd_execution && query_match_ps2_re)
{
if (ds->length != ds_res_1st_execution.length ||
!(memcmp(ds_res_1st_execution.str, ds->str, ds->length) == 0))