From 6bd5d72b5418adfca178b33c92151c6714591964 Mon Sep 17 00:00:00 2001 From: make123 Date: Tue, 10 Sep 2024 17:45:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(dbm-services):=20=E8=AF=AD=E6=B3=95?= =?UTF-8?q?=E6=A3=80=E6=9F=A5tendbcluster=20create=20table=20=E9=9D=9E?= =?UTF-8?q?=E5=94=AF=E4=B8=80=E7=B4=A2=E5=BC=95=E5=88=A4=E6=96=AD=E9=94=99?= =?UTF-8?q?=E8=AF=AF=20#6817?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db-simulation/app/syntax/spider_create_table_rule.go | 8 ++++---- .../pkg/components/mysql/semantic_dump_schema.go | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dbm-services/mysql/db-simulation/app/syntax/spider_create_table_rule.go b/dbm-services/mysql/db-simulation/app/syntax/spider_create_table_rule.go index 7ac48b613a..7d819a427d 100644 --- a/dbm-services/mysql/db-simulation/app/syntax/spider_create_table_rule.go +++ b/dbm-services/mysql/db-simulation/app/syntax/spider_create_table_rule.go @@ -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,否则需要报错 @@ -107,7 +107,7 @@ func (c CreateTableResult) shardKeyChecker(r *CheckerResult) { r.Trigger(SR.SpiderCreateTableRule.NoPubColAtMultUniqueIndex, shardKeyCol) return } - // 如果存在 一个或者多个唯一索引(包含主键) + // 如果存在 一个或者多个唯一索引(包含主键) case len(uks) > 1: // shard_key只能是其中的共同部分;否则无法建表; if !slices.Contains(pubCols, shardKeyCol) { @@ -115,8 +115,8 @@ func (c CreateTableResult) shardKeyChecker(r *CheckerResult) { 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 } diff --git a/dbm-services/mysql/db-tools/dbactuator/pkg/components/mysql/semantic_dump_schema.go b/dbm-services/mysql/db-tools/dbactuator/pkg/components/mysql/semantic_dump_schema.go index 2963ec1ee9..27e4c940f5 100644 --- a/dbm-services/mysql/db-tools/dbactuator/pkg/components/mysql/semantic_dump_schema.go +++ b/dbm-services/mysql/db-tools/dbactuator/pkg/components/mysql/semantic_dump_schema.go @@ -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{