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

dm: set enable cluster index to off for downstream tracker (#10346) #10632

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions dm/pkg/schema/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/pingcap/tidb/parser/model"
"github.com/pingcap/tidb/parser/mysql"
"github.com/pingcap/tidb/sessionctx"
"github.com/pingcap/tidb/sessionctx/variable"
"github.com/pingcap/tidb/util/chunk"
"github.com/pingcap/tidb/util/filter"
"github.com/pingcap/tidb/util/mock"
Expand Down Expand Up @@ -465,6 +466,17 @@ func (dt *downstreamTracker) getTableInfoByCreateStmt(tctx *tcontext.Context, ta
return nil, dmterror.ErrSchemaTrackerInvalidCreateTableStmt.Delegate(err, createStr)
}

// suppress ErrTooLongKey
strictSQLModeBackup := dt.se.GetSessionVars().StrictSQLMode
dt.se.GetSessionVars().StrictSQLMode = false
// support drop PK
enableClusteredIndexBackup := dt.se.GetSessionVars().EnableClusteredIndex
dt.se.GetSessionVars().EnableClusteredIndex = variable.ClusteredIndexDefModeOff
defer func() {
dt.se.GetSessionVars().StrictSQLMode = strictSQLModeBackup
dt.se.GetSessionVars().EnableClusteredIndex = enableClusteredIndexBackup
}()

ti, err := ddl.BuildTableInfoWithStmt(dt.se, stmtNode.(*ast.CreateTableStmt), mysql.DefaultCharset, "", nil)
if err != nil {
return nil, dmterror.ErrSchemaTrackerCannotMockDownstreamTable.Delegate(err, createStr)
Expand Down
2 changes: 1 addition & 1 deletion dm/pkg/schema/tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ func TestGetDownStreamIndexInfo(t *testing.T) {

mock.ExpectQuery("SHOW CREATE TABLE " + tableID).WillReturnRows(
sqlmock.NewRows([]string{"Table", "Create Table"}).
AddRow("test", "create table t(a int primary key, b int, c varchar(20000), key(c(20000)))"))
AddRow("test", "create table t(a int, b int, c varchar(20000), primary key(a, b), key(c(20000)))/*!90000 SHARD_ROW_ID_BITS=6 */"))
dti, err := tracker.GetDownStreamTableInfo(tcontext.Background(), tableID, oriTi)
require.NoError(t, err)
require.NotNil(t, dti.WhereHandle.UniqueNotNullIdx)
Expand Down
Loading