Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-15966

Behavior for TRUNCATE versioned table is not documented and not covered by tests

Details

    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.

      Attachments

        Issue Links

          Activity

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

            Naturally, DROP+CREATE does not preserve history.

            serg Sergei Golubchik added a comment - TRUNCATE is DDL, it's defined as DROP+CREATE, and it requires DROP privilege. Naturally, DROP+CREATE does not preserve history.

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

            kevg Eugene Kosov (Inactive) added a comment - TRUNCATE disallowed for system-versioned tables by standard in 14.10 <truncate table statement>

            Good point. Shall we do the same?

            serg Sergei Golubchik added a comment - Good point. Shall we do the same?

            I vote for the standard compliance.

            kevg Eugene Kosov (Inactive) added a comment - I vote for the standard compliance.
            greenman Ian Gilfillan added a comment -

            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.

            greenman Ian Gilfillan added a comment - 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.

            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.

            darkain Vincent Milum Jr added a comment - 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.

            People

              serg Sergei Golubchik
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              5 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.