mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-27277 Add a warning when max_sort_length is reached
During a query execution some sorting and grouping operations on strings may be involved. System variable max_sort_length defines the maximum number of bytes to use when comparing strings during sorting/grouping. Thus, the comparable parts of strings may be less than their actual size, so the results of the query may be not sorted/grouped properly. To indicate that some comparisons were done on a truncated lengths, a new warning has been introduced with this commit.
This commit is contained in:
@@ -5853,6 +5853,13 @@ public:
|
||||
/* Handling of timeouts for commands */
|
||||
thr_timer_t query_timer;
|
||||
|
||||
/*
|
||||
Number of strings which were involved in sorting or grouping and whose
|
||||
lengths were truncated according to the max_sort_length system variable
|
||||
setting
|
||||
*/
|
||||
ulonglong num_of_strings_sorted_on_truncated_length;
|
||||
|
||||
public:
|
||||
void set_query_timer()
|
||||
{
|
||||
@@ -6053,6 +6060,23 @@ public:
|
||||
bool need_report_unit_results();
|
||||
bool report_collected_unit_results();
|
||||
bool init_collecting_unit_results();
|
||||
|
||||
/*
|
||||
Push post-execution warnings, which may be some kinds of aggregate messages
|
||||
like number of times max_sort_length was reached during sorting/grouping
|
||||
*/
|
||||
void push_final_warnings()
|
||||
{
|
||||
if (num_of_strings_sorted_on_truncated_length)
|
||||
{
|
||||
push_warning_printf(this, Sql_condition::WARN_LEVEL_WARN,
|
||||
WARN_SORTING_ON_TRUNCATED_LENGTH,
|
||||
ER_THD(this, WARN_SORTING_ON_TRUNCATED_LENGTH),
|
||||
num_of_strings_sorted_on_truncated_length,
|
||||
variables.max_sort_length);
|
||||
num_of_strings_sorted_on_truncated_length= 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user