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

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

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

            ekr3peeK Adam Baranyai created issue -
            ekr3peeK Adam Baranyai made changes -
            Field Original Value New Value
            Description When using the *CURDATE()* function as part of a VIRTUAL column, the column becomes unselectable.

            Ways to reproduce:


            {code:mysql}
            -- 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
            {code}
            When using the *CURDATE()* function as part of a VIRTUAL column, the column becomes unselectable.

            Ways to reproduce:


            {code:mysql}
            -- 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
            {code}

            As a workaround, using CURRENT_TIMESTAMP() will work without errors.
            alice Alice Sherepa added a comment -

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

            alice Alice Sherepa added a comment - Thanks! This is the same problem as MDEV-25772 ( MDEV-26437 ), I will add the testcase there
            alice Alice Sherepa made changes -
            Component/s N/A [ 14411 ]
            Fix Version/s N/A [ 14700 ]
            Resolution Duplicate [ 3 ]
            Status Open [ 1 ] Closed [ 6 ]
            alice Alice Sherepa made changes -
            nikitamalyavin Nikita Malyavin made changes -
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 125092 ] MariaDB v4 [ 159690 ]

            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.