|
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.
|