Skip to content

Commit

Permalink
executor: display pre_split_regions for auto_random tables in `SHOW…
Browse files Browse the repository at this point in the history
… CREATE` (#49781)

close #49839
  • Loading branch information
tangenta authored Dec 27, 2023
1 parent d0d24ae commit 30b2b8f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/executor/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
9 changes: 9 additions & 0 deletions tests/integrationtest/r/executor/show.result
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
5 changes: 5 additions & 0 deletions tests/integrationtest/t/executor/show.test
Original file line number Diff line number Diff line change
Expand Up @@ -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`;

0 comments on commit 30b2b8f

Please sign in to comment.