[MDEV-5614] timestamp virtual column yields syntax error in show create table Created: 2014-02-04  Updated: 2015-11-04  Resolved: 2015-11-04

Status: Closed
Project: MariaDB Server
Component/s: Parser, Temporal Types
Affects Version/s: 5.3.12, 5.5.35, 10.0.7, 10.0.22
Fix Version/s: 10.1.8

Type: Bug Priority: Minor
Reporter: sbester1 Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Environment:

Linux x64


Issue Links:
Duplicate
duplicates MDEV-8441 Bad SHOW CREATE TABLE output for a ta... Closed

 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;



 Comments   
Comment by Sudheera Palihakkara [ 2014-02-05 ]

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

Comment by sbester1 [ 2014-02-05 ]

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>

Comment by Daniel Black [ 2015-11-03 ]

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)

Generated at Thu Feb 08 07:05:43 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.