[MDEV-19218] EXCHANGE PARTITION and versioning Created: 2019-04-09  Updated: 2019-11-28

Status: Open
Project: MariaDB Server
Component/s: Partitioning, Versioned Tables
Fix Version/s: None

Type: Task Priority: Major
Reporter: Sergei Golubchik Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Test whether ALTER TABLE ... EXCHANGE PARTITION works with tables partitioned by history.

Make it to work, if it doesn't.



 Comments   
Comment by Elena Stepanova [ 2019-04-09 ]

It does seem to work at the first glance.
Of course it needs proper testing, but conceptually it seems to work:

MariaDB [test]> create table t1 (a int) with system versioning partition by system_time (partition p0 history, partition pc current);
Query OK, 0 rows affected (0.077 sec)
 
MariaDB [test]> insert into t1 values (1);
Query OK, 1 row affected (0.016 sec)
 
MariaDB [test]> update t1 set a = 2;
Query OK, 1 row affected (0.011 sec)
Rows matched: 1  Changed: 1  Inserted: 1  Warnings: 0
 
MariaDB [test]> create or replace table t2 like t1;
Query OK, 0 rows affected (0.107 sec)
 
MariaDB [test]> alter table t2 remove partitioning;
Query OK, 0 rows affected (0.190 sec)              
Records: 0  Duplicates: 0  Warnings: 0
 
MariaDB [test]> alter table t1 exchange partition p0 with table t2;
Query OK, 0 rows affected (0.196 sec)
 
MariaDB [test]> select *, row_start, row_end from t1 for system_time all;
+------+----------------------------+----------------------------+
| a    | row_start                  | row_end                    |
+------+----------------------------+----------------------------+
|    2 | 2019-04-09 11:30:18.041118 | 2038-01-19 05:14:07.999999 |
+------+----------------------------+----------------------------+
1 row in set (0.003 sec)
 
MariaDB [test]> select *, row_start, row_end from t2 for system_time all;
+------+----------------------------+----------------------------+
| a    | row_start                  | row_end                    |
+------+----------------------------+----------------------------+
|    1 | 2019-04-09 11:30:12.247797 | 2019-04-09 11:30:18.041118 |
+------+----------------------------+----------------------------+
1 row in set (0.004 sec)
 
MariaDB [test]> update t1 set a = 3;
Query OK, 1 row affected (0.011 sec)
Rows matched: 1  Changed: 1  Inserted: 1  Warnings: 0
 
MariaDB [test]> truncate table t2;
Query OK, 0 rows affected (0.075 sec)
 
MariaDB [test]> alter table t1 exchange partition pc with table t2;
Query OK, 0 rows affected (0.099 sec)
 
MariaDB [test]> select *, row_start, row_end from t1 for system_time all;
+------+----------------------------+----------------------------+
| a    | row_start                  | row_end                    |
+------+----------------------------+----------------------------+
|    2 | 2019-04-09 11:30:18.041118 | 2019-04-09 11:34:30.988074 |
+------+----------------------------+----------------------------+
1 row in set (0.003 sec)
 
MariaDB [test]> select *, row_start, row_end from t2 for system_time all;
+------+----------------------------+----------------------------+
| a    | row_start                  | row_end                    |
+------+----------------------------+----------------------------+
|    3 | 2019-04-09 11:34:30.988074 | 2038-01-19 05:14:07.999999 |
+------+----------------------------+----------------------------+
1 row in set (0.004 sec)

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