10.2+ Integer DEFAULT values missing quotes (MDEV-15377)

[MDEV-15394] DEFAULT current_timestamp() discrepancy Created: 2018-02-23  Updated: 2018-04-15  Resolved: 2018-04-15

Status: Closed
Project: MariaDB Server
Component/s: Documentation, Server
Affects Version/s: 10.2
Fix Version/s: N/A

Type: Technical task Priority: Minor
Reporter: Nemanja Stambolic Assignee: Ian Gilfillan
Resolution: Fixed Votes: 0
Labels: None
Environment:

GNU/Linux


Issue Links:
PartOf
is part of MDEV-15377 10.2+ Integer DEFAULT values missing ... Closed
is part of MDEV-15390 information_schema returns quoted str... Closed
Relates
relates to MDEV-15407 DEFAULT NULL forced when no DEFAULT s... Closed

 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?



 Comments   
Comment by Nemanja Stambolic [ 2018-03-08 ]

Any comment on this?

Comment by Ian Gilfillan [ 2018-03-13 ]

serg can you comment on why this change was made?

Comment by Sergei Golubchik [ 2018-03-13 ]

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.

Comment by Elena Stepanova [ 2018-03-13 ]

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

Comment by Ian Gilfillan [ 2018-04-15 ]

Documented in https://mariadb.com/kb/en/library/now/

Generated at Thu Feb 08 08:20:57 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.