Details

    • Technical task
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • 10.2(EOL)
    • N/A
    • Documentation, Server
    • None
    • GNU/Linux

    Description

      Another linked discrepancy on this matter.

      10.0

      createdTS timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
      

      10.2

      createdTS timestamp NOT NULL DEFAULT current_timestamp()
      

      What is the background on this one? Standards compliance or it's nicer to use functions instead of built-in constants?

      Attachments

        Issue Links

          Activity

            Any comment on this?

            stamster Nemanja Stambolic added a comment - Any comment on this?
            greenman Ian Gilfillan added a comment -

            serg can you comment on why this change was made?

            greenman Ian Gilfillan added a comment - serg can you comment on why this change was made?

            It was a side effect, in a way. In earlier versions, the default could be either a constant or CURRENT_TIMESTAMP.

            Now it's just an expression, so the default value is printed like any expression is. See how CURRENT_TIMESTAMP is printed elsewhere:

            MariaDB [test]> explain extended select CURRENT_TIMESTAMP;
            +------+-------------+-------+------+---------------+------+---------+------+------+----------+----------------+
            | id   | select_type | table | type | possible_keys | key  | key_len | ref  | rows | filtered | Extra          |
            +------+-------------+-------+------+---------------+------+---------+------+------+----------+----------------+
            |    1 | SIMPLE      | NULL  | NULL | NULL          | NULL | NULL    | NULL | NULL |     NULL | No tables used |
            +------+-------------+-------+------+---------------+------+---------+------+------+----------+----------------+
            1 row in set, 1 warning (0.00 sec)
             
            Note (Code 1003): select current_timestamp() AS `CURRENT_TIMESTAMP`
            MariaDB [test]> create view v1 as SELECT CURRENT_TIMESTAMP; show create view v1;
            Query OK, 0 rows affected (0.00 sec)
             
            +------+-------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
            | View | Create View                                                                                                                               | character_set_client | collation_connection |
            +------+-------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
            | v1   | CREATE ALGORITHM=UNDEFINED DEFINER=`serg`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select current_timestamp() AS `CURRENT_TIMESTAMP` | utf8                 | utf8_general_ci      |
            +------+-------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
            1 row in set (0.00 sec)
            

            Now CURRENT_TIMESTAMP is consistently printed everywhere. In earlier versions, the sequence of letters "DEFAULT CURRENT_TIMESTAMP" was hard-coded, so CURRENT_TIMESTAMP was printed differently in DEFAULT as compared to all other cases.

            serg Sergei Golubchik added a comment - It was a side effect, in a way. In earlier versions, the default could be either a constant or CURRENT_TIMESTAMP. Now it's just an expression, so the default value is printed like any expression is. See how CURRENT_TIMESTAMP is printed elsewhere: MariaDB [test]> explain extended select CURRENT_TIMESTAMP; +------+-------------+-------+------+---------------+------+---------+------+------+----------+----------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +------+-------------+-------+------+---------------+------+---------+------+------+----------+----------------+ | 1 | SIMPLE | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | No tables used | +------+-------------+-------+------+---------------+------+---------+------+------+----------+----------------+ 1 row in set, 1 warning (0.00 sec)   Note (Code 1003): select current_timestamp() AS `CURRENT_TIMESTAMP` MariaDB [test]> create view v1 as SELECT CURRENT_TIMESTAMP; show create view v1; Query OK, 0 rows affected (0.00 sec)   +------+-------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+ | View | Create View | character_set_client | collation_connection | +------+-------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+ | v1 | CREATE ALGORITHM=UNDEFINED DEFINER=`serg`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select current_timestamp() AS `CURRENT_TIMESTAMP` | utf8 | utf8_general_ci | +------+-------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+ 1 row in set (0.00 sec) Now CURRENT_TIMESTAMP is consistently printed everywhere. In earlier versions, the sequence of letters "DEFAULT CURRENT_TIMESTAMP" was hard-coded, so CURRENT_TIMESTAMP was printed differently in DEFAULT as compared to all other cases.

            greenman, I think this is one of the questions (and answers) that deserve to be added to FAQ.

            elenst Elena Stepanova added a comment - greenman , I think this is one of the questions (and answers) that deserve to be added to FAQ.
            greenman Ian Gilfillan added a comment - Documented in https://mariadb.com/kb/en/library/now/

            People

              greenman Ian Gilfillan
              stamster Nemanja Stambolic
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.