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

            elenst Elena Stepanova created issue -
            elenst Elena Stepanova made changes -
            Field Original Value New Value
            Assignee Elena Stepanova [ elenst ] Alexander Krizhanovsky [ krizhanovsky ]
            krizhanovsky Alexander Krizhanovsky made changes -
            Assignee Alexander Krizhanovsky [ krizhanovsky ] Eugene Kosov [ kevg ]

            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.
            serg Sergei Golubchik made changes -
            Assignee Eugene Kosov [ kevg ] Ian Gilfillan [ greenman ]
            serg Sergei Golubchik made changes -
            Component/s Documentation [ 10903 ]
            serg Sergei Golubchik made changes -
            Fix Version/s N/A [ 14700 ]
            Fix Version/s 10.3 [ 22126 ]

            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.
            greenman Ian Gilfillan made changes -
            Assignee Ian Gilfillan [ greenman ]
            elenst Elena Stepanova made changes -
            Assignee Eugene Kosov [ kevg ]
            serg Sergei Golubchik made changes -
            Fix Version/s 10.3 [ 22126 ]
            Fix Version/s N/A [ 14700 ]
            serg Sergei Golubchik made changes -
            Status Open [ 1 ] Confirmed [ 10101 ]
            krizhanovsky Alexander Krizhanovsky made changes -
            Assignee Eugene Kosov [ kevg ] Nikita Malyavin [ nikitamalyavin ]
            nikitamalyavin Nikita Malyavin made changes -
            Status Confirmed [ 10101 ] In Progress [ 3 ]
            nikitamalyavin Nikita Malyavin made changes -
            Assignee Nikita Malyavin [ nikitamalyavin ] Sergei Golubchik [ serg ]
            Status In Progress [ 3 ] In Review [ 10002 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 10.4 [ 22408 ]
            serg Sergei Golubchik made changes -
            Status In Review [ 10002 ] Stalled [ 10000 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 10.4.5 [ 23311 ]
            Fix Version/s 10.3 [ 22126 ]
            Fix Version/s 10.4 [ 22408 ]
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 86705 ] MariaDB v4 [ 154215 ]
            darkain Vincent Milum Jr made changes -

            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.