Skip to content

*: add show table regions syntax#349

Merged
tiancaiamao merged 7 commits intopingcap:masterfrom
crazycs520:split_status
Jul 2, 2019
Merged

*: add show table regions syntax#349
tiancaiamao merged 7 commits intopingcap:masterfrom
crazycs520:split_status

Conversation

@crazycs520
Copy link
Copy Markdown
Contributor

@crazycs520 crazycs520 commented Jun 10, 2019

What problem does this PR solve?

Add sql syntax to check split table region status.

SHOW TABLE [table_name] REGIONS

SHOW TABLE [table_name] INDEX [index_name] REGIONS;

What is changed and how it works?

eg

tidb > create table t (a int, b int, index idx(a));
Query OK, 0 rows affected
Time: 0.077s
tidb > split table t between (0) and (10000000000000000) regions 10;
Query OK, 0 rows affected
Time: 0.046s
tidb > split table t index idx between (0) and (1000000000) regions 4;
Query OK, 0 rows affected
Time: 0.408s
tidb> show table t regions;
+-----------+---------------------------------------+---------------------------------------+-----------+---------------------+------------+
| REGION_ID | START_KEY                             | END_Key                               | LEADER_ID | PEERS               | SCATTERING |
+-----------+---------------------------------------+---------------------------------------+-----------+---------------------+------------+
| 23273     | t_6068_i_1_03800000002cb4178003000000 | t_6068_r_1000000000000000             | 23276     | 23274, 23275, 23276 | 0          |
| 23277     | t_6068_r_1000000000000000             | t_6068_r_2000000000000000             | 23280     | 23280, 23281, 23282 | 0          |
| 23283     | t_6068_r_2000000000000000             | t_6068_r_3000000000000000             | 23284     | 23284, 23285, 23287 | 0          |
| 23288     | t_6068_r_3000000000000000             | t_6068_r_4000000000000000             | 23291     | 23290, 23291, 23292 | 0          |
| 23293     | t_6068_r_4000000000000000             | t_6068_r_5000000000000000             | 23297     | 23294, 23297, 23298 | 0          |
| 23299     | t_6068_r_5000000000000000             | t_6068_r_6000000000000000             | 23301     | 23300, 23301, 23302 | 0          |
| 23303     | t_6068_r_6000000000000000             | t_6068_r_7000000000000000             | 23307     | 23306, 23307, 23308 | 0          |
| 23309     | t_6068_r_7000000000000000             | t_6068_r_8000000000000000             | 23313     | 23310, 23311, 23313 | 0          |
| 23314     | t_6068_r_8000000000000000             | t_6068_r_9000000000000000             | 23318     | 23316, 23317, 23318 | 0          |
| 22571     | t_6068_r_9000000000000000             |                                       | 22573     | 22572, 22573, 22575 | 0          |
| 23325     | t_6068_i_1_                           | t_6068_i_1_03800000000ee6b28003000000 | 23328     | 23326, 23327, 23328 | 0          |
| 23329     | t_6068_i_1_03800000000ee6b28003000000 | t_6068_i_1_03800000001dcd650003000000 | 23332     | 23332, 23333, 23334 | 0          |
| 23335     | t_6068_i_1_03800000001dcd650003000000 | t_6068_i_1_03800000002cb4178003000000 | 23339     | 23336, 23337, 23339 | 0          |
+-----------+---------------------------------------+---------------------------------------+-----------+---------------------+------------+
13 rows in set
Time: 0.013s
tidb> show table t index idx regions;
+-----------+---------------------------------------+---------------------------------------+-----------+---------------------+------------+
| REGION_ID | START_KEY                             | END_Key                               | LEADER_ID | PEERS               | SCATTERING |
+-----------+---------------------------------------+---------------------------------------+-----------+---------------------+------------+
| 23325     | t_6068_i_1_                           | t_6068_i_1_03800000000ee6b28003000000 | 23328     | 23326, 23327, 23328 | 0          |
| 23329     | t_6068_i_1_03800000000ee6b28003000000 | t_6068_i_1_03800000001dcd650003000000 | 23332     | 23332, 23333, 23334 | 0          |
| 23335     | t_6068_i_1_03800000001dcd650003000000 | t_6068_i_1_03800000002cb4178003000000 | 23339     | 23336, 23337, 23339 | 0          |
| 23273     | t_6068_i_1_03800000002cb4178003000000 | t_6068_r_1000000000000000             | 23276     | 23274, 23275, 23276 | 0          |
+-----------+---------------------------------------+---------------------------------------+-----------+---------------------+------------+

Check List

Tests

  • Unit test

Code changes

@codecov

This comment has been minimized.

@crazycs520 crazycs520 changed the title *: add split table status syntax *: add show table regions syntax Jun 11, 2019
Copy link
Copy Markdown
Contributor

@kennytm kennytm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest LGTM

Comment thread parser.y Outdated
Comment thread parser.y Outdated
Comment thread parser.y
| "SHOW" "TABLE" TableName "REGIONS"
{
$$ = &ast.ShowStmt{
Tp: ast.ShowRegions,
Copy link
Copy Markdown
Contributor

@winkyao winkyao Jun 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please adjust the indent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Copy link
Copy Markdown
Contributor

@winkyao winkyao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest LGTM

Copy link
Copy Markdown
Member

@bb7133 bb7133 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kennytm
Copy link
Copy Markdown
Contributor

kennytm commented Jun 13, 2019

Needs to fix parser.go conflict again 🤷

@tiancaiamao
Copy link
Copy Markdown
Collaborator

LGTM
Please address conflicts @crazycs520

@tiancaiamao tiancaiamao merged commit f9dfedc into pingcap:master Jul 2, 2019
crazycs520 added a commit to crazycs520/parser that referenced this pull request Jul 12, 2019
'SHOW TABLE table_name [INDEX] [index_name] REGIONS'
crazycs520 added a commit to crazycs520/parser that referenced this pull request Jul 12, 2019
bb7133 pushed a commit that referenced this pull request Jul 12, 2019
tiancaiamao pushed a commit to tiancaiamao/parser that referenced this pull request Apr 27, 2021
'SHOW TABLE table_name [INDEX] [index_name] REGIONS'
lyonzhi pushed a commit to lyonzhi/parser that referenced this pull request Apr 25, 2024
'SHOW TABLE table_name [INDEX] [index_name] REGIONS'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants