Skip to content

Commit d1e5fa8

Browse files
committed
MDEV-34305 Redundant truncation errors/warnings with optimizer_trace enabled
my_like_range*() can create longer keys than Field::char_length(). This caused warnings during print_range(). Fix: Suppressing warnings in print_range().
1 parent df35072 commit d1e5fa8

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

mysql-test/main/opt_trace.result

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9280,5 +9280,33 @@ select QUERY, LENGTH(trace)>1 from information_schema.optimizer_trace;
92809280
QUERY LENGTH(trace)>1
92819281
insert into t2 select * from t1 where a<= b and a>4 1
92829282
drop table t1, t2;
9283+
#
9284+
# MDEV-34305 Redundant truncation errors/warnings with optimizer_trace enabled
9285+
#
9286+
SET @@optimizer_trace='enabled=on';
9287+
CREATE TABLE t1 (
9288+
a CHAR(2) NOT NULL PRIMARY KEY,
9289+
b VARCHAR(20) NOT NULL,
9290+
KEY (b)
9291+
) CHARSET=utf8mb4;
9292+
CREATE TABLE t2 (
9293+
a CHAR(2) NOT NULL PRIMARY KEY,
9294+
b VARCHAR(20) NOT NULL,
9295+
KEY (b)
9296+
) CHARSET=utf8mb4;
9297+
INSERT INTO t1 VALUES
9298+
('AB','MySQLAB'),
9299+
('JA','Sun Microsystems'),
9300+
('MS','Microsoft'),
9301+
('IB','IBM- Inc.'),
9302+
('GO','Google Inc.');
9303+
INSERT IGNORE INTO t2 VALUES
9304+
('AB','Sweden'),
9305+
('JA','USA'),
9306+
('MS','United States'),
9307+
('IB','North America'),
9308+
('GO','South America');
9309+
UPDATE t1,t2 SET t1.b=UPPER(t1.b) WHERE t1.b LIKE 'Unknown%';
9310+
DROP TABLE t1, t2;
92839311
# End of 10.5 tests
92849312
set optimizer_trace='enabled=off';

mysql-test/main/opt_trace.test

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,5 +971,40 @@ select QUERY, LENGTH(trace)>1 from information_schema.optimizer_trace;
971971

972972
drop table t1, t2;
973973

974+
--echo #
975+
--echo # MDEV-34305 Redundant truncation errors/warnings with optimizer_trace enabled
976+
--echo #
977+
978+
SET @@optimizer_trace='enabled=on';
979+
980+
CREATE TABLE t1 (
981+
a CHAR(2) NOT NULL PRIMARY KEY,
982+
b VARCHAR(20) NOT NULL,
983+
KEY (b)
984+
) CHARSET=utf8mb4;
985+
986+
CREATE TABLE t2 (
987+
a CHAR(2) NOT NULL PRIMARY KEY,
988+
b VARCHAR(20) NOT NULL,
989+
KEY (b)
990+
) CHARSET=utf8mb4;
991+
992+
INSERT INTO t1 VALUES
993+
('AB','MySQLAB'),
994+
('JA','Sun Microsystems'),
995+
('MS','Microsoft'),
996+
('IB','IBM- Inc.'),
997+
('GO','Google Inc.');
998+
999+
INSERT IGNORE INTO t2 VALUES
1000+
('AB','Sweden'),
1001+
('JA','USA'),
1002+
('MS','United States'),
1003+
('IB','North America'),
1004+
('GO','South America');
1005+
1006+
UPDATE t1,t2 SET t1.b=UPPER(t1.b) WHERE t1.b LIKE 'Unknown%';
1007+
DROP TABLE t1, t2;
1008+
9741009
--echo # End of 10.5 tests
9751010
set optimizer_trace='enabled=off';

sql/opt_range.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16453,6 +16453,7 @@ static
1645316453
void print_range(String *out, const KEY_PART_INFO *key_part,
1645416454
KEY_MULTI_RANGE *range, uint n_key_parts)
1645516455
{
16456+
Check_level_instant_set check_field(current_thd, CHECK_FIELD_IGNORE);
1645616457
uint flag= range->range_flag;
1645716458
String key_name;
1645816459
key_name.set_charset(system_charset_info);

0 commit comments

Comments
 (0)