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

SHOW CREATE TABLE returns corrupted info when using DEFAULT with an expresssion in some cases

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Cannot Reproduce
    • 10.2.1
    • 10.2.5
    • Virtual Columns
    • 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.

      Attachments

        Activity

          People

            serg Sergei Golubchik
            karlsson Anders Karlsson
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.