-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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: support alter algorithm INPLACE/INSTANT #8811
Conversation
The circleci will be fixed after the pingcap/parser#93 merged. |
ddl/ddl_algorithm_test.go
Outdated
@@ -0,0 +1,107 @@ | |||
// Copyright 2015 PingCAP, Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2015 -> 2018
ddl/ddl_algorithm.go
Outdated
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSES/QL-LICENSE file. | ||
|
||
// Copyright 2015 PingCAP, Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2015 -> 2018
go.mod
Outdated
@@ -86,3 +86,5 @@ require ( | |||
sourcegraph.com/sourcegraph/appdash v0.0.0-20180531100431-4c381bd170b4 | |||
sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67 | |||
) | |||
|
|||
replace github.com/pingcap/parser => github.com/winkyao/parser v0.0.0-20181221090435-0eaad9528419 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line will be removed after the pingcap/parser#93 is merged, but now we need to replace the parser to pass the ci.
@winkyao I spoke to MySQL users about the error on |
@winkyao what do you think?if you are worried about warning messages are easy to ignore, we can also transform it(CPOY=>INSTANT) in replication app. But a warning message is definitely simpler if no other affects |
@morgo Well, return warning is also acceptable for me. I'll change this PR later. |
@morgo Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LGTM |
ddl/ddl_api.go
Outdated
@@ -1407,10 +1407,16 @@ func getCharsetAndCollateInTableOption(startIdx int, options []*ast.TableOption) | |||
return | |||
} | |||
|
|||
func (d *ddl) AlterTable(ctx sessionctx.Context, ident ast.Ident, specs []*ast.AlterTableSpec) (err error) { | |||
// Only handle valid specs. | |||
// resolveAlterTableSpec resolve alter table algorithm and remove ignore table spec in specs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/resolve/resolves
s/remove/removes
func (d *ddl) AlterTable(ctx sessionctx.Context, ident ast.Ident, specs []*ast.AlterTableSpec) (err error) { | ||
// Only handle valid specs. | ||
// resolveAlterTableSpec resolve alter table algorithm and remove ignore table spec in specs. | ||
// returns valied specs, and the occured error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/returns/Return
ddl/ddl_api.go
Outdated
for _, spec := range specs { | ||
if spec.Tp == ast.AlterTableAlgorithm { | ||
// find the last AlterTableAlgorithm. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/find/Find
ddl/db_integration_test.go
Outdated
@@ -1210,3 +1210,75 @@ func (s *testIntegrationSuite) TestAlterColumn(c *C) { | |||
_, err = s.tk.Exec("alter table mc modify column a bigint auto_increment") // Adds auto_increment should throw error | |||
c.Assert(err, NotNil) | |||
} | |||
|
|||
func (s *testIntegrationSuite) assertWarningExec(c *C, sql string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think adding the warning message as an argument can be beneficial for calls to other functions.
@zimulala Done, PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
/run-common-test |
/run-common-test tidb-test=pr/741 |
1 similar comment
/run-common-test tidb-test=pr/741 |
/run-integration-common-test tidb-test=pr/741 |
Codecov Report
@@ Coverage Diff @@
## master #8811 +/- ##
==========================================
+ Coverage 67.07% 67.15% +0.08%
==========================================
Files 372 373 +1
Lines 78085 78113 +28
==========================================
+ Hits 52373 52459 +86
+ Misses 21043 20966 -77
- Partials 4669 4688 +19
Continue to review full report at Codecov.
|
What problem does this PR solve?
For #8428 , this is the first step to support
EXPLAIN DDL
(#8429).MySQL support COPY/INPLACE/INSTANT/DEFAULT alter algorithm, you can get the details in https://dev.mysql.com/doc/refman/8.0/en/alter-table.html#alter-table-performance
In TiDB, we only support INPLACE/INSTANT, and the most algorithm of the alter operations is the
INSTANT
, which meansThe add index using
INPLACE
algorithm, but not exactly the same with MySQL, the difference with MySQL is that TiDB never blocks the DML and never have a metadata lock on the table:If user specifies the unsupported algorithm of the alter operation, a wanrning
ERROR 1846 (0A000): ALGORITHM=COPY is not supported. Reason: Cannot alter table by COPY. Try ALGORITHM=INSTANT.
will be returned:Need to merge pingcap/parser#93 first.
Tests
Code changes
Side effects
Related changes
This change is
@zimulala @crazycs520 @morgo PTAL