MDEV-35275 Unexpected WARN_SORTING_ON_TRUNCATED_LENGTH or assertion failure in diagnostics area

MDEV-27277 added warnings on truncation during sorting for SELECTs
but did not for DML operations. However, UPDATEs and DELETEs may also
perform sorting and thus produce warnings. This commit fixes that
This commit is contained in:
Oleg Smirnov 2024-10-29 21:36:09 +07:00
parent 556a40dce0
commit bf9662f6fa
4 changed files with 44 additions and 0 deletions

View File

@ -492,6 +492,27 @@ Warning 4202 30 values were longer than max_sort_length. Sorting used only the f
drop function f1;
drop view v1;
drop table t1, t2, t3;
set max_sort_length = default;
#
# MDEV-35275 Unexpected WARN_SORTING_ON_TRUNCATED_LENGTH or assertion
# failure in diagnostics area
#
create table t1 (a int, b varchar(1024));
insert into t1 values (1,repeat('x',513)), (2,repeat('y',650));
insert into t1 select * from t1 order by b limit 1;
Warnings:
Warning 4202 2 values were longer than max_sort_length. Sorting used only the first 70 bytes
update t1 set a = 3 order by b limit 1;
Warnings:
Warning 4202 3 values were longer than max_sort_length. Sorting used only the first 70 bytes
delete from t1 where a < 3 order by b;
Warnings:
Warning 4202 2 values were longer than max_sort_length. Sorting used only the first 70 bytes
# Make sure warnings from previous statements do not overflow to next ones
select a from t1;
a
3
drop table t1;
connection default;
disconnect test_con1;
disconnect test_con2;

View File

@ -282,6 +282,27 @@ drop function f1;
drop view v1;
drop table t1, t2, t3;
set max_sort_length = default;
--echo #
--echo # MDEV-35275 Unexpected WARN_SORTING_ON_TRUNCATED_LENGTH or assertion
--echo # failure in diagnostics area
--echo #
create table t1 (a int, b varchar(1024));
insert into t1 values (1,repeat('x',513)), (2,repeat('y',650));
insert into t1 select * from t1 order by b limit 1;
update t1 set a = 3 order by b limit 1;
delete from t1 where a < 3 order by b;
--echo # Make sure warnings from previous statements do not overflow to next ones
select a from t1;
drop table t1;
#
# Cleanup
#

View File

@ -1434,6 +1434,7 @@ values_loop_end:
thd->lex->current_select->leaf_tables_saved= true;
}
thd->push_final_warnings();
my_free(readbuff);
#ifndef EMBEDDED_LIBRARY
if (lock_type == TL_WRITE_DELAYED && table->expr_arena)

View File

@ -34267,6 +34267,7 @@ bool Sql_cmd_dml::execute(THD *thd)
if (res)
goto err;
thd->push_final_warnings();
res= unit->cleanup();
/* "Unprepare" this object since unit->cleanup actually unprepares */