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

ddl: add support for renaming columns #14281

Merged
merged 10 commits into from
Jan 3, 2020
Merged

Conversation

tangenta
Copy link
Contributor

@tangenta tangenta commented Dec 30, 2019

What problem does this PR solve?

Fix #10195.

What is changed and how it works?

Add rename column in DDL.

Check List

Tests

  • Unit test
  • Integration test

Code changes

  • Has exported function/method change

Side effects

Related changes

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

Release note

  • ddl: add support for renaming columns.

Copy link
Contributor

@djshow832 djshow832 left a comment

Choose a reason for hiding this comment

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

Test if it affects objects that reference to this column. E.g. generated columns, indexes, views.
Does the view definition(show create view) updates?

Copy link
Contributor

@djshow832 djshow832 left a comment

Choose a reason for hiding this comment

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

There's no lock in renaming column, what happens if another thread is adding a column with the same name?

ddl/ddl_api.go Outdated Show resolved Hide resolved
ddl/ddl_api.go Outdated Show resolved Hide resolved
@tangenta
Copy link
Contributor Author

tangenta commented Dec 30, 2019

There's no lock in renaming column, what happens if another thread is adding a column with the same name?

I think the ddl job queue would do the synchronization.

ddl/ddl_api.go Outdated Show resolved Hide resolved
ddl/ddl_api.go Show resolved Hide resolved
ddl/db_test.go Show resolved Hide resolved

// Test renaming generated columns.
s.tk.MustExec("drop table test_rename_column")
s.tk.MustExec("create table test_rename_column (id int, col1 int generated always as (id + 1))")
Copy link
Contributor

Choose a reason for hiding this comment

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

I mean, rename id, not col1, because col1 refers to id.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. PTAL

ddl/db_test.go Show resolved Hide resolved
Copy link
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

@bb7133 bb7133 added the status/LGT1 Indicates that a PR has LGTM 1. label Jan 1, 2020
ddl/ddl_api.go Outdated Show resolved Hide resolved
@reafans
Copy link
Contributor

reafans commented Jan 2, 2020

/run-all-tests

@Deardrops
Copy link
Contributor

LGTM

@tangenta tangenta added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jan 2, 2020
@reafans
Copy link
Contributor

reafans commented Jan 3, 2020

/run-all-tests

@reafans
Copy link
Contributor

reafans commented Jan 3, 2020

lgtm

@reafans
Copy link
Contributor

reafans commented Jan 3, 2020

/merge

@sre-bot sre-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jan 3, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Jan 3, 2020

/run-all-tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/sql-infra SIG: SQL Infra 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.

Support ALTER TABLE .. RENAME COLUMN
8 participants