MariaDB 10.3.10 When referring to bigint to generate timestamp data in the virtual generated column, the value of the generated column does not change when the time zone changes
When creating a virtual column, if the virtual column is timestamp, the value of the virtual column does not change when the time zone changes, and the mysql version changes.
mariadb10.3:
create table test_timestamp (`create_timestamp` timestamp(3) NOT NULL COMMENT '记录创建时间',`create_time` timestamp(3) GENERATED ALWAYS AS (from_unixtime(`create_timestamp` )) VIRTUAL COMMENT '记录创建时间');
insert into test_timestamp (`create_timestamp`) value (1569495326.861);
mysql> select * from test_timestamp;
+------------------+-------------------------+
| create_timestamp | create_time |
+------------------+-------------------------+
| 1569495326861 | 2019-09-26 10:55:26.861 |
+------------------+-------------------------+
1 row in set (0.01 sec)
mysql> set time_zone = "+01:00";
Query OK, 0 rows affected (0.00 sec)
mysql> select * from test_timestamp;
+------------------+-------------------------+
| create_timestamp | create_time |
+------------------+-------------------------+
| 1569495326861 | 2019-09-26 10:55:26.861 |
+------------------+-------------------------+
1 row in set (0.00 sec)
mysql5.7:
mysql> create table test_timestamp (`create_timestamp` bigint(20) NOT NULL COMMENT '记录创建时间',
Alice Sherepa
added a comment - Thanks a lot! I repeated on MariaDb 5.5-10.4:
create table t1 (a int , b timestamp GENERATED ALWAYS AS (from_unixtime(a)) VIRTUAL);
insert into t1 (a) value (1569495327);
select a, b, from_unixtime(a) from t1;
set time_zone = "+01:00" ;
select a, b, from_unixtime(a) from t1;
drop table t1;
MariaDB [test]> select a, b, from_unixtime(a) from t1;
+------------+---------------------+---------------------+
| a | b | from_unixtime(a) |
+------------+---------------------+---------------------+
| 1569495327 | 2019-09-26 12:55:27 | 2019-09-26 12:55:27 |
+------------+---------------------+---------------------+
1 row in set (0.000 sec)
MariaDB [test]> set time_zone = "+01:00";
Query OK, 0 rows affected (0.000 sec)
MariaDB [test]> select a, b, from_unixtime(a) from t1;
+------------+---------------------+---------------------+
| a | b | from_unixtime(a) |
+------------+---------------------+---------------------+
| 1569495327 | 2019-09-26 12:55:27 | 2019-09-26 11:55:27 |
+------------+---------------------+---------------------+
1 row in set (0.000 sec)
People
Sergei Golubchik
hongsheng zhou
Votes:
0Vote for this issue
Watchers:
3Start 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":1204.8999999761581,"ttfb":438.89999997615814,"pageVisibility":"visible","entityId":81009,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"e532157e-b06e-470a-b125-cae5a53c47fe","navigationType":0,"readyForUser":1322,"redirectCount":0,"resourceLoadedEnd":1505.1000000238419,"resourceLoadedStart":445.5,"resourceTiming":[{"duration":247.10000002384186,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":445.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":445.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":692.6000000238419,"responseStart":0,"secureConnectionStart":0},{"duration":247.10000002384186,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/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":445.7999999523163,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":445.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":692.8999999761581,"responseStart":0,"secureConnectionStart":0},{"duration":255.60000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":445.7999999523163,"connectEnd":445.7999999523163,"connectStart":445.7999999523163,"domainLookupEnd":445.7999999523163,"domainLookupStart":445.7999999523163,"fetchStart":445.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":445.7999999523163,"responseEnd":701.3999999761581,"responseStart":701.3999999761581,"secureConnectionStart":445.7999999523163},{"duration":330.6999999284744,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/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":446.10000002384186,"connectEnd":446.10000002384186,"connectStart":446.10000002384186,"domainLookupEnd":446.10000002384186,"domainLookupStart":446.10000002384186,"fetchStart":446.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":446.10000002384186,"responseEnd":776.7999999523163,"responseStart":776.7999999523163,"secureConnectionStart":446.10000002384186},{"duration":333.8000000715256,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":446.2999999523163,"connectEnd":446.2999999523163,"connectStart":446.2999999523163,"domainLookupEnd":446.2999999523163,"domainLookupStart":446.2999999523163,"fetchStart":446.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":446.2999999523163,"responseEnd":780.1000000238419,"responseStart":780.1000000238419,"secureConnectionStart":446.2999999523163},{"duration":334.60000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":446.5,"connectEnd":446.5,"connectStart":446.5,"domainLookupEnd":446.5,"domainLookupStart":446.5,"fetchStart":446.5,"redirectEnd":0,"redirectStart":0,"requestStart":446.5,"responseEnd":781.1000000238419,"responseStart":781.1000000238419,"secureConnectionStart":446.5},{"duration":335.60000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":446.6999999284744,"connectEnd":446.6999999284744,"connectStart":446.6999999284744,"domainLookupEnd":446.6999999284744,"domainLookupStart":446.6999999284744,"fetchStart":446.6999999284744,"redirectEnd":0,"redirectStart":0,"requestStart":446.6999999284744,"responseEnd":782.2999999523163,"responseStart":782.2999999523163,"secureConnectionStart":446.6999999284744},{"duration":405.7000000476837,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":446.89999997615814,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":446.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":852.6000000238419,"responseStart":0,"secureConnectionStart":0},{"duration":336.2999999523163,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":447,"connectEnd":447,"connectStart":447,"domainLookupEnd":447,"domainLookupStart":447,"fetchStart":447,"redirectEnd":0,"redirectStart":0,"requestStart":447,"responseEnd":783.2999999523163,"responseStart":783.2999999523163,"secureConnectionStart":447},{"duration":405.7000000476837,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/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":447.1999999284744,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":447.1999999284744,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":852.8999999761581,"responseStart":0,"secureConnectionStart":0},{"duration":336.7000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/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":447.39999997615814,"connectEnd":447.39999997615814,"connectStart":447.39999997615814,"domainLookupEnd":447.39999997615814,"domainLookupStart":447.39999997615814,"fetchStart":447.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":447.39999997615814,"responseEnd":784.1000000238419,"responseStart":784.1000000238419,"secureConnectionStart":447.39999997615814},{"duration":1051.1000000238419,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":452.6999999284744,"connectEnd":452.6999999284744,"connectStart":452.6999999284744,"domainLookupEnd":452.6999999284744,"domainLookupStart":452.6999999284744,"fetchStart":452.6999999284744,"redirectEnd":0,"redirectStart":0,"requestStart":452.6999999284744,"responseEnd":1503.7999999523163,"responseStart":1503.7999999523163,"secureConnectionStart":452.6999999284744},{"duration":1049.3000000715256,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":455.7999999523163,"connectEnd":455.7999999523163,"connectStart":455.7999999523163,"domainLookupEnd":455.7999999523163,"domainLookupStart":455.7999999523163,"fetchStart":455.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":455.7999999523163,"responseEnd":1505.1000000238419,"responseStart":1505.1000000238419,"secureConnectionStart":455.7999999523163},{"duration":180.20000004768372,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":886.6999999284744,"connectEnd":886.6999999284744,"connectStart":886.6999999284744,"domainLookupEnd":886.6999999284744,"domainLookupStart":886.6999999284744,"fetchStart":886.6999999284744,"redirectEnd":0,"redirectStart":0,"requestStart":886.6999999284744,"responseEnd":1066.8999999761581,"responseStart":1066.8999999761581,"secureConnectionStart":886.6999999284744},{"duration":417.89999997615814,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/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","startTime":1155.7999999523163,"connectEnd":1155.7999999523163,"connectStart":1155.7999999523163,"domainLookupEnd":1155.7999999523163,"domainLookupStart":1155.7999999523163,"fetchStart":1155.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":1155.7999999523163,"responseEnd":1573.6999999284744,"responseStart":1573.6999999284744,"secureConnectionStart":1155.7999999523163}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":271,"responseStart":439,"responseEnd":456,"domLoading":443,"domInteractive":1530,"domContentLoadedEventStart":1530,"domContentLoadedEventEnd":1573,"domComplete":1824,"loadEventStart":1824,"loadEventEnd":1824,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1509.1000000238419},{"name":"bigPipe.sidebar-id.end","time":1509.8999999761581},{"name":"bigPipe.activity-panel-pipe-id.start","time":1510.1000000238419},{"name":"bigPipe.activity-panel-pipe-id.end","time":1511.6999999284744},{"name":"activityTabFullyLoaded","time":1587.2999999523163}],"measures":[],"correlationId":"a5f5ac508f575a","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":98,"dbReadsTimeInMs":13,"dbConnsTimeInMs":22,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Thanks a lot! I repeated on MariaDb 5.5-10.4:
MariaDB [test]> select a, b, from_unixtime(a) from t1;
+------------+---------------------+---------------------+
| a | b | from_unixtime(a) |
+------------+---------------------+---------------------+
| 1569495327 | 2019-09-26 12:55:27 | 2019-09-26 12:55:27 |
+------------+---------------------+---------------------+
1 row in set (0.000 sec)
MariaDB [test]> set time_zone = "+01:00";
Query OK, 0 rows affected (0.000 sec)
MariaDB [test]> select a, b, from_unixtime(a) from t1;
+------------+---------------------+---------------------+
| a | b | from_unixtime(a) |
+------------+---------------------+---------------------+
| 1569495327 | 2019-09-26 12:55:27 | 2019-09-26 11:55:27 |
+------------+---------------------+---------------------+
1 row in set (0.000 sec)