[MDEV-22225] Timestamp based virtual colum incongruences Created: 2020-04-12  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: Time zones
Affects Version/s: 10.5.3
Fix Version/s: 10.4

Type: Bug Priority: Major
Reporter: Roy Bellingan Assignee: Sergei Golubchik
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Suse 15.1 self compiled from 8c0b988073c6537f53bcda0afbba0f4ce20fae34



 Description   

In short after changing timezone, the select * data differ from the indexed one

SET time_zone = 'UTC';
 
CREATE TABLE `l2` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `dateUTC` date GENERATED ALWAYS AS (cast(`timestamp` as date)) VIRTUAL,
  PRIMARY KEY (`id`),
  KEY `dateUTC` (`dateUTC`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
INSERT INTO `l2` (`id`, `timestamp`) VALUES
(1,	'2020-04-12 23:10:04'),
(2,	'2020-04-12 20:10:04');
 
**************************************************
SET time_zone = 'Europe/Helsinki';
 
select * from l2 where timestamp > '2020-04-13';
+----+---------------------+------------+
| id | timestamp           | dateUTC    |
+----+---------------------+------------+
|  1 | 2020-04-13 02:10:04 | 2020-04-13 |
+----+---------------------+------------+
1 row in set (0.001 sec)
 
select * from l2 where dateUTC = '2020-04-13';
Empty set (0.002 sec)
 
select * from l2 where dateUTC = '2020-04-12';
+----+---------------------+------------+
| id | timestamp           | dateUTC    |
+----+---------------------+------------+
|  1 | 2020-04-13 02:10:04 | 2020-04-13 |
|  2 | 2020-04-12 23:10:04 | 2020-04-12 |
+----+---------------------+------------+

This is related to MDEV-21249
Which fixed only the representational, but the data in the index is still "wrong"



 Comments   
Comment by Roy Bellingan [ 2020-04-12 ]

The problem is also goin in the "other direction"

TRUNCATE TABLE l2;
SET time_zone = 'Europe/Helsinki';
INSERT INTO `l2` (`timestamp`) VALUES  ('2020-04-13 02:10:04');
 
 
SELECT * FROM l2 WHERE `dateUTC` = '2020-04-13';
+----+---------------------+------------+
| id | timestamp           | dateUTC    |
+----+---------------------+------------+
|  1 | 2020-04-13 02:10:04 | 2020-04-13 |
+----+---------------------+------------+
 
*************************************
SET time_zone = 'UTC';
 
SELECT * FROM l2 WHERE `dateUTC` = '2020-04-13';
+----+---------------------+------------+
| id | timestamp           | dateUTC    |
+----+---------------------+------------+
|  1 | 2020-04-12 23:10:04 | 2020-04-12 |
+----+---------------------+------------+
 

Generated at Thu Feb 08 09:13:08 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.