DROP TABLE IF EXISTS t1,t2;
|
CREATE TABLE t1 (
|
a INT, b VARCHAR(1), c INT,
|
KEY(a), KEY(b)
|
) ENGINE=MyISAM;
|
INSERT INTO t1 VALUES
|
(1,'v',9),(2,'v',8),(3,'c',7),(4,'m',6),(5,'x',5),
|
(6,'i',4),(7,'e',3),(8,'p',2),(9,'s',1),(10,'j',9),
|
(11,'z',8),(12,'c',7),(13,'a',6),(14,'q',5),(15,'y',4),
|
(16,'n',3),(17,'r',2),(18,'v',1),(19,'p',0);
|
CREATE TABLE t2 (
|
pk INT, d VARCHAR(1), e INT,
|
PRIMARY KEY(pk), KEY(d,e)
|
) ENGINE=MyISAM;
|
INSERT INTO t2 VALUES
|
(1,'x',1),(2,'d',2),(3,'r',3),(4,'f',4),(5,'y',5),
|
(6,'u',6),(7,'m',7),(8,'k',8),(9,'o',9),(10,'w',1),
|
(11,'m',2),(12,'q',3),(13,'m',4),(14,'d',5),
|
(15,'g',6),(16,'x',7),(17,'f',8);
|
SELECT * FROM t1,t2 WHERE a=d;
|
SHOW WARNINGS;
|
returns warnings as expected:
+---------+------+---------------------------------------+
|
| Level | Code | Message |
|
+---------+------+---------------------------------------+
|
| Warning | 1292 | Truncated incorrect DOUBLE value: 'x' |
|
| Warning | 1292 | Truncated incorrect DOUBLE value: 'd' |
|
| Warning | 1292 | Truncated incorrect DOUBLE value: 'r' |
|
....
|
If I change the engine to InnoDB, the warnings are not displayed any more:
DROP TABLE IF EXISTS t1,t2;
|
CREATE TABLE t1 (
|
a INT, b VARCHAR(1), c INT,
|
KEY(a), KEY(b)
|
) ENGINE=InnoDB;
|
INSERT INTO t1 VALUES
|
(1,'v',9),(2,'v',8),(3,'c',7),(4,'m',6),(5,'x',5),
|
(6,'i',4),(7,'e',3),(8,'p',2),(9,'s',1),(10,'j',9),
|
(11,'z',8),(12,'c',7),(13,'a',6),(14,'q',5),(15,'y',4),
|
(16,'n',3),(17,'r',2),(18,'v',1),(19,'p',0);
|
CREATE TABLE t2 (
|
pk INT, d VARCHAR(1), e INT,
|
PRIMARY KEY(pk), KEY(d,e)
|
) ENGINE=InnoDB;
|
INSERT INTO t2 VALUES
|
(1,'x',1),(2,'d',2),(3,'r',3),(4,'f',4),(5,'y',5),
|
(6,'u',6),(7,'m',7),(8,'k',8),(9,'o',9),(10,'w',1),
|
(11,'m',2),(12,'q',3),(13,'m',4),(14,'d',5),
|
(15,'g',6),(16,'x',7),(17,'f',8);
|
SELECT * FROM t1,t2 WHERE a=d;
|
SHOW WARNINGS;
|
The problem happens because in case of InnoDB, execution goes through do_field_string():
#0 Field_num::get_int (this=0x7fff8e8dbe20,
|
cs=0x555556b78c80 <my_charset_latin1>, from=0x7fff8e81c68e "d\002", len=1,
|
rnd=0x7ffff7f7c768, unsigned_max=4294967295, signed_min=-2147483648,
|
signed_max=2147483647) at /home/bar/maria-git/server.10.2/sql/field.cc:1585
|
#1 0x0000555555c405e1 in Field_long::store (this=0x7fff8e8dbe20,
|
from=0x7fff8e81c68e "d\002", len=1, cs=0x555556b78c80 <my_charset_latin1>)
|
at /home/bar/maria-git/server.10.2/sql/field.cc:4027
|
#2 0x0000555555c5de78 in do_field_string (copy=0x7fff8e8dbda0)
|
at /home/bar/maria-git/server.10.2/sql/field_conv.cc:372
|
Field_num::get_int() does not produce the warnings because count_cuted_field is equal to CHECK_FIELD_IGNORE.
In case of MyISAM the optimizer chooses a different plan, execution goes through this code:
#3 0x00005555559864a4 in Value_source::Converter_strntod_with_warn::Converter_strntod_with_warn (this=0x7ffff7f33a30, thd=0x7fff98709070, filter=...,
|
cs=0x555556b78c80 <my_charset_latin1>, str=0x7fff9866db8e "x\001",
|
length=1) at /home/bar/maria-git/server.10.2/sql/field.h:202
|
#4 0x0000555555c4c137 in Field_varstring::val_real (this=0x7fff9866dc88)
|
at /home/bar/maria-git/server.10.2/sql/field.cc:7437
|
#5 0x0000555555c7f6ea in Item_field::val_real (this=0x7fff8d422f98)
|
at /home/bar/maria-git/server.10.2/sql/item.cc:2463
|
#6 0x0000555555c9c96c in Arg_comparator::compare_real (this=0x7fff8d423140)
|
at /home/bar/maria-git/server.10.2/sql/item_cmpfunc.cc:864
|
#7 0x0000555555caeec0 in Arg_comparator::compare (this=0x7fff8d423140)
|
at /home/bar/maria-git/server.10.2/sql/item_cmpfunc.h:87
|
The warnings ARE displayed, because Converter_strntod_with_warn checks for thd->no_errors rather than thd->count_cuted_fields.
The execution path for InnoDB should be fixed to call do_field_int() instead of do_field_string().
This will force Field_long to produce warnings on Field_long::store("d", 1, &my_charset_latin1).
- blocks
-
MDEV-4912
Data type plugin API version 1
-
-
Closed
{"report":{"fcp":3634.0999999046326,"ttfb":2134,"pageVisibility":"visible","entityId":55202,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":32,"apdex":0.5,"journeyId":"86df5da8-de82-4892-905e-9282dd03bd1a","navigationType":0,"readyForUser":3749.300000190735,"redirectCount":0,"resourceLoadedEnd":3909.300000190735,"resourceLoadedStart":2153.699999809265,"resourceTiming":[{"duration":884.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":2153.699999809265,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":2153.699999809265,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":3038.199999809265,"responseStart":0,"secureConnectionStart":0},{"duration":884.4000000953674,"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":2154.0999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":2154.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":3038.5,"responseStart":0,"secureConnectionStart":0},{"duration":891,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":2154.300000190735,"connectEnd":2154.300000190735,"connectStart":2154.300000190735,"domainLookupEnd":2154.300000190735,"domainLookupStart":2154.300000190735,"fetchStart":2154.300000190735,"redirectEnd":0,"redirectStart":0,"requestStart":2154.300000190735,"responseEnd":3045.300000190735,"responseStart":3045.300000190735,"secureConnectionStart":2154.300000190735},{"duration":922.8999996185303,"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":2156.800000190735,"connectEnd":2156.800000190735,"connectStart":2156.800000190735,"domainLookupEnd":2156.800000190735,"domainLookupStart":2156.800000190735,"fetchStart":2156.800000190735,"redirectEnd":0,"redirectStart":0,"requestStart":2156.800000190735,"responseEnd":3079.699999809265,"responseStart":3079.699999809265,"secureConnectionStart":2156.800000190735},{"duration":924.2000002861023,"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":2159.199999809265,"connectEnd":2159.199999809265,"connectStart":2159.199999809265,"domainLookupEnd":2159.199999809265,"domainLookupStart":2159.199999809265,"fetchStart":2159.199999809265,"redirectEnd":0,"redirectStart":0,"requestStart":2159.199999809265,"responseEnd":3083.4000000953674,"responseStart":3083.4000000953674,"secureConnectionStart":2159.199999809265},{"duration":923.9000000953674,"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":2159.9000000953674,"connectEnd":2159.9000000953674,"connectStart":2159.9000000953674,"domainLookupEnd":2159.9000000953674,"domainLookupStart":2159.9000000953674,"fetchStart":2159.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":2159.9000000953674,"responseEnd":3083.800000190735,"responseStart":3083.800000190735,"secureConnectionStart":2159.9000000953674},{"duration":923.5,"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":2160.800000190735,"connectEnd":2160.800000190735,"connectStart":2160.800000190735,"domainLookupEnd":2160.800000190735,"domainLookupStart":2160.800000190735,"fetchStart":2160.800000190735,"redirectEnd":0,"redirectStart":0,"requestStart":2160.800000190735,"responseEnd":3084.300000190735,"responseStart":3084.300000190735,"secureConnectionStart":2160.800000190735},{"duration":1046.2000002861023,"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":2162.199999809265,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":2162.199999809265,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":3208.4000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":921.2000002861023,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":2163.5999999046326,"connectEnd":2163.5999999046326,"connectStart":2163.5999999046326,"domainLookupEnd":2163.5999999046326,"domainLookupStart":2163.5999999046326,"fetchStart":2163.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":2163.5999999046326,"responseEnd":3084.800000190735,"responseStart":3084.800000190735,"secureConnectionStart":2163.5999999046326},{"duration":1044,"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":2164.5999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":2164.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":3208.5999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":920,"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":2165.4000000953674,"connectEnd":2165.4000000953674,"connectStart":2165.4000000953674,"domainLookupEnd":2165.4000000953674,"domainLookupStart":2165.4000000953674,"fetchStart":2165.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":2165.4000000953674,"responseEnd":3085.4000000953674,"responseStart":3085.4000000953674,"secureConnectionStart":2165.4000000953674},{"duration":1198.9000000953674,"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":2168.5,"connectEnd":2168.5,"connectStart":2168.5,"domainLookupEnd":2168.5,"domainLookupStart":2168.5,"fetchStart":2168.5,"redirectEnd":0,"redirectStart":0,"requestStart":2168.5,"responseEnd":3367.4000000953674,"responseStart":3367.4000000953674,"secureConnectionStart":2168.5},{"duration":1735.6000003814697,"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":2173.699999809265,"connectEnd":2173.699999809265,"connectStart":2173.699999809265,"domainLookupEnd":2173.699999809265,"domainLookupStart":2173.699999809265,"fetchStart":2173.699999809265,"redirectEnd":0,"redirectStart":0,"requestStart":2173.699999809265,"responseEnd":3909.300000190735,"responseStart":3909.300000190735,"secureConnectionStart":2173.699999809265},{"duration":113.89999961853027,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":3254.300000190735,"connectEnd":3254.300000190735,"connectStart":3254.300000190735,"domainLookupEnd":3254.300000190735,"domainLookupStart":3254.300000190735,"fetchStart":3254.300000190735,"redirectEnd":0,"redirectStart":0,"requestStart":3254.300000190735,"responseEnd":3368.199999809265,"responseStart":3368.199999809265,"secureConnectionStart":3254.300000190735}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":1960,"responseStart":2134,"responseEnd":2157,"domLoading":2140,"domInteractive":3996,"domContentLoadedEventStart":3996,"domContentLoadedEventEnd":4073,"domComplete":4722,"loadEventStart":4722,"loadEventEnd":4723,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":3911.699999809265},{"name":"bigPipe.sidebar-id.end","time":3912.699999809265},{"name":"bigPipe.activity-panel-pipe-id.start","time":3912.9000000953674},{"name":"bigPipe.activity-panel-pipe-id.end","time":3915.199999809265},{"name":"activityTabFullyLoaded","time":4087.800000190735}],"measures":[],"correlationId":"24363fd7de31db","effectiveType":"4g","downlink":9.1,"rtt":0,"serverDuration":100,"dbReadsTimeInMs":12,"dbConnsTimeInMs":22,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
If I change the data type from INT to DECIMAL(10,0):
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (
a DECIMAL(10,0), b VARCHAR(1), c INT,
KEY(a), KEY(b)
) ENGINE=InnoDB;
INSERT INTO t1 VALUES
(1,'v',9),(2,'v',8),(3,'c',7),(4,'m',6),(5,'x',5),
(6,'i',4),(7,'e',3),(8,'p',2),(9,'s',1),(10,'j',9),
(11,'z',8),(12,'c',7),(13,'a',6),(14,'q',5),(15,'y',4),
(16,'n',3),(17,'r',2),(18,'v',1),(19,'p',0);
CREATE TABLE t2 (
pk INT, d VARCHAR(1), e INT,
PRIMARY KEY(pk), KEY(d,e)
) ENGINE=InnoDB;
INSERT INTO t2 VALUES
(1,'x',1),(2,'d',2),(3,'r',3),(4,'f',4),(5,'y',5),
(6,'u',6),(7,'m',7),(8,'k',8),(9,'o',9),(10,'w',1),
(11,'m',2),(12,'q',3),(13,'m',4),(14,'d',5),
(15,'g',6),(16,'x',7),(17,'f',8);
SELECT * FROM t1,t2 WHERE a=d;
SHOW WARNINGS;
It returns warnings with InnoDB:
+---------+------+---------------------------------------------------------+
| Level | Code | Message |
+---------+------+---------------------------------------------------------+
| Warning | 1918 | Encountered illegal value '' when converting to DECIMAL |
| Warning | 1292 | Truncated incorrect DECIMAL value: 'd' |
| Warning | 1918 | Encountered illegal value '' when converting to DECIMAL |
| Warning | 1292 | Truncated incorrect DECIMAL value: 'd' |
....