Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#10346
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
GMHDBJD authored and ti-chi-bot committed Dec 26, 2023
1 parent ef65442 commit f892a91
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions dm/pkg/schema/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"sync"

"github.com/pingcap/errors"
<<<<<<< HEAD
"github.com/pingcap/tidb/ddl"
"github.com/pingcap/tidb/ddl/schematracker"
"github.com/pingcap/tidb/executor"
Expand All @@ -36,6 +37,25 @@ import (
"github.com/pingcap/tidb/util/filter"
"github.com/pingcap/tidb/util/mock"
"github.com/pingcap/tidb/util/sqlexec"
=======
"github.com/pingcap/tidb/pkg/ddl"
"github.com/pingcap/tidb/pkg/ddl/schematracker"
"github.com/pingcap/tidb/pkg/executor"
"github.com/pingcap/tidb/pkg/infoschema"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/meta/autoid"
"github.com/pingcap/tidb/pkg/parser"
"github.com/pingcap/tidb/pkg/parser/ast"
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/parser/mysql"
"github.com/pingcap/tidb/pkg/sessionctx"
"github.com/pingcap/tidb/pkg/sessionctx/variable"
"github.com/pingcap/tidb/pkg/util/chunk"
"github.com/pingcap/tidb/pkg/util/filter"
"github.com/pingcap/tidb/pkg/util/mock"
"github.com/pingcap/tidb/pkg/util/sqlexec"
"github.com/pingcap/tiflow/dm/pkg/conn"
>>>>>>> 2e729efee1 (dm: set enable cluster index to off for downstream tracker (#10346))
tcontext "github.com/pingcap/tiflow/dm/pkg/context"
fr "github.com/pingcap/tiflow/dm/pkg/func-rollback"
"github.com/pingcap/tiflow/dm/pkg/log"
Expand Down Expand Up @@ -464,6 +484,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

0 comments on commit f892a91

Please sign in to comment.