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) #14091

Merged
merged 2 commits into from
Dec 20, 2019

Conversation

bb7133
Copy link
Member

@bb7133 bb7133 commented Dec 17, 2019

Cherry-pick #14062


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

Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

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

Please fix CI.

@bb7133
Copy link
Member Author

bb7133 commented Dec 20, 2019

/run-unit-test

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

@AilinKid AilinKid added the status/LGT1 Indicates that a PR has LGTM 1. label Dec 20, 2019
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, (error message begin with lower-case is more Golang idiomatic).

@bb7133 bb7133 added status/LGT2 Indicates that a PR has LGTM 2. status/can-merge Indicates a PR has been approved by a committer. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Dec 20, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Dec 20, 2019

/run-all-tests

@sre-bot sre-bot merged commit 9efbf48 into pingcap:release-3.0 Dec 20, 2019
@bb7133 bb7133 deleted the bb7133/cp-14062-3.0 branch December 29, 2023 18:43
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. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants