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

table: fix show index for the partitioned table #7346

Merged
merged 5 commits into from
Aug 10, 2018

Conversation

ciscoxll
Copy link
Contributor

@ciscoxll ciscoxll commented Aug 10, 2018

What have you changed? (mandatory)

  • fix show index for the partitioned table.
  • I want to get the IndexInfo from the partition table, but getting the IndexInfo is always empty.
  • Looking at the logs, it is normal for UpdateTable to update the IndexInfo.
  • Finally found, table partitioning no initializes the indices of the tableCommon.
  • Fix issue Can not show index for the partitioned table #7345

master branch

mysql> set @@tidb_enable_table_partition = 1;
Query OK, 0 rows affected (0.00 sec)

mysql> create table partition_drop_idx (
    ->         c1 int, c2 int, c3 int
    ->     )
    ->     partition by range( c1 ) (
    ->         partition p0 values less than (1990),
    ->         partition p1 values less than (1995),
    ->         partition p2 values less than (2000),
    ->         partition p3 values less than (2005),
    ->         partition p4 values less than (2010),
    ->         partition p5 values less than (2015)
    ->        );
Query OK, 0 rows affected (0.12 sec)

mysql> alter table partition_drop_idx add index idx1 (c1);
Query OK, 0 rows affected (0.04 sec)
mysql> show index from  partition_drop_idx;
Query OK, 0 rows affected (0.04 sec)

show-index branch

mysql> set @@tidb_enable_table_partition = 1;
Query OK, 0 rows affected (0.00 sec)

mysql> create table partition_drop_idx (
    ->         c1 int, c2 int, c3 int
    ->     )
    ->     partition by range( c1 ) (
    ->         partition p0 values less than (1990),
    ->         partition p1 values less than (1995),
    ->         partition p2 values less than (2000),
    ->         partition p3 values less than (2005),
    ->         partition p4 values less than (2010),
    ->         partition p5 values less than (2015)
    ->        );
Query OK, 0 rows affected (0.12 sec)

mysql> alter table partition_drop_idx add index idx1 (c1);
Query OK, 0 rows affected (0.04 sec)
mysql> show index from  partition_drop_idx;
+--------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table              | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+--------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| partition_drop_idx |          1 | idx1     |            1 | c1          | A         |           0 |     NULL | NULL   | YES  | BTREE      |         |               |
+--------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
1 row in set (0.00 sec)

What is the type of the changes? (mandatory)

Bug fix

  • Bug fix (non-breaking change which fixes an issue)

How has this PR been tested? (mandatory)

Unit tests.

Does this PR affect documentation (docs/docs-cn) update? (mandatory)

No

Does this PR affect tidb-ansible update? (mandatory)

No

Does this PR need to be added to the release notes? (mandatory)

No

@ciscoxll ciscoxll added type/bug The issue is confirmed as a bug. status/WIP labels Aug 10, 2018
Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

/run-all-tests

@winkyao
Copy link
Contributor

winkyao commented Aug 10, 2018

The fix is wrong.

@ciscoxll
Copy link
Contributor Author

@winkyao @tiancaiamao PTAL.

ddl/db_test.go Outdated
for _, pidx := range t.Indices() {
if pidx.Meta().Name.L == "idx1" {
idx1 = pidx
break
Copy link
Contributor

Choose a reason for hiding this comment

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

adding show index test case?

@tiancaiamao
Copy link
Contributor

Is it the cause of this issue #7308

@ciscoxll
Copy link
Contributor Author

@winkyao @tiancaiamao @zhexuany PTAL.

Copy link
Contributor

@zhexuany zhexuany 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

@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.

LGTM

@ciscoxll
Copy link
Contributor Author

/run-all-tests

@ciscoxll
Copy link
Contributor Author

/run-all-tests

@tiancaiamao tiancaiamao merged commit 593810e into pingcap:master Aug 10, 2018
@tiancaiamao
Copy link
Contributor

LGTM

@ciscoxll ciscoxll deleted the show-index branch August 10, 2018 08:21
@sre-bot sre-bot added the contribution This PR is from a community contributor. label Dec 18, 2019
@you06 you06 added the sig/sql-infra SIG: SQL Infra label Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution This PR is from a community contributor. sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants