Commit 3c86786f authored by Yuchen Pei's avatar Yuchen Pei

MDEV-34915 Sort output of session track system variable in mysqltest

Updated the output format too.

Before:

-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- autocommit
-- ON
-- time_zone
-- SYSTEM
-- character_set_client
-- latin1
-- character_set_connection
-- latin1
-- redirect_url
--

After:

-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- autocommit: ON
-- character_set_client: latin1
-- character_set_connection: latin1
-- redirect_url:
-- time_zone: SYSTEM
parent 0a5e4a01
......@@ -7898,6 +7898,20 @@ static const char *trking_info_desc[SESSION_TRACK_END + 1]=
/**
@brief Append state change information (received through Ok packet) to the output.
@details The appended string is lines prefixed with "-- ". Only
tracking types with info sent from the server are displayed. For
each tracking type, the first line is the type name e.g.
"-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES".
The subsequent lines are the actual tracking info. When type is
SESSION_TRACK_SYSTEM_VARIABLES, the actual tracking info is a list
of name-value pairs of lines, sorted by name, e.g. if the info
received from the server is "autocommit=ON;time_zone=SYSTEM", the
corresponding string is
-- autocommit: ON
-- time_zone: SYSTEM
@param [in,out] ds Dynamic string to hold the content to be printed.
@param [in] mysql Connection handle.
*/
......@@ -7905,11 +7919,16 @@ static const char *trking_info_desc[SESSION_TRACK_END + 1]=
static void append_session_track_info(DYNAMIC_STRING *ds, MYSQL *mysql)
{
#ifndef EMBEDDED_LIBRARY
DYNAMIC_STRING ds_sort, *ds_type= NULL;
for (unsigned int type= SESSION_TRACK_BEGIN; type <= SESSION_TRACK_END; type++)
{
const char *data;
size_t data_length;
/*
Append the tracking type line, if any corresponding tracking
info is received.
*/
if (!mysql_session_track_get_first(mysql,
(enum_session_state_type) type,
&data, &data_length))
......@@ -7925,26 +7944,56 @@ static void append_session_track_info(DYNAMIC_STRING *ds, MYSQL *mysql)
DBUG_ASSERT(0);
dynstr_append_mem(ds, STRING_WITH_LEN("Tracker???\n"));
}
dynstr_append_mem(ds, STRING_WITH_LEN("-- "));
dynstr_append_mem(ds, data, data_length);
}
else
continue;
/*
The remaining of this function: format and append the actual
tracking info.
*/
if (type == SESSION_TRACK_SYSTEM_VARIABLES)
{
/* Prepare a string to be sorted before being appended. */
if (init_dynamic_string(&ds_sort, "", 1024, 1024))
die("Out of memory");
ds_type= &ds_sort;
}
else
ds_type= ds;
/* Append the first piece of info */
dynstr_append_mem(ds_type, STRING_WITH_LEN("-- "));
dynstr_append_mem(ds_type, data, data_length);
/* Whether we are appending the value of a variable */
bool appending_value= type == SESSION_TRACK_SYSTEM_VARIABLES;
/* Append remaining pieces */
while (!mysql_session_track_get_next(mysql,
(enum_session_state_type) type,
&data, &data_length))
{
dynstr_append_mem(ds, STRING_WITH_LEN("\n-- "));
if (appending_value)
dynstr_append_mem(ds_type, STRING_WITH_LEN(": "));
else
dynstr_append_mem(ds_type, STRING_WITH_LEN("\n-- "));
appending_value= !appending_value && type == SESSION_TRACK_SYSTEM_VARIABLES;
if (data == NULL)
{
DBUG_ASSERT(data_length == 0);
dynstr_append_mem(ds, STRING_WITH_LEN("<NULL>"));
dynstr_append_mem(ds_type, STRING_WITH_LEN("<NULL>"));
}
else
dynstr_append_mem(ds, data, data_length);
dynstr_append_mem(ds_type, data, data_length);
}
DBUG_ASSERT(!appending_value);
if (type == SESSION_TRACK_SYSTEM_VARIABLES)
{
dynstr_append_mem(ds_type, STRING_WITH_LEN("\n"));
dynstr_append_sorted(ds, ds_type, false);
dynstr_append_mem(ds, STRING_WITH_LEN("\n"));
dynstr_free(&ds_sort);
}
dynstr_append_mem(ds, STRING_WITH_LEN("\n\n"));
else
dynstr_append_mem(ds, STRING_WITH_LEN("\n\n"));
}
#endif /* EMBEDDED_LIBRARY */
}
......@@ -12018,7 +12067,8 @@ void replace_dynstr_append_uint(DYNAMIC_STRING *ds, uint val)
/*
Build a list of pointer to each line in ds_input, sort
the list and use the sorted list to append the strings
sorted to the output ds
sorted to the output ds. The string ds_input needs to
end with a newline.
SYNOPSIS
dynstr_append_sorted()
......
......@@ -6,26 +6,22 @@ SET @@session.session_track_system_variables='character_set_connection';
# tracking info on
SET NAMES 'utf8';
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- character_set_connection
-- utf8
-- character_set_connection: utf8
SET NAMES 'big5';
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- character_set_connection
-- big5
-- character_set_connection: big5
# tracking info on once
SET NAMES 'utf8';
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- character_set_connection
-- utf8
-- character_set_connection: utf8
SET NAMES 'big5';
# tracking info on
SET NAMES 'utf8';
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- character_set_connection
-- utf8
-- character_set_connection: utf8
# tracking info off once
SET NAMES 'big5';
......@@ -37,8 +33,7 @@ set @save_optimizer_switch=@@optimizer_switch;
SET @@session.session_track_system_variables='optimizer_switch';
set optimizer_switch='index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off';
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- optimizer_switch
-- index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off
-- optimizer_switch: index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off
Warnings:
Warning 1681 'engine_condition_pushdown=on' is deprecated and will be removed in a future release
......@@ -71,13 +66,11 @@ ERROR HY000: Unknown system variable 'a'
connect con,localhost,root,,test;
SET NAMES 'utf8';
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- character_set_connection
-- utf8
-- character_set_connection: utf8
SET NAMES 'big5';
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- character_set_connection
-- big5
-- character_set_connection: big5
select @@session_track_system_variables;
@@session_track_system_variables
......
......@@ -5,31 +5,26 @@ SET gtid_seq_no=1000;
SET @@session.session_track_system_variables='last_gtid';
create table t1 (a int) engine=innodb;
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- last_gtid
-- 0-1-1000
-- last_gtid: 0-1-1000
select @@last_gtid;
@@last_gtid
0-1-1000
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- last_gtid
-- 0-1-1000
-- last_gtid: 0-1-1000
insert into t1 values (1);
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- last_gtid
-- 0-1-1001
-- last_gtid: 0-1-1001
select @@last_gtid;
@@last_gtid
0-1-1001
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- last_gtid
-- 0-1-1001
-- last_gtid: 0-1-1001
drop table t1;
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- last_gtid
-- 0-1-1002
-- last_gtid: 0-1-1002
reset master;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment