Skip to content

Commit

Permalink
fix(dbm-services): 语法检查tendbcluster create table 非唯一索引判断错误 #6817
Browse files Browse the repository at this point in the history
  • Loading branch information
ymakedaq authored and iSecloud committed Sep 11, 2024
1 parent 4e41839 commit 6bd5d72
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (c CreateTableResult) shardKeyChecker(r *CheckerResult) {
switch {
case hasPk:
return
case len(uks) > 1:
case len(uks) >= 1:
return
case len(keys) > 1:
// 如果没有唯一索引,如果包含多个普通索引,则必须指定shard_key,否则需要报错
Expand All @@ -107,16 +107,16 @@ func (c CreateTableResult) shardKeyChecker(r *CheckerResult) {
r.Trigger(SR.SpiderCreateTableRule.NoPubColAtMultUniqueIndex, shardKeyCol)
return
}
// 如果存在 一个或者多个唯一索引(包含主键)
// 如果存在 一个或者多个唯一索引(包含主键)
case len(uks) > 1:
// shard_key只能是其中的共同部分;否则无法建表;
if !slices.Contains(pubCols, shardKeyCol) {
r.Trigger(SR.SpiderCreateTableRule.NoPubColAtMultUniqueIndex, shardKeyCol)
return
}
// 如果只存在多个普通索引,shard_key只能是其中任意一个的一部分
case len(uks) < 1 && len(uks) > 1:
if !c.shardKeyExistInKeys(shardKeyCol, uks) {
case len(uks) < 1 && len(keys) > 1:
if !c.shardKeyExistInKeys(shardKeyCol, keys) {
r.Trigger(SR.SpiderCreateTableRule.MustSpecialShardKeyOnlyHaveCommonIndex, shardKeyCol)
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ func (c *SemanticDumpSchemaComp) DumpSchema() (err error) {
}
if c.isSpider {
dumpOption.GtidPurgedOff = true
c.useTmysqldump = false
}
dumper = &mysqlutil.MySQLDumperTogether{
MySQLDumper: mysqlutil.MySQLDumper{
Expand Down

0 comments on commit 6bd5d72

Please sign in to comment.