This script demonstrates that although TIME'00:00:00.0' and TIME'00:00:00.00' are equal to each other for comparison, they are still not equal in other contexts:
Looks wrong. The SELECT query should return empty set, and EXPLAIN should not tell that the condition was simplified to true.
Alexander Barkov
added a comment - The same problem is repeatable with DECIMAL:
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DECIMAL (10,3));
INSERT INTO t1 VALUES (10.0),(10.1);
SELECT LENGTH(10.0)+a,LENGTH(10.000)+a FROM t1;
+----------------+------------------+
| LENGTH(10.0)+a | LENGTH(10.000)+a |
+----------------+------------------+
| 14.000 | 16.000 |
| 14.100 | 16.100 |
+----------------+------------------+
SELECT * FROM t1 WHERE LENGTH(10.0)+a<=>LENGTH(10.000)+a;
+--------+
| a |
+--------+
| 10.000 |
| 10.100 |
+--------+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(10.0)+a<=>LENGTH(10.000)+a;
SHOW WARNINGS;
+-------+------+--------------------------------------------------------+
| Level | Code | Message |
+-------+------+--------------------------------------------------------+
| Note | 1003 | select `test`.`t1`.`a` AS `a` from `test`.`t1` where 1 |
+-------+------+--------------------------------------------------------+
Looks wrong. The SELECT query should return empty set, and EXPLAIN should not tell that the condition was simplified to true .
The problem happens because Item_bool_func2::remove_eq_conds() correctly calls eq() for the arguments like this:
if (args[0]->eq(args[1], true)) // Notice true
but further eq() can handle binary vs non-binary comparison only for string constants (and not for temporal or decimal).
eq() should be fixed to take into account possible different formats when the binary_cmp parameter is true, for all affected data types (such as temporal and DECIMAL).
Alexander Barkov
added a comment - - edited The problem happens because Item_bool_func2::remove_eq_conds() correctly calls eq() for the arguments like this:
if (args[0]->eq(args[1], true )) // Notice true
but further eq() can handle binary vs non-binary comparison only for string constants (and not for temporal or decimal).
eq() should be fixed to take into account possible different formats when the binary_cmp parameter is true , for all affected data types (such as temporal and DECIMAL).
because Item_hex_constant::type() and Item_string::type() returns different codes (STRING_ITEM vs VARBIN_ITEM).
Alexander Barkov
added a comment - - edited In this scenario it works fine (the constants 'a' and 0x61 are not detected as same):
SET NAMES utf8;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DECIMAL (10,3));
INSERT INTO t1 VALUES (10.0),(10.1);
SELECT CHARSET( 'a' ),CHARSET(0x61),LENGTH(CHARSET( 'a' ))+a,LENGTH(CHARSET(0x61))+a FROM t1;
+--------------+---------------+------------------------+-------------------------+
| CHARSET('a') | CHARSET(0x61) | LENGTH(CHARSET('a'))+a | LENGTH(CHARSET(0x61))+a |
+--------------+---------------+------------------------+-------------------------+
| utf8 | binary | 14.000 | 16.000 |
| utf8 | binary | 14.100 | 16.100 |
+--------------+---------------+------------------------+-------------------------+
SELECT * FROM t1 WHERE LENGTH(CHARSET( 'a' ))+a<=>LENGTH(CHARSET(0x61))+a;
Empty set (1.80 sec)
EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(CHARSET( 'a' ))+a<=>LENGTH(CHARSET(0x61))+a;
SHOW WARNINGS;
+-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message |
+-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Note | 1003 | select `test`.`t1`.`a` AS `a` from `test`.`t1` where <cache>(octet_length(charset('a'))) + `test`.`t1`.`a` <=> <cache>(octet_length(charset(0x61))) + `test`.`t1`.`a` |
+-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
because Item_hex_constant::type() and Item_string::type() returns different codes (STRING_ITEM vs VARBIN_ITEM).
People
Alexander Barkov
Alexander Barkov
Votes:
0Vote for this issue
Watchers:
1Start watching this issue
Dates
Created:
Updated:
Resolved:
Git Integration
Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.
{"report":{"fcp":1508.4000000953674,"ttfb":264.40000009536743,"pageVisibility":"visible","entityId":68029,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"fb87874a-4c26-41c4-8662-cd9101584531","navigationType":0,"readyForUser":1608.1000001430511,"redirectCount":0,"resourceLoadedEnd":1830.4000000953674,"resourceLoadedStart":269.60000014305115,"resourceTiming":[{"duration":562.8999998569489,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":269.60000014305115,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":269.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":832.5,"responseStart":0,"secureConnectionStart":0},{"duration":563.0999999046326,"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":269.90000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":269.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":833,"responseStart":0,"secureConnectionStart":0},{"duration":607.0999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":270.10000014305115,"connectEnd":270.10000014305115,"connectStart":270.10000014305115,"domainLookupEnd":270.10000014305115,"domainLookupStart":270.10000014305115,"fetchStart":270.10000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":270.10000014305115,"responseEnd":877.2000000476837,"responseStart":877.2000000476837,"secureConnectionStart":270.10000014305115},{"duration":681.5,"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":270.30000019073486,"connectEnd":270.30000019073486,"connectStart":270.30000019073486,"domainLookupEnd":270.30000019073486,"domainLookupStart":270.30000019073486,"fetchStart":270.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":270.30000019073486,"responseEnd":951.8000001907349,"responseStart":951.8000001907349,"secureConnectionStart":270.30000019073486},{"duration":687.1000001430511,"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":270.5,"connectEnd":270.5,"connectStart":270.5,"domainLookupEnd":270.5,"domainLookupStart":270.5,"fetchStart":270.5,"redirectEnd":0,"redirectStart":0,"requestStart":270.5,"responseEnd":957.6000001430511,"responseStart":957.6000001430511,"secureConnectionStart":270.5},{"duration":692,"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":270.60000014305115,"connectEnd":270.60000014305115,"connectStart":270.60000014305115,"domainLookupEnd":270.60000014305115,"domainLookupStart":270.60000014305115,"fetchStart":270.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":270.60000014305115,"responseEnd":962.6000001430511,"responseStart":962.6000001430511,"secureConnectionStart":270.60000014305115},{"duration":692.2000000476837,"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":270.90000009536743,"connectEnd":270.90000009536743,"connectStart":270.90000009536743,"domainLookupEnd":270.90000009536743,"domainLookupStart":270.90000009536743,"fetchStart":270.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":270.90000009536743,"responseEnd":963.1000001430511,"responseStart":963.1000001430511,"secureConnectionStart":270.90000009536743},{"duration":756.8000001907349,"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":271,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":271,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1027.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":692.7000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":271.2000000476837,"connectEnd":271.2000000476837,"connectStart":271.2000000476837,"domainLookupEnd":271.2000000476837,"domainLookupStart":271.2000000476837,"fetchStart":271.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":271.2000000476837,"responseEnd":963.9000000953674,"responseStart":963.9000000953674,"secureConnectionStart":271.2000000476837},{"duration":756.5999999046326,"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":271.40000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":271.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1028,"responseStart":0,"secureConnectionStart":0},{"duration":693.4000000953674,"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":271.5,"connectEnd":271.5,"connectStart":271.5,"domainLookupEnd":271.5,"domainLookupStart":271.5,"fetchStart":271.5,"redirectEnd":0,"redirectStart":0,"requestStart":271.5,"responseEnd":964.9000000953674,"responseStart":964.9000000953674,"secureConnectionStart":271.5},{"duration":853.3999998569489,"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":277.60000014305115,"connectEnd":277.60000014305115,"connectStart":277.60000014305115,"domainLookupEnd":277.60000014305115,"domainLookupStart":277.60000014305115,"fetchStart":277.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":277.60000014305115,"responseEnd":1131,"responseStart":1131,"secureConnectionStart":277.60000014305115},{"duration":1503.6000001430511,"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":292.2000000476837,"connectEnd":292.2000000476837,"connectStart":292.2000000476837,"domainLookupEnd":292.2000000476837,"domainLookupStart":292.2000000476837,"fetchStart":292.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":292.2000000476837,"responseEnd":1795.8000001907349,"responseStart":1795.8000001907349,"secureConnectionStart":292.2000000476837},{"duration":126.5,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1040.3000001907349,"connectEnd":1040.3000001907349,"connectStart":1040.3000001907349,"domainLookupEnd":1040.3000001907349,"domainLookupStart":1040.3000001907349,"fetchStart":1040.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":1040.3000001907349,"responseEnd":1166.8000001907349,"responseStart":1166.8000001907349,"secureConnectionStart":1040.3000001907349},{"duration":490.09999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":1340.3000001907349,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1340.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1830.4000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":587,"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":1341.3000001907349,"connectEnd":1341.3000001907349,"connectStart":1341.3000001907349,"domainLookupEnd":1341.3000001907349,"domainLookupStart":1341.3000001907349,"fetchStart":1341.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":1341.3000001907349,"responseEnd":1928.3000001907349,"responseStart":1928.3000001907349,"secureConnectionStart":1341.3000001907349},{"duration":594.9000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/s/097ae97cb8fbec7d6ea4bbb1f26955b9-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":1341.7000000476837,"connectEnd":1341.7000000476837,"connectStart":1341.7000000476837,"domainLookupEnd":1341.7000000476837,"domainLookupStart":1341.7000000476837,"fetchStart":1341.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":1341.7000000476837,"responseEnd":1936.6000001430511,"responseStart":1936.6000001430511,"secureConnectionStart":1341.7000000476837}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":86,"responseStart":264,"responseEnd":292,"domLoading":268,"domInteractive":1863,"domContentLoadedEventStart":1863,"domContentLoadedEventEnd":1929,"domComplete":2857,"loadEventStart":2857,"loadEventEnd":2858,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1837.4000000953674},{"name":"bigPipe.sidebar-id.end","time":1838.3000001907349},{"name":"bigPipe.activity-panel-pipe-id.start","time":1838.5},{"name":"bigPipe.activity-panel-pipe-id.end","time":1841.7000000476837},{"name":"activityTabFullyLoaded","time":1950.7000000476837}],"measures":[],"correlationId":"a095802e3d0f02","effectiveType":"4g","downlink":9.8,"rtt":0,"serverDuration":112,"dbReadsTimeInMs":15,"dbConnsTimeInMs":24,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
The same problem is repeatable with DECIMAL:
+----------------+------------------+
| LENGTH(10.0)+a | LENGTH(10.000)+a |
+----------------+------------------+
| 14.000 | 16.000 |
| 14.100 | 16.100 |
+----------------+------------------+
+--------+
| a |
+--------+
| 10.000 |
| 10.100 |
+--------+
SHOW WARNINGS;
+-------+------+--------------------------------------------------------+
| Level | Code | Message |
+-------+------+--------------------------------------------------------+
| Note | 1003 | select `test`.`t1`.`a` AS `a` from `test`.`t1` where 1 |
+-------+------+--------------------------------------------------------+
Looks wrong. The SELECT query should return empty set, and EXPLAIN should not tell that the condition was simplified to true.