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

ALTER COLUMN NOT NULL fails with "cannot convert NULL to non-constant DEFAULT" error even if default is constant when using INPLACE algorithm

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.3, 10.4, 10.3.37, 10.4.27, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11
    • 10.4, 10.5, 10.6
    • None
    • Ubuntu 18.04.1 LTS, Ubuntu 20.04.5 LTS

    Description

      Applying an online change for a column from NULL to NOT NULL using a constant default value fails with a "cannot convert NULL to non-constant DEFAULT".

      CREATE TABLE `test_seb` (
        `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
        `created` timestamp NULL DEFAULT NULL,
        PRIMARY KEY (`id`),
        KEY `created` (`created`)
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
       
      ALTER TABLE test_seb MODIFY created timestamp NOT NULL DEFAULT '2000-01-01 00:00:00', ALGORITHM=INPLACE;
       
      /* Error:
      SQL Error [1846] [0A000]: (conn:248597) ALGORITHM=INPLACE is not supported. Reason: cannot convert NULL to non-constant DEFAULT. Try ALGORITHM=COPY
      */
      

      Trying to apply a constant default before applying the NOT NULL change does not change the behavior.

      Attachments

        Activity

          People

            marko Marko Mäkelä
            svolle Sébastien Volle
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.