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

ALTER TABLE .. SET DEFAULT produces invalid table structure

    XMLWordPrintable

    Details

      Description

      Set to Minor because only 10.2 and 10.3 are affected.

      CREATE TABLE t (b TEXT NOT NULL);
      ALTER TABLE t ALTER b SET DEFAULT NULL;
      SHOW CREATE TABLE t;
      

      The ALTER is obviously wrong, as it attempts to set the default value to NULL while the column is not null. But it works, and the resulting table is this:

      10.2 676987c4

      CREATE TABLE `t` (
        `b` text NOT NULL DEFAULT NULL
      ) ENGINE=MyISAM DEFAULT CHARSET=latin1
      

      Reproducible on 10.2-10.3.
      Not reproducible on 10.4-10.6.

      An attempt to execute this CREATE statement on any version, including the affected ones, expectedly ends with an error:

      query 'CREATE TABLE `t` (
      `b` text NOT NULL DEFAULT NULL
      ) ENGINE=MyISAM DEFAULT CHARSET=latin1
      ' failed: 1067: Invalid default value for 'b'
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Git Integration