[MDEV-26619] CURDATE() functions results in lost connection when used in a VIRTUAL column Created: 2021-09-16  Updated: 2021-10-01  Resolved: 2021-09-16

Status: Closed
Project: MariaDB Server
Component/s: N/A
Affects Version/s: 10.4.21
Fix Version/s: N/A

Type: Bug Priority: Minor
Reporter: Adam Baranyai Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: function, virtual_columns
Environment:

Centos 7


Issue Links:
Duplicate
duplicates MDEV-24176 Server crashes after insert in the ta... Closed
duplicates MDEV-25772 Virtual Column with CURDATE function ... Closed

 Description   

When using the CURDATE() function as part of a VIRTUAL column, the column becomes unselectable.

Ways to reproduce:

-- create table with virtual column using the curdate() function
CREATE TABLE `TestTable` (
 `TestId` int(11) NOT NULL AUTO_INCREMENT,
 `VirtualColumnTest` tinyint(4) GENERATED ALWAYS AS (if(curdate() between '2020-01-01' and '2020-01-02',1,0)) VIRTUAL,
 PRIMARY KEY (`TestId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
-- selecting with "*" works as expected
SELECT * FROM TestTable;
 
-- selecting directly by column triggers error
SELECT VirtualColumnTest FROM TestTable;
 
-- ERROR 2013 (HY000): Lost connection to MySQL server during query

As a workaround, using CURRENT_TIMESTAMP() will work without errors.



 Comments   
Comment by Alice Sherepa [ 2021-09-16 ]

Thanks!
This is the same problem as MDEV-25772 (MDEV-26437), I will add the testcase there

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