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

Couldn't alter field with default value for make it not nullable.

    XMLWordPrintable

    Details

    • Sprint:
      10.1.6-2

      Description

      Reproduction:

      1) Create table

      CREATE TABLE `table2` (
        `i1` INT(10) UNSIGNED NOT NULL,
        `d1` TIMESTAMP NULL DEFAULT NULL
      ) ENGINE=INNODB;

      2) Fill table

      INSERT INTO table2 (i1) VALUES (1), (2), (3), (4), (5);

      3) Try Alter table with making field `d1` not nullable with default value CURRENT_TIMESTAMP

      ALTER TABLE `table2`   
        CHANGE `d1` `d1` TIMESTAMP DEFAULT CURRENT_TIMESTAMP  NOT NULL

      Error happens here:

      Error Code: 1138
      Invalid use of NULL value

      Expected that column `d1` will be filled with NOW() value

      SELECT @@sql_mode

      @@sql_mode                                                                                                                 
      ---------------------------------------------------------------------------------------------------------------------------
      NO_BACKSLASH_ESCAPES,STRICT_ALL_TABLES,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION  

      In continue bug https://mariadb.atlassian.net/browse/MDEV-6880 but also needed with already created fields.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jplindst Jan Lindström
              Reporter:
              mikhail Mikhail Gavrilov
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: