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

timestamp virtual column yields syntax error in show create table

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • 5.3.12, 5.5.35, 10.0.7, 10.0.22
    • 10.1.8
    • Parser, Temporal Types
    • None
    • Linux x64

    Description

      You cannot mysqldump/reload the table in the below testcase due to invalid sql being returned by "show create table".

      drop table if exists t1;
      create table t1(a int, b timestamp as (a=1) virtual)engine=innodb;
      show create table t1;

      Attachments

        Issue Links

          Activity

            Hi,
            I'd like to know more information on this issue where is this testcase located? thanks

            sudheera Sudheera Palihakkara added a comment - Hi, I'd like to know more information on this issue where is this testcase located? thanks
            sbester1 sbester1 added a comment -

            The problem is very simple. Look at it, you cannot create a table shown by 'show create table':

            mysql> create table t1(a int, b timestamp as (a=1) virtual)engine=innodb;
            Query OK, 0 rows affected (0.39 sec)
             
            mysql> show create table t1;
            +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
            | Table | Create Table                                                                                                                                             |
            +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
            | t1    | CREATE TABLE `t1` (
              `a` int(11) DEFAULT NULL,
              `b` timestamp AS (a=1) VIRTUAL NULL ON UPDATE CURRENT_TIMESTAMP
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
            1 row in set (0.04 sec)
             
            mysql> drop table if exists `t1`;
            Query OK, 0 rows affected (0.19 sec)
             
            mysql>
            mysql> CREATE TABLE `t1` (
                ->   `a` int(11) DEFAULT NULL,
                ->   `b` timestamp AS (a=1) VIRTUAL NULL ON UPDATE CURRENT_TIMESTAMP
                -> ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
            ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NULL ON UPDATE CURRENT_TIMESTAMP
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1' at line 3
            mysql>

            sbester1 sbester1 added a comment - The problem is very simple. Look at it, you cannot create a table shown by 'show create table': mysql> create table t1(a int, b timestamp as (a=1) virtual)engine=innodb; Query OK, 0 rows affected (0.39 sec)   mysql> show create table t1; +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ | t1 | CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL, `b` timestamp AS (a=1) VIRTUAL NULL ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=latin1 | +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.04 sec)   mysql> drop table if exists `t1`; Query OK, 0 rows affected (0.19 sec)   mysql> mysql> CREATE TABLE `t1` ( -> `a` int(11) DEFAULT NULL, -> `b` timestamp AS (a=1) VIRTUAL NULL ON UPDATE CURRENT_TIMESTAMP -> ) ENGINE=InnoDB DEFAULT CHARSET=latin1; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NULL ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=latin1' at line 3 mysql>
            danblack Daniel Black added a comment -

            works in 10.1 - was fixed in MDEV-8441

            MariaDB [test]> select @@version;
            +--------------------+
            | @@version          |
            +--------------------+
            | 10.1.8-MariaDB-log |
            +--------------------+
            1 row in set (0.00 sec)
             
            MariaDB [test]> create table t1(a int, b timestamp as (a=1) virtual)engine=innodb;
            Query OK, 0 rows affected (0.00 sec)
             
            MariaDB [test]> show create table t1;
            +-------+-------------------------------------------------------------------------------------------------------------------------+
            | Table | Create Table                                                                                                            |
            +-------+-------------------------------------------------------------------------------------------------------------------------+
            | t1    | CREATE TABLE `t1` (
              `a` int(11) DEFAULT NULL,
              `b` timestamp AS (a=1) VIRTUAL
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
            +-------+-------------------------------------------------------------------------------------------------------------------------+
            1 row in set (0.00 sec)
             
            MariaDB [test]> drop table t1;CREATE TABLE `t1` (
            Query OK, 0 rows affected (0.01 sec)
             
                ->   `a` int(11) DEFAULT NULL,
                ->   `b` timestamp AS (a=1) VIRTUAL
                -> ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
            Query OK, 0 rows affected (0.00 sec)

            MariaDB [test]> select @@version
                -> ;
            +---------------------+
            | @@version           |
            +---------------------+
            | 10.0.22-MariaDB-log |
            +---------------------+
            1 row in set (0.00 sec)
             
            MariaDB [test]> create table t1(a int, b timestamp as (a=1) virtual)engine=innodb;
            Query OK, 0 rows affected (0.00 sec)
             
            MariaDB [test]> show create table t1;
            +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
            | Table | Create Table                                                                                                                                             |
            +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
            | t1    | CREATE TABLE `t1` (
              `a` int(11) DEFAULT NULL,
              `b` timestamp AS (a=1) VIRTUAL NULL ON UPDATE CURRENT_TIMESTAMP
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
            1 row in set (0.00 sec)

            danblack Daniel Black added a comment - works in 10.1 - was fixed in MDEV-8441 MariaDB [test]> select @@version; +--------------------+ | @@version | +--------------------+ | 10.1.8-MariaDB-log | +--------------------+ 1 row in set (0.00 sec)   MariaDB [test]> create table t1(a int, b timestamp as (a=1) virtual)engine=innodb; Query OK, 0 rows affected (0.00 sec)   MariaDB [test]> show create table t1; +-------+-------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+-------------------------------------------------------------------------------------------------------------------------+ | t1 | CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL, `b` timestamp AS (a=1) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 | +-------+-------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)   MariaDB [test]> drop table t1;CREATE TABLE `t1` ( Query OK, 0 rows affected (0.01 sec)   -> `a` int(11) DEFAULT NULL, -> `b` timestamp AS (a=1) VIRTUAL -> ) ENGINE=InnoDB DEFAULT CHARSET=latin1; Query OK, 0 rows affected (0.00 sec) MariaDB [test]> select @@version -> ; +---------------------+ | @@version | +---------------------+ | 10.0.22-MariaDB-log | +---------------------+ 1 row in set (0.00 sec)   MariaDB [test]> create table t1(a int, b timestamp as (a=1) virtual)engine=innodb; Query OK, 0 rows affected (0.00 sec)   MariaDB [test]> show create table t1; +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ | t1 | CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL, `b` timestamp AS (a=1) VIRTUAL NULL ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=latin1 | +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)

            People

              Unassigned Unassigned
              sbester1 sbester1
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.