[MDEV-15966] Behavior for TRUNCATE versioned table is not documented and not covered by tests Created: 2018-04-21  Updated: 2022-05-02  Resolved: 2019-08-05

Status: Closed
Project: MariaDB Server
Component/s: Documentation, Versioned Tables
Affects Version/s: 10.3
Fix Version/s: 10.4.5

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Problem/Incident
causes MDEV-28439 Inconsistencies of TRUNCATE on SYSTEM... Open

 Description   

MariaDB [test]> select *, row_start, row_end from t3 for system_time all;
+------+----------------------------+----------------------------+
| a    | row_start                  | row_end                    |
+------+----------------------------+----------------------------+
|    1 | 2018-04-22 02:21:24.283521 | 2018-04-22 02:21:27.809661 |
|    2 | 2018-04-22 02:21:24.283521 | 2038-01-19 05:14:07.999999 |
+------+----------------------------+----------------------------+
2 rows in set (0.00 sec)
 
MariaDB [test]> truncate table t3;
Query OK, 0 rows affected (0.20 sec)
 
MariaDB [test]> select *, row_start, row_end from t3 for system_time all;
Empty set (0.00 sec)

TRUNCATE TABLE on a versioned table removes all table contents, including historical records. I can only assume it's expected behavior, I can't find it documented anywhere in the KB, and there is no MTR test for TRUNCATE – I found only one test which uses the command, partition.test, but it does not check the result of truncation, it only executes the statement as a regression test for a crash.

If it works as designed, please add a test and have it documented. If not, then please fix.



 Comments   
Comment by Sergei Golubchik [ 2018-04-25 ]

TRUNCATE is DDL, it's defined as DROP+CREATE, and it requires DROP privilege.

Naturally, DROP+CREATE does not preserve history.

Comment by Eugene Kosov (Inactive) [ 2018-04-25 ]

TRUNCATE disallowed for system-versioned tables by standard in 14.10 <truncate table statement>

Comment by Sergei Golubchik [ 2018-04-26 ]

Good point. Shall we do the same?

Comment by Eugene Kosov (Inactive) [ 2018-04-26 ]

I vote for the standard compliance.

Comment by Ian Gilfillan [ 2018-04-27 ]

Agree, TRUNCATE should not be permitted for system-versioned tables. I will document the current behaviour, and leave this task to be reassigned for implementation.

Comment by Vincent Milum Jr [ 2022-05-02 ]

I think this topic needs revisiting, as the documentation and implementation don't align, plus the fact that this was actually very useful functionality to have TRUNCATE support on SYSTEM VERSIONED tables.

I've opened MDEV-28439 to discuss this further along with all the details I've found so far.

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