DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (
|
id int(11) NOT NULL PRIMARY KEY,
|
country varchar(32),
|
code int(11) default NULL
|
);
|
INSERT INTO t1 VALUES (1,'ITALY',100),(2,'ITALY',200),(3,'FRANCE',100), (4,'ITALY',100);
|
DROP VIEW IF EXISTS v1;
|
CREATE VIEW v1 AS SELECT * FROM t1;
|
|
DROP TABLE IF EXISTS t2;
|
CREATE TABLE t2 AS
|
SELECT code, COUNT(DISTINCT country), MAX(id) FROM t1 GROUP BY code ORDER BY MAX(id);
|
SHOW CREATE TABLE t2;
|
returns
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| Table | Create Table |
|
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| t2 | CREATE TABLE `t2` (
|
`code` int(11) DEFAULT NULL,
|
`COUNT(DISTINCT country)` bigint(21) NOT NULL,
|
`MAX(id)` int(11)
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
|
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
Notice, MAX(id) was correctly created as INT(11) when doing CREATE..SELECT..FROM t1.
Now if I do the same with v1 instead of t1:
DROP TABLE IF EXISTS t2;
|
CREATE TABLE t2 AS
|
SELECT code, COUNT(DISTINCT country), MAX(id) FROM v1 GROUP BY code ORDER BY MAX(id);
|
SHOW CREATE TABLE t2;
|
it returns
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| Table | Create Table |
|
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| t2 | CREATE TABLE `t2` (
|
`code` int(11) DEFAULT NULL,
|
`COUNT(DISTINCT country)` bigint(21) NOT NULL,
|
`MAX(id)` bigint(11) DEFAULT NULL
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
|
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
Notice, MAX(id) was erroneously created as BIGINT(11).
The problem happens because Item_sum::create_tmp_field() does not adjust the data type from length.
- blocks
-
MDEV-4912
Data type plugin API version 1
-
-
Closed
{"report":{"fcp":3204.7000000476837,"ttfb":1283.2000000476837,"pageVisibility":"visible","entityId":55231,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"81e28650-f9bc-4c0d-a7bb-be64658c2cc5","navigationType":0,"readyForUser":3394,"redirectCount":0,"resourceLoadedEnd":4032.2000000476837,"resourceLoadedStart":1288.2999999523163,"resourceTiming":[{"duration":1378.2000000476837,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":1288.2999999523163,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1288.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2666.5,"responseStart":0,"secureConnectionStart":0},{"duration":1378.2999999523163,"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":1288.5999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1288.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2666.899999856949,"responseStart":0,"secureConnectionStart":0},{"duration":1387.0999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":1288.7999999523163,"connectEnd":1288.7999999523163,"connectStart":1288.7999999523163,"domainLookupEnd":1288.7999999523163,"domainLookupStart":1288.7999999523163,"fetchStart":1288.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":1288.7999999523163,"responseEnd":2675.899999856949,"responseStart":2675.899999856949,"secureConnectionStart":1288.7999999523163},{"duration":1442.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":1288.8999998569489,"connectEnd":1288.8999998569489,"connectStart":1288.8999998569489,"domainLookupEnd":1288.8999998569489,"domainLookupStart":1288.8999998569489,"fetchStart":1288.8999998569489,"redirectEnd":0,"redirectStart":0,"requestStart":1288.8999998569489,"responseEnd":2731.399999856949,"responseStart":2731.399999856949,"secureConnectionStart":1288.8999998569489},{"duration":1446.5,"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":1289.2000000476837,"connectEnd":1289.2000000476837,"connectStart":1289.2000000476837,"domainLookupEnd":1289.2000000476837,"domainLookupStart":1289.2000000476837,"fetchStart":1289.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":1289.2000000476837,"responseEnd":2735.7000000476837,"responseStart":2735.7000000476837,"secureConnectionStart":1289.2000000476837},{"duration":1446.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":1289.2999999523163,"connectEnd":1289.2999999523163,"connectStart":1289.2999999523163,"domainLookupEnd":1289.2999999523163,"domainLookupStart":1289.2999999523163,"fetchStart":1289.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":1289.2999999523163,"responseEnd":2736.2000000476837,"responseStart":2736.2000000476837,"secureConnectionStart":1289.2999999523163},{"duration":1447.0999999046326,"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":1289.5,"connectEnd":1289.5,"connectStart":1289.5,"domainLookupEnd":1289.5,"domainLookupStart":1289.5,"fetchStart":1289.5,"redirectEnd":0,"redirectStart":0,"requestStart":1289.5,"responseEnd":2736.5999999046326,"responseStart":2736.5999999046326,"secureConnectionStart":1289.5},{"duration":1540.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":1289.7000000476837,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1289.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2830.2000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":1447.2000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":1289.8999998569489,"connectEnd":1289.8999998569489,"connectStart":1289.8999998569489,"domainLookupEnd":1289.8999998569489,"domainLookupStart":1289.8999998569489,"fetchStart":1289.8999998569489,"redirectEnd":0,"redirectStart":0,"requestStart":1289.8999998569489,"responseEnd":2737.0999999046326,"responseStart":2737.0999999046326,"secureConnectionStart":1289.8999998569489},{"duration":1540.4000000953674,"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":1290.0999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1290.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2830.5,"responseStart":0,"secureConnectionStart":0},{"duration":1447.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":1290.2999999523163,"connectEnd":1290.2999999523163,"connectStart":1290.2999999523163,"domainLookupEnd":1290.2999999523163,"domainLookupStart":1290.2999999523163,"fetchStart":1290.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":1290.2999999523163,"responseEnd":2737.7000000476837,"responseStart":2737.5999999046326,"secureConnectionStart":1290.2999999523163},{"duration":2547.7000000476837,"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":1298,"connectEnd":1298,"connectStart":1298,"domainLookupEnd":1298,"domainLookupStart":1298,"fetchStart":1298,"redirectEnd":0,"redirectStart":0,"requestStart":1298,"responseEnd":3845.7000000476837,"responseStart":3845.7000000476837,"secureConnectionStart":1298},{"duration":2734.100000143051,"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":1298.0999999046326,"connectEnd":1298.0999999046326,"connectStart":1298.0999999046326,"domainLookupEnd":1298.0999999046326,"domainLookupStart":1298.0999999046326,"fetchStart":1298.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":1298.0999999046326,"responseEnd":4032.2000000476837,"responseStart":4032.2000000476837,"secureConnectionStart":1298.0999999046326},{"duration":979.6000001430511,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":2868.0999999046326,"connectEnd":2868.0999999046326,"connectStart":2868.0999999046326,"domainLookupEnd":2868.0999999046326,"domainLookupStart":2868.0999999046326,"fetchStart":2868.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":2868.0999999046326,"responseEnd":3847.7000000476837,"responseStart":3847.7000000476837,"secureConnectionStart":2868.0999999046326},{"duration":867.7000000476837,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":3185.899999856949,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":3185.899999856949,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":4053.5999999046326,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":1120,"responseStart":1283,"responseEnd":1287,"domLoading":1287,"domInteractive":4057,"domContentLoadedEventStart":4057,"domContentLoadedEventEnd":4113,"domComplete":6569,"loadEventStart":6569,"loadEventEnd":6571,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":4036.7000000476837},{"name":"bigPipe.sidebar-id.end","time":4037.5999999046326},{"name":"bigPipe.activity-panel-pipe-id.start","time":4037.7999999523163},{"name":"bigPipe.activity-panel-pipe-id.end","time":4040.399999856949},{"name":"activityTabFullyLoaded","time":4120.200000047684}],"measures":[],"correlationId":"2806cd8f97297e","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":93,"dbReadsTimeInMs":13,"dbConnsTimeInMs":23,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}