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

Please remove automatic TIMESTAMP update behaviour

    XMLWordPrintable

Details

    Description

      I was going to report this bug:

      CREATE TABLE t (
        id INTEGER NOT NULL,
        t1 TIMESTAMP NOT NULL,
        t2 TIMESTAMP,
        CONSTRAINT pk_t PRIMARY KEY (id)
      );
       
      INSERT INTO t (id, t1) 
      VALUES (1, timestamp '1970-01-01 01:00:38.0');
       
      UPDATE t 
      SET
        t.t2 = timestamp '1970-01-01 01:02:10.0';
        
      SELECT * FROM t;
      

      Clearly, I don't want the result to be what it currently is:

      id t1 t2
      1 2022-05-04 13:57:45.000 1970-01-01 01:02:10.000

      It's so easy to achieve this behaviour if I wanted it by explicitly specifying the default. It's so hard to remember that this feature exists, having spent yet another 30 minutes debugging my own code until I was reminded of this:
      https://mariadb.com/kb/en/timestamp/#automatic-values

      It's very random, why would the first TIMESTAMP ever be special? Why not the last? Or the fifth? What about DATETIME, why doesn't it apply there?

      I strongly suggest you remove this "feature," which looks like a bug to me every time I run into it, and it's really not the first time. Users can very easily specify DEFAULT expressions themselves

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              lukas.eder Lukas Eder
              Votes:
              6 Vote for this issue
              Watchers:
              8 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.