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

In NO_ZERO_DATE mode, multiple timestamp fields with no default can't be created

    XMLWordPrintable

Details

    Description

      MariaDB [test]> set sql_mode='';
      Query OK, 0 rows affected (0.00 sec)
       
      MariaDB [test]> create table t1(a timestamp, b timestamp);
      Query OK, 0 rows affected (0.11 sec)
       
      MariaDB [test]> set sql_mode = 'NO_ZERO_DATE';
      Query OK, 0 rows affected (0.00 sec)
       
      MariaDB [test]> create table t2(a timestamp, b timestamp);
      ERROR 1067 (42000): Invalid default value for 'b'
       
      MariaDB [test]> create table t2(a timestamp, b int, c timestamp);
      ERROR 1067 (42000): Invalid default value for 'c'
       
      MariaDB [test]> create table t2(a timestamp);
      Query OK, 0 rows affected (0.07 sec)
      

      Index creation is affected as well.

      MariaDB [test]> set sql_mode='';
      Query OK, 0 rows affected (0.00 sec)
       
      MariaDB [test]> create table t1(a timestamp, b timestamp);
      Query OK, 0 rows affected (0.06 sec)
       
      MariaDB [test]> set sql_mode='NO_ZERO_DATE';
      Query OK, 0 rows affected (0.00 sec)
       
      MariaDB [test]> create index idx on t1(a);
      ERROR 1067 (42000): Invalid default value for 'b'
       
      MariaDB [test]> set sql_mode='NO_ZERO_DATE,STRICT_TRANS_TABLES';
      Query OK, 0 rows affected (0.01 sec)
       
      MariaDB [test]> create index idx on t1(a);
      ERROR 1292 (22007): Incorrect datetime value: '0000-00-00 00:00:00' for column 'b' at row 1
      

      Also, it seems impossible to use current_timestamp in CREATE TABLE .. ON UPDATE.

      MariaDB [test]> set sql_mode = 'NO_ZERO_DATE';
      Query OK, 0 rows affected (0.00 sec)
       
      MariaDB [test]> create table t1 (a timestamp(5) on update current_timestamp(5));
      ERROR 1067 (42000): Invalid default value for 'a'
       
      MariaDB [test]> create table t1 (a timestamp(5) on update current_timestamp(4));
      ERROR 1294 (HY000): Invalid ON UPDATE clause for 'a' column
       
      MariaDB [test]> create table t1 (a timestamp(5) on update current_timestamp(6));
      ERROR 1067 (42000): Invalid default value for 'a'
       
      MariaDB [test]> create table t1 (a timestamp on update current_timestamp);
      ERROR 1067 (42000): Invalid default value for 'a'
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              nirbhay_c Nirbhay Choubey (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.