Type:
Bug
Priority:
Critical
Resolution:
Fixed
Affects Version/s:
10.2.16 , 10.3.21 , 5.5(EOL) , 10.1(EOL) , 10.2(EOL) , 10.3(EOL) , 10.4(EOL) , 10.5
Environment:
Tested on Debian with 10.3.21 and Gentoo with 10.2.16.
Hi,
today we encountered one strange behavior in an older project. Below are simple SQL statements that quickly show where the problem is.
When combining a number and a number as a string in an IN WHERE condition, it sometimes returns extra unwanted records.
As you can see, condition id = 1234 OR id = "97716021308405775" returns expected 2 records, but equivalent id IN(1234,"97716021308405775") returns 4 records. This unexpected behavior is independent on storage engine - it works the same with InnoDB, MYISAM or TokuDB.
We'll fix our ORM layer to use the IN condition correctly (with either numbers or strings only), but maybe it's a bug in MariaDB that should be fixed. Maybe it's just old, familiar, unexpected behavior that can't be corrected?
DROP TABLE IF EXISTS test;
CREATE TABLE `test` (
`id` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
INSERT IGNORE INTO `test` VALUES(1234),(97716021308405775),(97716021308405770),(97716021308405780);
– OK
SELECT * FROM `test` WHERE `id` IN(97716021308405775);
SELECT * FROM `test` WHERE `id` IN("97716021308405775");
SELECT * FROM `test` WHERE `id` IN("1234",97716021308405775);
SELECT * FROM `test` WHERE `id` IN("1234","97716021308405775");
SELECT * FROM `test` WHERE `id` = 1234 OR id = "97716021308405775";
– NOT OK (returns 4 records instead of 2)
SELECT * FROM `test` WHERE `id` IN(1234,"97716021308405775");
SELECT * FROM `test` WHERE `id` IN("97716021308405775",1234);
{"report":{"fcp":1740.7000002861023,"ttfb":403.80000019073486,"pageVisibility":"visible","entityId":82150,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"4b1e1419-c88c-4035-b864-a69f0df22e3c","navigationType":0,"readyForUser":1876.5,"redirectCount":0,"resourceLoadedEnd":1957.9000000953674,"resourceLoadedStart":413.09999990463257,"resourceTiming":[{"duration":610.7000002861023,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":413.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":413.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1023.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":610.6999998092651,"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":413.40000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":413.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1024.0999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":620.2000002861023,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":413.59999990463257,"connectEnd":413.59999990463257,"connectStart":413.59999990463257,"domainLookupEnd":413.59999990463257,"domainLookupStart":413.59999990463257,"fetchStart":413.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":413.59999990463257,"responseEnd":1033.8000001907349,"responseStart":1033.8000001907349,"secureConnectionStart":413.59999990463257},{"duration":971.9000000953674,"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":413.80000019073486,"connectEnd":413.80000019073486,"connectStart":413.80000019073486,"domainLookupEnd":413.80000019073486,"domainLookupStart":413.80000019073486,"fetchStart":413.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":413.80000019073486,"responseEnd":1385.7000002861023,"responseStart":1385.7000002861023,"secureConnectionStart":413.80000019073486},{"duration":976.6000003814697,"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":414.09999990463257,"connectEnd":414.09999990463257,"connectStart":414.09999990463257,"domainLookupEnd":414.09999990463257,"domainLookupStart":414.09999990463257,"fetchStart":414.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":414.09999990463257,"responseEnd":1390.7000002861023,"responseStart":1390.7000002861023,"secureConnectionStart":414.09999990463257},{"duration":976.7999997138977,"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":414.30000019073486,"connectEnd":414.30000019073486,"connectStart":414.30000019073486,"domainLookupEnd":414.30000019073486,"domainLookupStart":414.30000019073486,"fetchStart":414.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":414.30000019073486,"responseEnd":1391.0999999046326,"responseStart":1391.0999999046326,"secureConnectionStart":414.30000019073486},{"duration":977,"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":414.5,"connectEnd":414.5,"connectStart":414.5,"domainLookupEnd":414.5,"domainLookupStart":414.5,"fetchStart":414.5,"redirectEnd":0,"redirectStart":0,"requestStart":414.5,"responseEnd":1391.5,"responseStart":1391.5,"secureConnectionStart":414.5},{"duration":978.8999996185303,"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":414.7000002861023,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":414.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1393.5999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":977.1999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":414.80000019073486,"connectEnd":414.80000019073486,"connectStart":414.80000019073486,"domainLookupEnd":414.80000019073486,"domainLookupStart":414.80000019073486,"fetchStart":414.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":414.80000019073486,"responseEnd":1392,"responseStart":1392,"secureConnectionStart":414.80000019073486},{"duration":978.6000003814697,"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":415.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":415.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1393.7000002861023,"responseStart":0,"secureConnectionStart":0},{"duration":977.2999997138977,"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":415.2000002861023,"connectEnd":415.2000002861023,"connectStart":415.2000002861023,"domainLookupEnd":415.2000002861023,"domainLookupStart":415.2000002861023,"fetchStart":415.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":415.2000002861023,"responseEnd":1392.5,"responseStart":1392.5,"secureConnectionStart":415.2000002861023},{"duration":1164.6999998092651,"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":417.40000009536743,"connectEnd":417.40000009536743,"connectStart":417.40000009536743,"domainLookupEnd":417.40000009536743,"domainLookupStart":417.40000009536743,"fetchStart":417.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":417.40000009536743,"responseEnd":1582.0999999046326,"responseStart":1582.0999999046326,"secureConnectionStart":417.40000009536743},{"duration":1539.1000003814697,"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":417.59999990463257,"connectEnd":417.59999990463257,"connectStart":417.59999990463257,"domainLookupEnd":417.59999990463257,"domainLookupStart":417.59999990463257,"fetchStart":417.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":417.59999990463257,"responseEnd":1956.7000002861023,"responseStart":1956.7000002861023,"secureConnectionStart":417.59999990463257},{"duration":366.90000009536743,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1205,"connectEnd":1205,"connectStart":1205,"domainLookupEnd":1205,"domainLookupStart":1205,"fetchStart":1205,"redirectEnd":0,"redirectStart":0,"requestStart":1205,"responseEnd":1571.9000000953674,"responseStart":1571.9000000953674,"secureConnectionStart":1205},{"duration":274,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":1683.9000000953674,"connectEnd":1683.9000000953674,"connectStart":1683.9000000953674,"domainLookupEnd":1683.9000000953674,"domainLookupStart":1683.9000000953674,"fetchStart":1683.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":1683.9000000953674,"responseEnd":1957.9000000953674,"responseStart":1957.9000000953674,"secureConnectionStart":1683.9000000953674},{"duration":250.59999990463257,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1730,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1730,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1980.5999999046326,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":250,"responseStart":404,"responseEnd":408,"domLoading":411,"domInteractive":1982,"domContentLoadedEventStart":1982,"domContentLoadedEventEnd":2025,"domComplete":3529,"loadEventStart":3529,"loadEventEnd":3531,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1959.4000000953674},{"name":"bigPipe.sidebar-id.end","time":1960.5},{"name":"bigPipe.activity-panel-pipe-id.start","time":1960.7000002861023},{"name":"bigPipe.activity-panel-pipe-id.end","time":1963.3000001907349},{"name":"activityTabFullyLoaded","time":2032.5}],"measures":[],"correlationId":"9c0817e8ce4c15","effectiveType":"4g","downlink":9.4,"rtt":0,"serverDuration":100,"dbReadsTimeInMs":15,"dbConnsTimeInMs":24,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}