Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-26619

CURDATE() functions results in lost connection when used in a VIRTUAL column

    XMLWordPrintable

Details

    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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ekr3peeK Adam Baranyai
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start 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.