Skip to content

Commit

Permalink
MDEV-34305 Redundant truncation errors/warnings with optimizer_trace …
Browse files Browse the repository at this point in the history
…enabled

my_like_range*() can create longer keys than Field::char_length().
This caused warnings during print_range().

Fix:

Suppressing warnings in print_range().
  • Loading branch information
abarkov committed Jul 8, 2024
1 parent df35072 commit d1e5fa8
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
28 changes: 28 additions & 0 deletions mysql-test/main/opt_trace.result
Original file line number Diff line number Diff line change
Expand Up @@ -9280,5 +9280,33 @@ select QUERY, LENGTH(trace)>1 from information_schema.optimizer_trace;
QUERY LENGTH(trace)>1
insert into t2 select * from t1 where a<= b and a>4 1
drop table t1, t2;
#
# MDEV-34305 Redundant truncation errors/warnings with optimizer_trace enabled
#
SET @@optimizer_trace='enabled=on';
CREATE TABLE t1 (
a CHAR(2) NOT NULL PRIMARY KEY,
b VARCHAR(20) NOT NULL,
KEY (b)
) CHARSET=utf8mb4;
CREATE TABLE t2 (
a CHAR(2) NOT NULL PRIMARY KEY,
b VARCHAR(20) NOT NULL,
KEY (b)
) CHARSET=utf8mb4;
INSERT INTO t1 VALUES
('AB','MySQLAB'),
('JA','Sun Microsystems'),
('MS','Microsoft'),
('IB','IBM- Inc.'),
('GO','Google Inc.');
INSERT IGNORE INTO t2 VALUES
('AB','Sweden'),
('JA','USA'),
('MS','United States'),
('IB','North America'),
('GO','South America');
UPDATE t1,t2 SET t1.b=UPPER(t1.b) WHERE t1.b LIKE 'Unknown%';
DROP TABLE t1, t2;
# End of 10.5 tests
set optimizer_trace='enabled=off';
35 changes: 35 additions & 0 deletions mysql-test/main/opt_trace.test
Original file line number Diff line number Diff line change
Expand Up @@ -971,5 +971,40 @@ select QUERY, LENGTH(trace)>1 from information_schema.optimizer_trace;

drop table t1, t2;

--echo #
--echo # MDEV-34305 Redundant truncation errors/warnings with optimizer_trace enabled
--echo #

SET @@optimizer_trace='enabled=on';

CREATE TABLE t1 (
a CHAR(2) NOT NULL PRIMARY KEY,
b VARCHAR(20) NOT NULL,
KEY (b)
) CHARSET=utf8mb4;

CREATE TABLE t2 (
a CHAR(2) NOT NULL PRIMARY KEY,
b VARCHAR(20) NOT NULL,
KEY (b)
) CHARSET=utf8mb4;

INSERT INTO t1 VALUES
('AB','MySQLAB'),
('JA','Sun Microsystems'),
('MS','Microsoft'),
('IB','IBM- Inc.'),
('GO','Google Inc.');

INSERT IGNORE INTO t2 VALUES
('AB','Sweden'),
('JA','USA'),
('MS','United States'),
('IB','North America'),
('GO','South America');

UPDATE t1,t2 SET t1.b=UPPER(t1.b) WHERE t1.b LIKE 'Unknown%';
DROP TABLE t1, t2;

--echo # End of 10.5 tests
set optimizer_trace='enabled=off';
1 change: 1 addition & 0 deletions sql/opt_range.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16453,6 +16453,7 @@ static
void print_range(String *out, const KEY_PART_INFO *key_part,
KEY_MULTI_RANGE *range, uint n_key_parts)
{
Check_level_instant_set check_field(current_thd, CHECK_FIELD_IGNORE);
uint flag= range->range_flag;
String key_name;
key_name.set_charset(system_charset_info);
Expand Down

0 comments on commit d1e5fa8

Please sign in to comment.