Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: support list columns partition table #24

Merged
merged 3 commits into from
Oct 14, 2020

Conversation

crazycs520
Copy link
Collaborator

@crazycs520 crazycs520 commented Oct 12, 2020

What problem does this PR solve?

related parser: pingcap/parser#1047

Support create,insert/delete/update/select,show create table statement for list partition table.

Here is an example:

test> create table t (id int) partition by list  (id) (
   ->     partition p0 values in (1,2),
   ->     partition p1 values in (3,4),
   ->     partition p3 values in (5,null)
   ->     );
Query OK, 0 rows affected
Time: 0.006s
test> insert into t values (1),(3),(5),(null);
Query OK, 4 rows affected
Time: 0.004s
test> insert into t values (6);
(1526, 'Table has no partition for value 6')
test> select * from t partition (p0);
+----+
| id |
+----+
| 1  |
+----+
1 row in set
Time: 0.011s
test> delete from t partition (p0);
Query OK, 1 row affected
Time: 0.001s
test> select * from t;
+--------+
| id     |
+--------+
| 3      |
| 5      |
| <null> |
+--------+
3 rows in set
Time: 0.011s

list columns partition

test> create table t (id int, name varchar(10)) partition by list columns (id,name) (
   ->     partition p0 values in ((1,'a'),(2,'b')),
   ->         partition p1 values in ((3,'c'),(4,'d')),
   ->             partition p3 values in ((5,'e'),(null,null))
   ->             );
Query OK, 0 rows affected
Time: 0.008s
test> insert into t values (1, 'a'),(2,'b'),(null,null);
Query OK, 3 rows affected
Time: 0.004s
test> insert into t values (100,'z');
(1526, 'Table has no partition for value from column_list')
test> select * from t partition (p0);
+----+------+
| id | name |
+----+------+
| 1  | a    |
| 2  | b    |
+----+------+
2 rows in set
Time: 0.011s
test> delete from t partition (p0);
Query OK, 2 rows affected
Time: 0.001s
test> select * from t;
+--------+--------+
| id     | name   |
+--------+--------+
| <null> | <null> |
+--------+--------+
1 row in set
Time: 0.011s
test> show create table t;
+-------+-------------------------------------------------------------+
| Table | Create Table                                                |
+-------+-------------------------------------------------------------+
| t     | CREATE TABLE `t` (                                          |
|       |   `id` int(11) DEFAULT NULL,                                |
|       |   `name` varchar(10) DEFAULT NULL                           |
|       | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
|       | PARTITION BY LIST COLUMNS(id,name) (                        |
|       |   PARTITION `p0` VALUES IN ((1,"a"),(2,"b")),               |
|       |   PARTITION `p1` VALUES IN ((3,"c"),(4,"d")),               |
|       |   PARTITION `p3` VALUES IN ((5,"e"),(NULL,NULL))            |
|       | )                                                           |
+-------+-------------------------------------------------------------+

What is changed and how it works?

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:

Check List

Tests

  • Unit test

Side effects

  • Performance regression
    • Consumes more CPU
    • Consumes more MEM

Release note

  • Support list partition table

Signed-off-by: crazycs520 <crazycs520@gmail.com>
Signed-off-by: crazycs520 <crazycs520@gmail.com>
Signed-off-by: crazycs520 <crazycs520@gmail.com>
@crazycs520 crazycs520 changed the title *: support list partition table *: support list columns partition table Oct 12, 2020
@tiancaiamao
Copy link
Collaborator

LGTM

@crazycs520 crazycs520 merged commit e949d65 into bb7133:4.0-itai Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants