The problem is repeatable with at least MyISAM and InnoDB.
SET @@optimizer_trace='enabled=on';
|
|
CREATE OR REPLACE TABLE t1 (
|
a CHAR(2) NOT NULL PRIMARY KEY,
|
b VARCHAR(20) NOT NULL,
|
KEY (b)
|
) ENGINE=InnoDB CHARSET=utf8mb4;
|
|
CREATE OR REPLACE TABLE t2 (
|
a CHAR(2) NOT NULL PRIMARY KEY,
|
b VARCHAR(20) NOT NULL,
|
KEY (b)
|
) ENGINE=InnoDB 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 of America'),
|
('IB','North America'),
|
('GO','South America');
|
|
UPDATE t1,t2 SET t1.b=UPPER(t1.b) WHERE t1.b LIKE 'Unknown%';
|
ERROR 1406 (22001): Data too long for column 'b' at row 1
|
The above error is not expected.
Additionally, in some versions (at least 11.3 and higher), warnings are produced in a simpler script:
SET @@optimizer_trace='enabled=on';
|
|
CREATE OR REPLACE TABLE t1 (
|
a CHAR(2) NOT NULL PRIMARY KEY,
|
b VARCHAR(20) NOT NULL,
|
KEY (b)
|
) ENGINE=InnoDB CHARSET=utf8mb4;
|
|
INSERT INTO t1 VALUES
|
('AB','MySQLAB'),
|
('JA','Sun Microsystems'),
|
('MS','Microsoft'),
|
('IB','IBM- Inc.'),
|
('GO','Google Inc.');
|
|
UPDATE t1 SET t1.b=UPPER(t1.b) WHERE t1.b LIKE 'Unknown%';
|
+---------+------+----------------------------------------+
|
| Level | Code | Message |
|
+---------+------+----------------------------------------+
|
| Warning | 1265 | Data truncated for column 'b' at row 1 |
|
| Warning | 1265 | Data truncated for column 'b' at row 1 |
|
| Warning | 1265 | Data truncated for column 'b' at row 1 |
|
| Warning | 1265 | Data truncated for column 'b' at row 1 |
|
+---------+------+----------------------------------------+
|
These warnings are not expected.
The problem seems to be in the fact that the call for like_range() in Item_func_like::get_mm_leaf() produces more characters than the size of the index.
The patch below fixes the problem, but the real patch should probably fix like_range() not to return more characters than the size of the index.
index 5793b19f695..108b4ac78ae 100644
|
--- a/sql/opt_range.cc
|
+++ b/sql/opt_range.cc
|
@@ -9174,6 +9174,19 @@ Item_func_like::get_mm_leaf(RANGE_OPT_PARAM *param,
|
&min_length, &max_length))
|
DBUG_RETURN(0); // Can't optimize with LIKE
|
|
+ min_length= Well_formed_prefix(field->charset(),
|
+ (const char *) min_str + offset, min_length,
|
+ field->char_length()).length();
|
+ max_length= Well_formed_prefix(field->charset(),
|
+ (const char *) max_str + offset, max_length,
|
+ field->char_length()).length();
|
if (offset != maybe_null) // BLOB or VARCHAR
|
{
|
int2store(min_str + maybe_null, min_length);
|
|
- blocks
-
MDEV-19123
Change default charset from latin1 to utf8mb4
-
-
Closed
{"report":{"fcp":1450.2000002861023,"ttfb":369,"pageVisibility":"visible","entityId":129443,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"91da9c1d-080f-464f-a705-21aae1b0981f","navigationType":0,"readyForUser":1570.7000002861023,"redirectCount":0,"resourceLoadedEnd":1791.5,"resourceLoadedStart":376.2000002861023,"resourceTiming":[{"duration":524.8999996185303,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":376.2000002861023,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":376.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":901.0999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":525,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":376.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":376.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":901.5,"responseStart":0,"secureConnectionStart":0},{"duration":534,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":376.7000002861023,"connectEnd":376.7000002861023,"connectStart":376.7000002861023,"domainLookupEnd":376.7000002861023,"domainLookupStart":376.7000002861023,"fetchStart":376.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":376.7000002861023,"responseEnd":910.7000002861023,"responseStart":910.7000002861023,"secureConnectionStart":376.7000002861023},{"duration":610.3000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":376.90000009536743,"connectEnd":376.90000009536743,"connectStart":376.90000009536743,"domainLookupEnd":376.90000009536743,"domainLookupStart":376.90000009536743,"fetchStart":376.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":376.90000009536743,"responseEnd":987.2000002861023,"responseStart":987.2000002861023,"secureConnectionStart":376.90000009536743},{"duration":614.2999997138977,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":377.2000002861023,"connectEnd":377.2000002861023,"connectStart":377.2000002861023,"domainLookupEnd":377.2000002861023,"domainLookupStart":377.2000002861023,"fetchStart":377.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":377.2000002861023,"responseEnd":991.5,"responseStart":991.4000000953674,"secureConnectionStart":377.2000002861023},{"duration":614.6999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":377.30000019073486,"connectEnd":377.30000019073486,"connectStart":377.30000019073486,"domainLookupEnd":377.30000019073486,"domainLookupStart":377.30000019073486,"fetchStart":377.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":377.30000019073486,"responseEnd":992,"responseStart":992,"secureConnectionStart":377.30000019073486},{"duration":614.9000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":377.5,"connectEnd":377.5,"connectStart":377.5,"domainLookupEnd":377.5,"domainLookupStart":377.5,"fetchStart":377.5,"redirectEnd":0,"redirectStart":0,"requestStart":377.5,"responseEnd":992.4000000953674,"responseStart":992.4000000953674,"secureConnectionStart":377.5},{"duration":707.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":377.7000002861023,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":377.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1085.2000002861023,"responseStart":0,"secureConnectionStart":0},{"duration":615.0999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":377.90000009536743,"connectEnd":377.90000009536743,"connectStart":377.90000009536743,"domainLookupEnd":377.90000009536743,"domainLookupStart":377.90000009536743,"fetchStart":377.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":377.90000009536743,"responseEnd":993,"responseStart":993,"secureConnectionStart":377.90000009536743},{"duration":707.3000001907349,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":378,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":378,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1085.3000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":615.3999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":378.2000002861023,"connectEnd":378.2000002861023,"connectStart":378.2000002861023,"domainLookupEnd":378.2000002861023,"domainLookupStart":378.2000002861023,"fetchStart":378.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":378.2000002861023,"responseEnd":993.5999999046326,"responseStart":993.5999999046326,"secureConnectionStart":378.2000002861023},{"duration":1095.1999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":379.2000002861023,"connectEnd":379.2000002861023,"connectStart":379.2000002861023,"domainLookupEnd":379.2000002861023,"domainLookupStart":379.2000002861023,"fetchStart":379.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":379.2000002861023,"responseEnd":1474.4000000953674,"responseStart":1474.4000000953674,"secureConnectionStart":379.2000002861023},{"duration":1412.1999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":379.30000019073486,"connectEnd":379.30000019073486,"connectStart":379.30000019073486,"domainLookupEnd":379.30000019073486,"domainLookupStart":379.30000019073486,"fetchStart":379.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":379.30000019073486,"responseEnd":1791.5,"responseStart":1791.5,"secureConnectionStart":379.30000019073486},{"duration":375.59999990463257,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1108,"connectEnd":1108,"connectStart":1108,"domainLookupEnd":1108,"domainLookupStart":1108,"fetchStart":1108,"redirectEnd":0,"redirectStart":0,"requestStart":1108,"responseEnd":1483.5999999046326,"responseStart":1483.5999999046326,"secureConnectionStart":1108},{"duration":355.2000002861023,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1440.5999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1440.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1795.8000001907349,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":146,"responseStart":369,"responseEnd":374,"domLoading":373,"domInteractive":1820,"domContentLoadedEventStart":1820,"domContentLoadedEventEnd":1873,"domComplete":2253,"loadEventStart":2253,"loadEventEnd":2254,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1796.9000000953674},{"name":"bigPipe.sidebar-id.end","time":1797.8000001907349},{"name":"bigPipe.activity-panel-pipe-id.start","time":1798},{"name":"bigPipe.activity-panel-pipe-id.end","time":1799.5999999046326},{"name":"activityTabFullyLoaded","time":1922.9000000953674}],"measures":[],"correlationId":"29096df232f87d","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":131,"dbReadsTimeInMs":11,"dbConnsTimeInMs":19,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Also repeatable with the TINYTEXT data type:
SET @@optimizer_trace='enabled=on';
CREATE OR REPLACE TABLE t1 (
a CHAR(2) NOT NULL PRIMARY KEY,
b TINYTEXT NOT NULL,
KEY (b(255))
) ENGINE=InnoDB CHARSET=utf8mb4;
CREATE OR REPLACE TABLE t2 (
a CHAR(2) NOT NULL PRIMARY KEY,
b TINYTEXT NOT NULL,
KEY (b(255))
) ENGINE=InnoDB 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 of America'),
('IB','North America'),
('GO','South America');
UPDATE t1,t2 SET t1.b=UPPER(t1.b) WHERE t1.b LIKE 'Unknown%';
ERROR 1406 (22001): Data too long for column 'b' at row 1