diff --git a/pkg/executor/show.go b/pkg/executor/show.go index 21367c03b57ea..6d522d9710611 100644 --- a/pkg/executor/show.go +++ b/pkg/executor/show.go @@ -1294,6 +1294,10 @@ func constructResultOfShowCreateTable(ctx sessionctx.Context, dbName *model.CISt buf.WriteString("*/") } + if tableInfo.AutoRandomBits > 0 && tableInfo.PreSplitRegions > 0 { + fmt.Fprintf(buf, " /*T! PRE_SPLIT_REGIONS=%d */", tableInfo.PreSplitRegions) + } + if len(tableInfo.Comment) > 0 { fmt.Fprintf(buf, " COMMENT='%s'", format.OutputFormat(tableInfo.Comment)) } diff --git a/tests/integrationtest/r/executor/show.result b/tests/integrationtest/r/executor/show.result index b76ab526b3387..c82e21e5302d2 100644 --- a/tests/integrationtest/r/executor/show.result +++ b/tests/integrationtest/r/executor/show.result @@ -1123,3 +1123,12 @@ select * from information_schema.COLLATIONS where IS_DEFAULT='Yes' and CHARACTER COLLATION_NAME CHARACTER_SET_NAME ID IS_DEFAULT IS_COMPILED SORTLEN utf8mb4_bin utf8mb4 46 Yes Yes 1 set @@session.default_collation_for_utf8mb4=default; +DROP TABLE IF EXISTS `t`; +CREATE TABLE `t` (a BIGINT PRIMARY KEY AUTO_RANDOM(2), b INT) PRE_SPLIT_REGIONS=4; +SHOW CREATE TABLE `t`; +Table Create Table +t CREATE TABLE `t` ( + `a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(2) */, + `b` int(11) DEFAULT NULL, + PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */ +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T! PRE_SPLIT_REGIONS=2 */ diff --git a/tests/integrationtest/t/executor/show.test b/tests/integrationtest/t/executor/show.test index ef88ad76614eb..b490834323beb 100644 --- a/tests/integrationtest/t/executor/show.test +++ b/tests/integrationtest/t/executor/show.test @@ -427,3 +427,8 @@ select * from information_schema.COLLATIONS; show character set like '%utf8mb4%'; select * from information_schema.COLLATIONS where IS_DEFAULT='Yes' and CHARACTER_SET_NAME='utf8mb4'; set @@session.default_collation_for_utf8mb4=default; + +# TestShowPreSplitRegionsForAutoRandomTables +DROP TABLE IF EXISTS `t`; +CREATE TABLE `t` (a BIGINT PRIMARY KEY AUTO_RANDOM(2), b INT) PRE_SPLIT_REGIONS=4; +SHOW CREATE TABLE `t`;