DECIMAL/INT vs DOUBLE work differently on CAST for empty strings:
SET sql_mode='STRICT_ALL_TABLES';
|
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a INT);
|
INSERT INTO t1 VALUES (CAST('' AS INT));
|
and
SET sql_mode='STRICT_ALL_TABLES';
|
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a DECIMAL);
|
INSERT INTO t1 VALUES (CAST('' AS DECIMAL));
|
correctly return
ERROR 1292 (22007): Truncated incorrect DECIMAL value: ''
|
DOUBLE works differently:
SET sql_mode='STRICT_ALL_TABLES';
|
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a DOUBLE);
|
INSERT INTO t1 VALUES (CAST('' AS DOUBLE));
|
It accepts the value silently:
Query OK, 1 row affected (0.03 sec)
|
This happens because the CAST alone does not produce any warnings for DOUBLE:
SELECT CAST('' AS DOUBLE);
|
and produces a warning for DECIMAL and INT:
MariaDB [test]> SELECT CAST('' AS INT);
|
+-----------------+
|
| CAST('' AS INT) |
|
+-----------------+
|
| 0 |
|
+-----------------+
|
1 row in set, 1 warning (0.00 sec)
|
|
MariaDB [test]> SELECT CAST('' AS INT);
|
+-----------------+
|
| CAST('' AS INT) |
|
+-----------------+
|
| 0 |
|
+-----------------+
|
1 row in set, 1 warning (0.00 sec)
|
|
MariaDB [test]> SHOW WARNINGS;
|
+---------+------+---------------------------------------+
|
| Level | Code | Message |
|
+---------+------+---------------------------------------+
|
| Warning | 1292 | Truncated incorrect INTEGER value: '' |
|
+---------+------+---------------------------------------+
|
1 row in set (0.00 sec)
|
During a discussion on maria-developers, Sergei and Bar agreed that a warning should be generated for all numeric data types.
There are no comments yet on this issue.
{"report":{"fcp":1069.1000003814697,"ttfb":236.70000076293945,"pageVisibility":"visible","entityId":52229,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"1bdec2e1-d774-4b86-8d98-9a76d1c13adf","navigationType":0,"readyForUser":1150.8000001907349,"redirectCount":0,"resourceLoadedEnd":745.8000001907349,"resourceLoadedStart":243.60000038146973,"resourceTiming":[{"duration":276.80000019073486,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":243.60000038146973,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":243.60000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":520.4000005722046,"responseStart":0,"secureConnectionStart":0},{"duration":277,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/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","startTime":243.80000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":243.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":520.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":378.20000076293945,"initiatorType":"script","name":"https://jira.mariadb.org/s/e9b27a47da5fb0f74a35acd57e9847fb-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":244,"connectEnd":244,"connectStart":244,"domainLookupEnd":244,"domainLookupStart":244,"fetchStart":244,"redirectEnd":0,"redirectStart":0,"requestStart":524,"responseEnd":622.2000007629395,"responseStart":540.2000007629395,"secureConnectionStart":244},{"duration":501.5999994277954,"initiatorType":"script","name":"https://jira.mariadb.org/s/c32eb0da7ad9831253f8397e6cc26afd-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/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","startTime":244.20000076293945,"connectEnd":244.20000076293945,"connectStart":244.20000076293945,"domainLookupEnd":244.20000076293945,"domainLookupStart":244.20000076293945,"fetchStart":244.20000076293945,"redirectEnd":0,"redirectStart":0,"requestStart":524.5,"responseEnd":745.8000001907349,"responseStart":553.1000003814697,"secureConnectionStart":244.20000076293945},{"duration":299.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/bc0bcb146314416123c992714ee00ff7-CDN/lu2bv2/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":244.4000005722046,"connectEnd":244.4000005722046,"connectStart":244.4000005722046,"domainLookupEnd":244.4000005722046,"domainLookupStart":244.4000005722046,"fetchStart":244.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":525.3000001907349,"responseEnd":544.2000007629395,"responseStart":542.3000001907349,"secureConnectionStart":244.4000005722046},{"duration":303.1000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":244.5,"connectEnd":244.5,"connectStart":244.5,"domainLookupEnd":244.5,"domainLookupStart":244.5,"fetchStart":244.5,"redirectEnd":0,"redirectStart":0,"requestStart":526.7000007629395,"responseEnd":547.6000003814697,"responseStart":544.4000005722046,"secureConnectionStart":244.5},{"duration":303.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":244.70000076293945,"connectEnd":244.70000076293945,"connectStart":244.70000076293945,"domainLookupEnd":244.70000076293945,"domainLookupStart":244.70000076293945,"fetchStart":244.70000076293945,"redirectEnd":0,"redirectStart":0,"requestStart":527.3000001907349,"responseEnd":547.9000005722046,"responseStart":545.7000007629395,"secureConnectionStart":244.70000076293945},{"duration":282.4000005722046,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bv2/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":244.80000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":244.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":527.2000007629395,"responseStart":0,"secureConnectionStart":0},{"duration":311,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":245.10000038146973,"connectEnd":245.10000038146973,"connectStart":245.10000038146973,"domainLookupEnd":245.10000038146973,"domainLookupStart":245.10000038146973,"fetchStart":245.10000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":535.2000007629395,"responseEnd":556.1000003814697,"responseStart":554.2000007629395,"secureConnectionStart":245.10000038146973},{"duration":284.19999980926514,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bv2/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":245.20000076293945,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":245.20000076293945,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":529.4000005722046,"responseStart":0,"secureConnectionStart":0},{"duration":313.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/719848dd97ebe0663199f49a3936487a-CDN/lu2bv2/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":245.4000005722046,"connectEnd":245.4000005722046,"connectStart":245.4000005722046,"domainLookupEnd":245.4000005722046,"domainLookupStart":245.4000005722046,"fetchStart":245.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":537.1000003814697,"responseEnd":558.6000003814697,"responseStart":556.8000001907349,"secureConnectionStart":245.4000005722046},{"duration":471.1000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":253.10000038146973,"connectEnd":253.10000038146973,"connectStart":253.10000038146973,"domainLookupEnd":253.10000038146973,"domainLookupStart":253.10000038146973,"fetchStart":253.10000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":629.8000001907349,"responseEnd":724.2000007629395,"responseStart":721.3000001907349,"secureConnectionStart":253.10000038146973},{"duration":473.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":253.4000005722046,"connectEnd":253.4000005722046,"connectStart":253.4000005722046,"domainLookupEnd":253.4000005722046,"domainLookupStart":253.4000005722046,"fetchStart":253.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":707.9000005722046,"responseEnd":726.6000003814697,"responseStart":725.2000007629395,"secureConnectionStart":253.4000005722046},{"duration":87.5,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":754.9000005722046,"connectEnd":754.9000005722046,"connectStart":754.9000005722046,"domainLookupEnd":754.9000005722046,"domainLookupStart":754.9000005722046,"fetchStart":754.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":802.5,"responseEnd":842.4000005722046,"responseStart":835.8000001907349,"secureConnectionStart":754.9000005722046}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":57,"responseStart":237,"responseEnd":253,"domLoading":240,"domInteractive":1206,"domContentLoadedEventStart":1206,"domContentLoadedEventEnd":1255,"domComplete":1931,"loadEventStart":1931,"loadEventEnd":1931,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1190.4000005722046},{"name":"bigPipe.sidebar-id.end","time":1191.1000003814697},{"name":"bigPipe.activity-panel-pipe-id.start","time":1191.3000001907349},{"name":"bigPipe.activity-panel-pipe-id.end","time":1191.8000001907349},{"name":"activityTabFullyLoaded","time":1262.7000007629395}],"measures":[],"correlationId":"3530431ac4e7ab","effectiveType":"4g","downlink":9.8,"rtt":0,"serverDuration":95,"dbReadsTimeInMs":15,"dbConnsTimeInMs":23,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}