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 the operation of dropping multi-indexes in one statement #14765

Closed
zimulala opened this issue Feb 13, 2020 · 34 comments · Fixed by #20457
Closed

Support the operation of dropping multi-indexes in one statement #14765

zimulala opened this issue Feb 13, 2020 · 34 comments · Fixed by #20457
Labels
challenge-program feature/accepted This feature request is accepted by product managers sig/sql-infra SIG: SQL Infra type/feature-request Categorizes issue or PR as related to a new feature.

Comments

@zimulala
Copy link
Contributor

zimulala commented Feb 13, 2020

Feature Request

Is your feature request related to a problem? Please describe:

create table t(a int, b int, key idx1(a), key idx2(b));
alter table t drop index idx1, drop index idx2;
ERROR 8200 (HY000): Unsupported multi schema change

Describe the feature you'd like:

mysql> alter table t drop index idx1, drop index idx2;
Query OK, 0 rows affected (0.03 sec)
Records: 0  Duplicates: 0  Warnings: 0

Support adding multi-columns in one statement, the syntax as follows:

ALTER TABLE tbl_name
    [alter_option [, alter_option] ...]

alter_option:
DROP {INDEX | KEY} index_name

Refer to: https://dev.mysql.com/doc/refman/5.7/en/alter-table.html

We can refer to the implementation of #5092(Support the operation of adding multi-columns).

Score

1200

SIG Slack Channel

You can join #sig-ddl on slack in your spare time to discuss and get help with mentors or others.

Mentor(s)

Recommended Skills

  • DDL
  • Golang

Learning Materials

MySQL's document for syntax reference.
TiDB DDL architecture

@zimulala zimulala added type/enhancement The issue or PR belongs to an enhancement. component/DDL-need-LGT3 labels Feb 13, 2020
@zimulala zimulala added type/new-feature and removed type/enhancement The issue or PR belongs to an enhancement. labels Feb 13, 2020
@zimulala zimulala added sig/sql-infra SIG: SQL Infra and removed component/DDL1 labels Mar 4, 2020
@zz-jason zz-jason added type/feature-request Categorizes issue or PR as related to a new feature. and removed type/new-feature labels Apr 3, 2020
@zimulala zimulala changed the title Support the operation of dropping multi-indexes in one statement Support the operation of adding multi-indexes in one statement Jun 16, 2020
@zimulala zimulala changed the title Support the operation of adding multi-indexes in one statement Support the operation of dropping multi-indexes in one statement Jun 16, 2020
@zimulala
Copy link
Contributor Author

@chanme picked up this issue.

@chanme
Copy link
Contributor

chanme commented Jul 12, 2020

@zimulala I'm trying to understand the following codes of the function onDropIndex and I have a few questions.

  1. when would job.IsRollingback() happen? and if it does, what is the purpose of setting job.Args[0] = indexInfo.ID
  2. for the other case, what is the purpose of setting getPartitionIDs into the args.

    tidb/ddl/index.go

    Lines 645 to 654 in 8a66104

    // Finish this job.
    if job.IsRollingback() {
    job.FinishTableJob(model.JobStateRollbackDone, model.StateNone, ver, tblInfo)
    job.Args[0] = indexInfo.ID
    // the partition ids were append by convertAddIdxJob2RollbackJob, it is weird, but for the compatibility,
    // we should keep appending the partitions in the convertAddIdxJob2RollbackJob.
    } else {
    job.FinishTableJob(model.JobStateDone, model.StateNone, ver, tblInfo)
    job.Args = append(job.Args, indexInfo.ID, getPartitionIDs(tblInfo))
    }

@zz-jason zz-jason added the feature/accepted This feature request is accepted by product managers label Jul 29, 2020
@zimulala
Copy link
Contributor Author

zimulala commented Sep 10, 2020

@zimulala I'm trying to understand the following codes of the function onDropIndex and I have a few questions.

  1. when would job.IsRollingback() happen? and if it does, what is the purpose of setting job.Args[0] = indexInfo.ID
  2. for the other case, what is the purpose of setting getPartitionIDs into the args.

    tidb/ddl/index.go

    Lines 645 to 654 in 8a66104

    // Finish this job.
    if job.IsRollingback() {
    job.FinishTableJob(model.JobStateRollbackDone, model.StateNone, ver, tblInfo)
    job.Args[0] = indexInfo.ID
    // the partition ids were append by convertAddIdxJob2RollbackJob, it is weird, but for the compatibility,
    // we should keep appending the partitions in the convertAddIdxJob2RollbackJob.
    } else {
    job.FinishTableJob(model.JobStateDone, model.StateNone, ver, tblInfo)
    job.Args = append(job.Args, indexInfo.ID, getPartitionIDs(tblInfo))
    }
  1. When adding index failed, we may need rollback(we can see the function of convertAddIdxJob2RollbackJob). After calling convertAddIdxJob2RollbackJob, it will do job.IsRollingback(). job.Args[0] = indexInfo.ID is use to remove index data in delete_range.go

  2. getPartitionIDs is used for partition table, I think we need to add this function in line648. Could you file an issue?

If I don't reply in time, you can join #sig-ddl on slack in your spare time

@asiafrank
Copy link
Contributor

/pick-up

@ti-challenge-bot
Copy link

Pick up success.

@ou-bing
Copy link
Contributor

ou-bing commented Oct 14, 2020

/pick-up

@ti-challenge-bot
Copy link

Pick up success.

@ti-challenge-bot
Copy link

@ou-bing You did not submit PR within 7 days, so give up automatically.

@ti-challenge-bot ti-challenge-bot bot removed the picked label Oct 21, 2020
@ou-bing
Copy link
Contributor

ou-bing commented Oct 22, 2020

/pick-up

@ti-challenge-bot
Copy link

Pick up success.

@ti-challenge-bot
Copy link

@ou-bing You did not submit PR within 7 days, so give up automatically.

@ti-challenge-bot ti-challenge-bot bot removed the picked label Oct 29, 2020
@ou-bing
Copy link
Contributor

ou-bing commented Oct 29, 2020

/pick-up

@ti-challenge-bot
Copy link

Pick up success.

@ti-challenge-bot
Copy link

@ou-bing You did not submit PR within 7 days, so give up automatically.

@ti-challenge-bot ti-challenge-bot bot removed the picked label Nov 5, 2020
@ou-bing
Copy link
Contributor

ou-bing commented Nov 5, 2020

/pick-up

@ti-challenge-bot
Copy link

Pick up success.

@ti-challenge-bot
Copy link

@ou-bing You did not submit PR within 7 days, so give up automatically.

@ti-challenge-bot ti-challenge-bot bot removed the picked label Nov 12, 2020
@ou-bing
Copy link
Contributor

ou-bing commented Nov 12, 2020

/pick-up

@ti-challenge-bot
Copy link

Pick up success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
challenge-program feature/accepted This feature request is accepted by product managers sig/sql-infra SIG: SQL Infra type/feature-request Categorizes issue or PR as related to a new feature.
Projects
None yet
8 participants