[MDEV-10458] SHOW CREATE TABLE returns corrupted info when using DEFAULT with an expresssion in some cases Created: 2016-07-28  Updated: 2017-03-22  Resolved: 2017-03-22

Status: Closed
Project: MariaDB Server
Component/s: Virtual Columns
Affects Version/s: 10.2.1
Fix Version/s: 10.2.5

Type: Bug Priority: Major
Reporter: Anders Karlsson Assignee: Sergei Golubchik
Resolution: Cannot Reproduce Votes: 0
Labels: 10.2-ga
Environment:

Linux x86_64



 Description   

When creating a table with two columns, the first one having a default with an expression, the running SHOW CREATE TABLE two times will corrupt the output on the second run:

> create table t(c1 char(19) not null default now(), c2 int);
> > show create table t;
+-------+-------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                  |
+-------+-------------------------------------------------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `c1` char(19) NOT NULL DEFAULT now(),
  `c2` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+-------------------------------------------------------------------------------------------------------------------------------+
> > show create table t;
+-------+-------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                  |
+-------+-------------------------------------------------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `c1` char(19) NOT NULL DEFAULT NULL ,
  `c2` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+-------------------------------------------------------------------------------------------------------------------------------+

Note that the default for column c1 got garbled in the second show create table. What ends up there depends on what the default expression is, in some cases it gets worse:

> create table t(c1 char(19) not null default uuid_short(), c2 int);
> show create table t;
+-------+--------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                         |
+-------+--------------------------------------------------------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `c1` char(19) NOT NULL DEFAULT uuid_short(),
  `c2` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+--------------------------------------------------------------------------------------------------------------------------------------+
> show create table t;
+-------+--------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                         |
+-------+--------------------------------------------------------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `c1` char(19) NOT NULL DEFAULT NULL short(),
  `c2` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+--------------------------------------------------------------------------------------------------------------------------------------+

Note that the returned CREATE TABLE is totally invalid here (DEFAULT NULL short()). The issue only seems to happen when there are at least 2 columns in the table.



 Comments   
Comment by Sergei Golubchik [ 2017-03-22 ]

I cannot repeat it. There were quite a few changes to DEFAULT handling since you've reported it, so it was probably fixed. Fell free to reopen the issue, if it wasn't.

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