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

session: support 'GLOBAL SCOPE' for tidb_enable_table_partition #14062

Merged
merged 4 commits into from
Dec 17, 2019

Conversation

bb7133
Copy link
Member

@bb7133 bb7133 commented Dec 16, 2019

What problem does this PR solve?

This PR tries to support global scope for TiDB system variable tidb_enable_table_partition. Sometimes users may need to disable TABLE PARTITIONS for a TiDB cluster, at this time, setting tidb_enable_table_partition to off at global scope will be convenient.

What is changed and how it works?

Add missing scope.

Check List

Tests

  • Unit test
  • Manual test (add detailed scripts or steps below)
tidb> show variables like '%partition%';                                                                                                                                                    +-----------------------------+-------+
| Variable_name               | Value |
+-----------------------------+-------+
| tidb_enable_table_partition | on    |
+-----------------------------+-------+
1 row in set (0.01 sec)

tidb> set global tidb_enable_table_partition=off;
Query OK, 0 rows affected (0.00 sec)

tidb> select @@global.tidb_enable_table_partition;
+--------------------------------------+
| @@global.tidb_enable_table_partition |
+--------------------------------------+
| off                                  |
+--------------------------------------+

tidb> select @@tidb_enable_table_partition;
+-------------------------------+
| @@tidb_enable_table_partition |
+-------------------------------+
| on                            |
+-------------------------------+
1 row in set (0.00 sec)

(Start a new session)
tidb> select @@tidb_enable_table_partition;
+-------------------------------+
| @@tidb_enable_table_partition |
+-------------------------------+
| off                           |
+-------------------------------+

tidb> CREATE TABLE e2 (
    ->     id INT NOT NULL,
    ->     fname VARCHAR(30),
    ->     lname VARCHAR(30),
    ->     hired DATE NOT NULL DEFAULT '1970-01-01',
    ->     separated DATE NOT NULL DEFAULT '9999-12-31',
    ->     job_code INT NOT NULL,
    ->     store_id INT NOT NULL
    -> )
    -> 
    -> PARTITION BY RANGE (store_id) (
    ->     PARTITION p0 VALUES LESS THAN (6),
    ->     PARTITION p1 VALUES LESS THAN (11),
    ->     PARTITION p2 VALUES LESS THAN (16),
    ->     PARTITION p3 VALUES LESS THAN (21)
    -> );
Query OK, 0 rows affected, 1 warning (0.02 sec)

tidb> show warnings;
+---------+------+------------------------------------------------------------------------------------------------------------------------------------------+
| Level   | Code | Message                                                                                                                                  |
+---------+------+------------------------------------------------------------------------------------------------------------------------------------------+
| Warning | 8200 | Partitions are ignored because Table Partition is disabled, please set 'tidb_enable_table_partition' is if you need to need to enable it |
+---------+------+------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

tidb> explain select * from e2 where store_id > 15 ;
+---------------------+----------+-----------+-------------------------------------------------------------+
| id                  | count    | task      | operator info                                               |
+---------------------+----------+-----------+-------------------------------------------------------------+
| TableReader_7       | 3333.33  | root      | data:Selection_6                                            |
| └─Selection_6       | 3333.33  | cop[tikv] | gt(test.e2.store_id, 15)                                    |
|   └─TableScan_5     | 10000.00 | cop[tikv] | table:e2, range:[-inf,+inf], keep order:false, stats:pseudo |
+---------------------+----------+-----------+-------------------------------------------------------------+
3 rows in set (0.01 sec)

Code changes

  • Has exported variable/fields change

Side effects

  • NA

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

Release note

  • Support 'GLOBAL SCOPE' for tidb_enable_table_partition

@bb7133 bb7133 added type/enhancement The issue or PR belongs to an enhancement. needs-cherry-pick-3.0 labels Dec 16, 2019
@codecov
Copy link

codecov bot commented Dec 16, 2019

Codecov Report

Merging #14062 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #14062   +/-   ##
===========================================
  Coverage   80.2104%   80.2104%           
===========================================
  Files           483        483           
  Lines        121620     121620           
===========================================
  Hits          97552      97552           
  Misses        16318      16318           
  Partials       7750       7750

Copy link
Contributor

@lonng lonng left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@AilinKid AilinKid left a comment

Choose a reason for hiding this comment

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

LGTM

tidb> show warnings;                                                                                                                                                                        +---------+------+---------------------------------------------------+
| Level   | Code | Message                                           |
+---------+------+---------------------------------------------------+
| Warning | 8200 | Unsupported partition type, treat as normal table |
+---------+------+---------------------------------------------------+

the warning here is not suitable~

@bb7133 bb7133 force-pushed the bb7133/global_partition_vars branch 2 times, most recently from df111f9 to f079dfc Compare December 16, 2019 03:21
@bb7133
Copy link
Member Author

bb7133 commented Dec 16, 2019

LGTM

tidb> show warnings;                                                                                                                                                                        +---------+------+---------------------------------------------------+
| Level   | Code | Message                                           |
+---------+------+---------------------------------------------------+
| Warning | 8200 | Unsupported partition type, treat as normal table |
+---------+------+---------------------------------------------------+

the warning here is not suitable~

Addressed, PTAL

@bb7133 bb7133 force-pushed the bb7133/global_partition_vars branch from f079dfc to f9af11d Compare December 16, 2019 03:29
Copy link
Contributor

@AilinKid AilinKid left a comment

Choose a reason for hiding this comment

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

LGTM

@tiancaiamao
Copy link
Contributor

LGTM

@bb7133 bb7133 added status/can-merge Indicates a PR has been approved by a committer. and removed status/DNM labels Dec 17, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Dec 17, 2019

/run-all-tests

@sre-bot sre-bot merged commit 881038e into pingcap:master Dec 17, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Dec 17, 2019

cherry pick to release-3.0 failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/can-merge Indicates a PR has been approved by a committer. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants