[MDEV-452] Add full support for auto-initialized/updated timestamp and datetime Created: 2012-08-14 Updated: 2021-12-27 Due: 2012-12-13 Resolved: 2012-12-14 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Fix Version/s: | 10.0.1 |
| Type: | Task | Priority: | Major |
| Reporter: | Timour Katchaounov (Inactive) | Assignee: | Timour Katchaounov (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||||||
| Description |
|
The task is to extract and backport all changes from MySQL 5.6 that move timestamp handling from the handler interface to the server. The change was done by: There is no public WL, however there is documentation: First goal is to evaluate MySQL's patch, whether it makes sense to backport it, or to reimplement it. Additional patches to investigate: Possibly the following patch is related: In addition, MySQL 5.6.6 adds the following system variable, and corresponding change in behavior: Since MySQL 5.6.6 is not Launchpad yet, it seems that the above is implemented by the following patches:
|
| Comments |
| Comment by Timour Katchaounov (Inactive) [ 2012-08-15 ] |
|
= The feature The feature generalizes all the possible ways to set the default value, and to update automatically the value of both TIMESTAMP and DATETIME fields. It makes the clauses DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP applicable to both TIMESTAMP and DATETIME fields, and allows to specify the default value as well as the update value on any TIMESTAMP and DATETIME field in the same table. For full usability, the feature should be paired together with the system variable sysvar_explicit_defaults_for_timestamp from MySQL 5.6.6 that deprecates the implicit default values of TIMESTAMP fileds, and results in NULL behavior typical for other data types. Therefore from feature perspective, this seems to useful. Backporting this feature will also allow MariaDB to be compatible in this respect with future MySQL versions. = The code The part of the diff related to code changes is 6096 lines, however only 4697 lines are related to changes in the server, the rest is unit testing code. Unfortunately until looking at this code I was totally unfamiliar with this area, therefore my analysis is not very deep. From what I could tell by reading the patch:
Backporting the patch mechanically should be possible in 2-3 days, then we need to allocate time to backport the test cases, and to test the final result. With my current background I am not able to tell if there is a simpler and/or more ellegant way to implement this functionality. |
| Comment by Timour Katchaounov (Inactive) [ 2012-08-17 ] |
|
Potential problems:
|
| Comment by Timour Katchaounov (Inactive) [ 2012-08-18 ] |
|
Second opinion after a first attempt for a backport. In summary: the MySQL patch cannot be used as it is. Problems with the MySQL patch:
Therefore I suggest that the backport is done it several steps:
|
| Comment by Timour Katchaounov (Inactive) [ 2012-08-22 ] |
|
Current state: On hasky:/tmp there is an archive mdev-452-mysql-timestamp.tar.gz with the files mysql-wl-5874.diff - original MySQL patch |
| Comment by Timour Katchaounov (Inactive) [ 2012-08-22 ] |
|
Suggestion how to implement the feature in MariaDB.
The above is in contrast with MySQL, where the set of fields to be auto-updated/inserted is determined by a loop over all table fields for each INSERT/UPDATE operation. |
| Comment by Michael Widenius [ 2012-08-22 ] |
|
We can in the .frm table store the number of fields that have an init function/timestamp. We need also to think how we continue this task and handle arbitrary init expression. Should not be that hard as we can reuse the virtual columns code for this. |
| Comment by Sergei Petrunia [ 2012-08-22 ] |
|
I wondering if it is a good idea to store in .frm file things that can be easily calculated when opening the table. Experience with virtual columns (lots of small bugs here-and-there, and finally - not much use in production so far) speaks against implementing anything else of this sort. |
| Comment by Rasmus Johansson (Inactive) [ 2012-08-28 ] |
|
Changing Due date since Timour is on vacation. Will talk to Monty about it since this task was initiated by him. |
| Comment by Timour Katchaounov (Inactive) [ 2012-10-11 ] |
|
Following Serg's advice, I reverted the change: |
| Comment by Timour Katchaounov (Inactive) [ 2012-10-17 ] |
|
Since this feature is reimplemented, because we thought that MySQL's implementation is both too complicated, and not efficient, it is quite interesting to compare the two implementations code wise. MariaDB:
MySQL:
I plan to add some more comments, and do some more code cleanup, so the number above may change a bit, but not likely too much. |
| Comment by Timour Katchaounov (Inactive) [ 2012-10-18 ] |
|
Reassigned to Serg for review. |
| Comment by Timour Katchaounov (Inactive) [ 2012-10-24 ] |
|
This MySQL bug describes the problem with LOAD semantics wrt default functions/values: |
| Comment by Timour Katchaounov (Inactive) [ 2012-12-14 ] |
|
Pushed to 10.0-base. |