[MDEV-16236] Make system versioning use standard compliant transaction timestamps Created: 2018-05-21 Updated: 2018-05-21 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | Versioned Tables |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major |
| Reporter: | Markus Winand | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Description |
|
The SQL standard requires the ROW START and ROW END column to be populated by the "transaction timestamp" which has the same value for each data change done in the same transaction. Quoting SQL-2:2016, $4.41.3 (Properties of SQL-transactions):
MariaDB seems to use the current time for each statement even when executed in the same transaction. One consequence of this requirement is that one transaction can at most create one new row version for each row (otherwise the timestamps would overlap so that a AS OF query might see more than one version). This is also clearly covered in the standard—e.g. for UPDATE in SQL-2:2016, 15.13 (Effect of replacing rows in base tables) 9 a ii B versus C. The following script shows the wrong behaviour:
|
| Comments |
| Comment by Sergei Golubchik [ 2018-05-21 ] | |||
|
Correct. This might change in the future, but at the moment if you want "transaction timestamp" in the above sense you need to declare your start_ts and end_ts columns as BIGINT UNSIGNED. In this setup if you want to see timestamps you can use a special function (and you'll need to load the versioning plugin to access it):
But all AS OF queries will work as expected with timestamps, you won't need to specify integer values in AS OF. While at the moment it works as intended, I'll keep this bug report open, in case we'll change the behavior to be more standard compliant. |