Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executor: fix show create table for partitioned table (#10682) #10689

Merged
merged 2 commits into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions executor/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -784,9 +784,6 @@ func (e *ShowExec) fetchShowCreateTable() error {
fmt.Fprintf(&buf, " COMPRESSION='%s'", tb.Meta().Compression)
}

// add partition info here.
appendPartitionInfo(tb.Meta().Partition, &buf)

if hasAutoIncID {
autoIncID, err := tb.Allocator(e.ctx).NextGlobalAutoID(tb.Meta().ID)
if err != nil {
Expand All @@ -809,6 +806,9 @@ func (e *ShowExec) fetchShowCreateTable() error {
if len(tb.Meta().Comment) > 0 {
fmt.Fprintf(&buf, " COMMENT='%s'", format.OutputFormat(tb.Meta().Comment))
}
// add partition info here.
appendPartitionInfo(tb.Meta().Partition, &buf)

e.appendRow([]interface{}{tb.Meta().Name.O, buf.String()})
return nil
}
Expand Down
55 changes: 55 additions & 0 deletions executor/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,61 @@ func (s *testSuite2) TestShowCreateTable(c *C) {
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin/*!90000 SHARD_ROW_ID_BITS=4 PRE_SPLIT_REGIONS=3 */",
))
tk.MustExec("drop table t")

tk.MustExec("CREATE TABLE `log` (" +
"`LOG_ID` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT," +
"`ROUND_ID` bigint(20) UNSIGNED NOT NULL," +
"`USER_ID` int(10) UNSIGNED NOT NULL," +
"`USER_IP` int(10) UNSIGNED DEFAULT NULL," +
"`END_TIME` datetime NOT NULL," +
"`USER_TYPE` int(11) DEFAULT NULL," +
"`APP_ID` int(11) DEFAULT NULL," +
"PRIMARY KEY (`LOG_ID`,`END_TIME`)," +
"KEY `IDX_EndTime` (`END_TIME`)," +
"KEY `IDX_RoundId` (`ROUND_ID`)," +
"KEY `IDX_UserId_EndTime` (`USER_ID`,`END_TIME`)" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=505488 " +
"PARTITION BY RANGE ( month(`end_time`) ) (" +
"PARTITION p1 VALUES LESS THAN (2)," +
"PARTITION p2 VALUES LESS THAN (3)," +
"PARTITION p3 VALUES LESS THAN (4)," +
"PARTITION p4 VALUES LESS THAN (5)," +
"PARTITION p5 VALUES LESS THAN (6)," +
"PARTITION p6 VALUES LESS THAN (7)," +
"PARTITION p7 VALUES LESS THAN (8)," +
"PARTITION p8 VALUES LESS THAN (9)," +
"PARTITION p9 VALUES LESS THAN (10)," +
"PARTITION p10 VALUES LESS THAN (11)," +
"PARTITION p11 VALUES LESS THAN (12)," +
"PARTITION p12 VALUES LESS THAN (MAXVALUE))")
tk.MustQuery("show create table log").Check(testutil.RowsWithSep("|",
"log CREATE TABLE `log` (\n"+
" `LOG_ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n"+
" `ROUND_ID` bigint(20) unsigned NOT NULL,\n"+
" `USER_ID` int(10) unsigned NOT NULL,\n"+
" `USER_IP` int(10) unsigned DEFAULT NULL,\n"+
" `END_TIME` datetime NOT NULL,\n"+
" `USER_TYPE` int(11) DEFAULT NULL,\n"+
" `APP_ID` int(11) DEFAULT NULL,\n"+
" PRIMARY KEY (`LOG_ID`,`END_TIME`),\n"+
" KEY `IDX_EndTime` (`END_TIME`),\n"+
" KEY `IDX_RoundId` (`ROUND_ID`),\n"+
" KEY `IDX_UserId_EndTime` (`USER_ID`,`END_TIME`)\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=505488\n"+
"PARTITION BY RANGE ( month(`end_time`) ) (\n"+
" PARTITION p1 VALUES LESS THAN (2),\n"+
" PARTITION p2 VALUES LESS THAN (3),\n"+
" PARTITION p3 VALUES LESS THAN (4),\n"+
" PARTITION p4 VALUES LESS THAN (5),\n"+
" PARTITION p5 VALUES LESS THAN (6),\n"+
" PARTITION p6 VALUES LESS THAN (7),\n"+
" PARTITION p7 VALUES LESS THAN (8),\n"+
" PARTITION p8 VALUES LESS THAN (9),\n"+
" PARTITION p9 VALUES LESS THAN (10),\n"+
" PARTITION p10 VALUES LESS THAN (11),\n"+
" PARTITION p11 VALUES LESS THAN (12),\n"+
" PARTITION p12 VALUES LESS THAN (MAXVALUE)\n"+
")"))
}

func (s *testSuite2) TestShowEscape(c *C) {
Expand Down