Skip to content

Commit 5a6d30e

Browse files
authored
Merge branch 'master' into rustin-patch-drop
2 parents b30ae36 + 6d50a47 commit 5a6d30e

File tree

5 files changed

+59
-59
lines changed

5 files changed

+59
-59
lines changed

ddl/db_partition_test.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func (s *testIntegrationSuite3) TestCreateTableWithPartition(c *C) {
214214
partition p0 values less than (to_seconds('2004-01-01')),
215215
partition p1 values less than (to_seconds('2005-01-01')));`)
216216
tk.MustQuery("show create table t26").Check(
217-
testkit.Rows("t26 CREATE TABLE `t26` (\n `a` date DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin\nPARTITION BY RANGE ( to_seconds(`a`) ) (\n PARTITION p0 VALUES LESS THAN (63240134400),\n PARTITION p1 VALUES LESS THAN (63271756800)\n)"))
217+
testkit.Rows("t26 CREATE TABLE `t26` (\n `a` date DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin\nPARTITION BY RANGE ( to_seconds(`a`) ) (\n PARTITION `p0` VALUES LESS THAN (63240134400),\n PARTITION `p1` VALUES LESS THAN (63271756800)\n)"))
218218
tk.MustExec(`create table t27 (a bigint unsigned not null)
219219
partition by range(a) (
220220
partition p0 values less than (10),
@@ -1624,81 +1624,81 @@ func (s *testIntegrationSuite5) TestConstAndTimezoneDepent(c *C) {
16241624
tk.MustExec("create database test_db_with_partition_const")
16251625
tk.MustExec("use test_db_with_partition_const")
16261626

1627-
sql1 := `create table t1 ( id int )
1627+
sql1 := `create table t1 ( id int )
16281628
partition by range(4) (
16291629
partition p1 values less than (10)
16301630
);`
16311631
tk.MustGetErrCode(sql1, tmysql.ErrWrongExprInPartitionFunc)
16321632

1633-
sql2 := `create table t2 ( time_recorded timestamp )
1633+
sql2 := `create table t2 ( time_recorded timestamp )
16341634
partition by range(TO_DAYS(time_recorded)) (
16351635
partition p1 values less than (1559192604)
16361636
);`
16371637
tk.MustGetErrCode(sql2, tmysql.ErrWrongExprInPartitionFunc)
16381638

1639-
sql3 := `create table t3 ( id int )
1639+
sql3 := `create table t3 ( id int )
16401640
partition by range(DAY(id)) (
16411641
partition p1 values less than (1)
16421642
);`
16431643
tk.MustGetErrCode(sql3, tmysql.ErrWrongExprInPartitionFunc)
16441644

1645-
sql4 := `create table t4 ( id int )
1645+
sql4 := `create table t4 ( id int )
16461646
partition by hash(4) partitions 4
16471647
;`
16481648
tk.MustGetErrCode(sql4, tmysql.ErrWrongExprInPartitionFunc)
16491649

1650-
sql5 := `create table t5 ( time_recorded timestamp )
1650+
sql5 := `create table t5 ( time_recorded timestamp )
16511651
partition by range(to_seconds(time_recorded)) (
16521652
partition p1 values less than (1559192604)
16531653
);`
16541654
tk.MustGetErrCode(sql5, tmysql.ErrWrongExprInPartitionFunc)
16551655

1656-
sql6 := `create table t6 ( id int )
1656+
sql6 := `create table t6 ( id int )
16571657
partition by range(to_seconds(id)) (
16581658
partition p1 values less than (1559192604)
16591659
);`
16601660
tk.MustGetErrCode(sql6, tmysql.ErrWrongExprInPartitionFunc)
16611661

1662-
sql7 := `create table t7 ( time_recorded timestamp )
1662+
sql7 := `create table t7 ( time_recorded timestamp )
16631663
partition by range(abs(time_recorded)) (
16641664
partition p1 values less than (1559192604)
16651665
);`
16661666
tk.MustGetErrCode(sql7, tmysql.ErrWrongExprInPartitionFunc)
16671667

16681668
sql8 := `create table t2332 ( time_recorded time )
1669-
partition by range(TO_DAYS(time_recorded)) (
1669+
partition by range(TO_DAYS(time_recorded)) (
16701670
partition p0 values less than (1)
16711671
);`
16721672
tk.MustGetErrCode(sql8, tmysql.ErrWrongExprInPartitionFunc)
16731673

1674-
sql9 := `create table t1 ( id int )
1674+
sql9 := `create table t1 ( id int )
16751675
partition by hash(4) partitions 4;`
16761676
tk.MustGetErrCode(sql9, tmysql.ErrWrongExprInPartitionFunc)
16771677

1678-
sql10 := `create table t1 ( id int )
1678+
sql10 := `create table t1 ( id int )
16791679
partition by hash(ed) partitions 4;`
16801680
tk.MustGetErrCode(sql10, tmysql.ErrBadField)
16811681

16821682
sql11 := `create table t2332 ( time_recorded time )
1683-
partition by range(TO_SECONDS(time_recorded)) (
1683+
partition by range(TO_SECONDS(time_recorded)) (
16841684
partition p0 values less than (1)
16851685
);`
16861686
tk.MustGetErrCode(sql11, tmysql.ErrWrongExprInPartitionFunc)
16871687

16881688
sql12 := `create table t2332 ( time_recorded time )
1689-
partition by range(TO_SECONDS(time_recorded)) (
1689+
partition by range(TO_SECONDS(time_recorded)) (
16901690
partition p0 values less than (1)
16911691
);`
16921692
tk.MustGetErrCode(sql12, tmysql.ErrWrongExprInPartitionFunc)
16931693

16941694
sql13 := `create table t2332 ( time_recorded time )
1695-
partition by range(day(time_recorded)) (
1695+
partition by range(day(time_recorded)) (
16961696
partition p0 values less than (1)
16971697
);`
16981698
tk.MustGetErrCode(sql13, tmysql.ErrWrongExprInPartitionFunc)
16991699

17001700
sql14 := `create table t2332 ( time_recorded timestamp )
1701-
partition by range(day(time_recorded)) (
1701+
partition by range(day(time_recorded)) (
17021702
partition p0 values less than (1)
17031703
);`
17041704
tk.MustGetErrCode(sql14, tmysql.ErrWrongExprInPartitionFunc)
@@ -1712,19 +1712,19 @@ func (s *testIntegrationSuite5) TestConstAndTimezoneDepent2(c *C) {
17121712
tk.MustExec("create database test_db_with_partition_const")
17131713
tk.MustExec("use test_db_with_partition_const")
17141714

1715-
tk.MustExec(`create table t1 ( time_recorded datetime )
1715+
tk.MustExec(`create table t1 ( time_recorded datetime )
17161716
partition by range(TO_DAYS(time_recorded)) (
17171717
partition p0 values less than (1));`)
17181718

1719-
tk.MustExec(`create table t2 ( time_recorded date )
1719+
tk.MustExec(`create table t2 ( time_recorded date )
17201720
partition by range(TO_DAYS(time_recorded)) (
17211721
partition p0 values less than (1));`)
17221722

1723-
tk.MustExec(`create table t3 ( time_recorded date )
1723+
tk.MustExec(`create table t3 ( time_recorded date )
17241724
partition by range(TO_SECONDS(time_recorded)) (
17251725
partition p0 values less than (1));`)
17261726

1727-
tk.MustExec(`create table t4 ( time_recorded date )
1727+
tk.MustExec(`create table t4 ( time_recorded date )
17281728
partition by range(TO_SECONDS(time_recorded)) (
17291729
partition p0 values less than (1));`)
17301730

executor/seqtest/seq_executor_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ func (s *seqTestSuite) TestShow(c *C) {
508508
tk.MustQuery("show create table t").Check(testutil.RowsWithSep("|",
509509
"t CREATE TABLE `t` (\n"+
510510
" `a` int(11) DEFAULT NULL\n"+
511-
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"+"\nPARTITION BY RANGE ( `a` ) (\n PARTITION p0 VALUES LESS THAN (10),\n PARTITION p1 VALUES LESS THAN (20),\n PARTITION p2 VALUES LESS THAN (MAXVALUE)\n)",
511+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"+"\nPARTITION BY RANGE ( `a` ) (\n PARTITION `p0` VALUES LESS THAN (10),\n PARTITION `p1` VALUES LESS THAN (20),\n PARTITION `p2` VALUES LESS THAN (MAXVALUE)\n)",
512512
))
513513

514514
tk.MustExec(`drop table if exists t`)
@@ -531,7 +531,7 @@ func (s *seqTestSuite) TestShow(c *C) {
531531
" `b` int(11) DEFAULT NULL,\n"+
532532
" `c` char(1) DEFAULT NULL,\n"+
533533
" `d` int(11) DEFAULT NULL\n"+
534-
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"+"\nPARTITION BY RANGE COLUMNS(a,d,c) (\n PARTITION p0 VALUES LESS THAN (5,10,\"ggg\"),\n PARTITION p1 VALUES LESS THAN (10,20,\"mmm\"),\n PARTITION p2 VALUES LESS THAN (15,30,\"sss\"),\n PARTITION p3 VALUES LESS THAN (50,MAXVALUE,MAXVALUE)\n)",
534+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"+"\nPARTITION BY RANGE COLUMNS(a,d,c) (\n PARTITION `p0` VALUES LESS THAN (5,10,\"ggg\"),\n PARTITION `p1` VALUES LESS THAN (10,20,\"mmm\"),\n PARTITION `p2` VALUES LESS THAN (15,30,\"sss\"),\n PARTITION `p3` VALUES LESS THAN (50,MAXVALUE,MAXVALUE)\n)",
535535
))
536536

537537
// Test hash partition

executor/show.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -950,15 +950,15 @@ func (e *ShowExec) fetchShowCreateTable() error {
950950
allocator := tb.Allocator(e.ctx, autoid.RowIDAllocType)
951951
var buf bytes.Buffer
952952
// TODO: let the result more like MySQL.
953-
if err = ConstructResultOfShowCreateTable(e.ctx, tb.Meta(), allocator, &buf); err != nil {
953+
if err = ConstructResultOfShowCreateTable(e.ctx, tableInfo, allocator, &buf); err != nil {
954954
return err
955955
}
956956
if tableInfo.IsView() {
957957
e.appendRow([]interface{}{tableInfo.Name.O, buf.String(), tableInfo.Charset, tableInfo.Collate})
958958
return nil
959959
}
960960

961-
e.appendRow([]interface{}{tb.Meta().Name.O, buf.String()})
961+
e.appendRow([]interface{}{tableInfo.Name.O, buf.String()})
962962
return nil
963963
}
964964

@@ -1023,7 +1023,7 @@ func appendPartitionInfo(partitionInfo *model.PartitionInfo, buf *bytes.Buffer)
10231023
}
10241024
for i, def := range partitionInfo.Definitions {
10251025
lessThans := strings.Join(def.LessThan, ",")
1026-
fmt.Fprintf(buf, " PARTITION %s VALUES LESS THAN (%s)", def.Name, lessThans)
1026+
fmt.Fprintf(buf, " PARTITION `%s` VALUES LESS THAN (%s)", def.Name, lessThans)
10271027
if i < len(partitionInfo.Definitions)-1 {
10281028
buf.WriteString(",\n")
10291029
} else {

executor/show_test.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -553,18 +553,18 @@ func (s *testSuite5) TestShowCreateTable(c *C) {
553553
"KEY `IDX_UserId_EndTime` (`USER_ID`,`END_TIME`)" +
554554
") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=505488 " +
555555
"PARTITION BY RANGE ( month(`end_time`) ) (" +
556-
"PARTITION p1 VALUES LESS THAN (2)," +
557-
"PARTITION p2 VALUES LESS THAN (3)," +
558-
"PARTITION p3 VALUES LESS THAN (4)," +
559-
"PARTITION p4 VALUES LESS THAN (5)," +
560-
"PARTITION p5 VALUES LESS THAN (6)," +
561-
"PARTITION p6 VALUES LESS THAN (7)," +
562-
"PARTITION p7 VALUES LESS THAN (8)," +
563-
"PARTITION p8 VALUES LESS THAN (9)," +
564-
"PARTITION p9 VALUES LESS THAN (10)," +
565-
"PARTITION p10 VALUES LESS THAN (11)," +
566-
"PARTITION p11 VALUES LESS THAN (12)," +
567-
"PARTITION p12 VALUES LESS THAN (MAXVALUE))")
556+
"PARTITION `p1` VALUES LESS THAN (2)," +
557+
"PARTITION `p2` VALUES LESS THAN (3)," +
558+
"PARTITION `p3` VALUES LESS THAN (4)," +
559+
"PARTITION `p4` VALUES LESS THAN (5)," +
560+
"PARTITION `p5` VALUES LESS THAN (6)," +
561+
"PARTITION `p6` VALUES LESS THAN (7)," +
562+
"PARTITION `p7` VALUES LESS THAN (8)," +
563+
"PARTITION `p8` VALUES LESS THAN (9)," +
564+
"PARTITION `p9` VALUES LESS THAN (10)," +
565+
"PARTITION `p10` VALUES LESS THAN (11)," +
566+
"PARTITION `p11` VALUES LESS THAN (12)," +
567+
"PARTITION `p12` VALUES LESS THAN (MAXVALUE))")
568568
tk.MustQuery("show create table log").Check(testutil.RowsWithSep("|",
569569
"log CREATE TABLE `log` (\n"+
570570
" `LOG_ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n"+
@@ -580,18 +580,18 @@ func (s *testSuite5) TestShowCreateTable(c *C) {
580580
" KEY `IDX_UserId_EndTime` (`USER_ID`,`END_TIME`)\n"+
581581
") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=505488\n"+
582582
"PARTITION BY RANGE ( month(`end_time`) ) (\n"+
583-
" PARTITION p1 VALUES LESS THAN (2),\n"+
584-
" PARTITION p2 VALUES LESS THAN (3),\n"+
585-
" PARTITION p3 VALUES LESS THAN (4),\n"+
586-
" PARTITION p4 VALUES LESS THAN (5),\n"+
587-
" PARTITION p5 VALUES LESS THAN (6),\n"+
588-
" PARTITION p6 VALUES LESS THAN (7),\n"+
589-
" PARTITION p7 VALUES LESS THAN (8),\n"+
590-
" PARTITION p8 VALUES LESS THAN (9),\n"+
591-
" PARTITION p9 VALUES LESS THAN (10),\n"+
592-
" PARTITION p10 VALUES LESS THAN (11),\n"+
593-
" PARTITION p11 VALUES LESS THAN (12),\n"+
594-
" PARTITION p12 VALUES LESS THAN (MAXVALUE)\n"+
583+
" PARTITION `p1` VALUES LESS THAN (2),\n"+
584+
" PARTITION `p2` VALUES LESS THAN (3),\n"+
585+
" PARTITION `p3` VALUES LESS THAN (4),\n"+
586+
" PARTITION `p4` VALUES LESS THAN (5),\n"+
587+
" PARTITION `p5` VALUES LESS THAN (6),\n"+
588+
" PARTITION `p6` VALUES LESS THAN (7),\n"+
589+
" PARTITION `p7` VALUES LESS THAN (8),\n"+
590+
" PARTITION `p8` VALUES LESS THAN (9),\n"+
591+
" PARTITION `p9` VALUES LESS THAN (10),\n"+
592+
" PARTITION `p10` VALUES LESS THAN (11),\n"+
593+
" PARTITION `p11` VALUES LESS THAN (12),\n"+
594+
" PARTITION `p12` VALUES LESS THAN (MAXVALUE)\n"+
595595
")"))
596596

597597
// for issue #11831

table/tables/partition_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ PARTITION BY RANGE ( id ) (
129129
_, err = tb.AddRecord(ts.se, types.MakeDatums(22))
130130
c.Assert(err, IsNil) // Insert into maxvalue partition.
131131

132-
createTable3 := `create table test.t3 (id int) partition by range (id)
132+
createTable3 := `create table test.t3 (id int) partition by range (id)
133133
(
134134
partition p0 values less than (10)
135135
)`
@@ -326,11 +326,11 @@ func (ts *testSuite) TestTimeZoneChange(c *C) {
326326
" `creation_dt` timestamp DEFAULT CURRENT_TIMESTAMP\n" +
327327
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin\n" +
328328
"PARTITION BY RANGE ( unix_timestamp(`creation_dt`) ) (\n" +
329-
" PARTITION p5 VALUES LESS THAN (1578035400),\n" +
330-
" PARTITION p6 VALUES LESS THAN (1578035700),\n" +
331-
" PARTITION p7 VALUES LESS THAN (1578036000),\n" +
332-
" PARTITION p8 VALUES LESS THAN (1578036300),\n" +
333-
" PARTITION p9 VALUES LESS THAN (MAXVALUE)\n)"))
329+
" PARTITION `p5` VALUES LESS THAN (1578035400),\n" +
330+
" PARTITION `p6` VALUES LESS THAN (1578035700),\n" +
331+
" PARTITION `p7` VALUES LESS THAN (1578036000),\n" +
332+
" PARTITION `p8` VALUES LESS THAN (1578036300),\n" +
333+
" PARTITION `p9` VALUES LESS THAN (MAXVALUE)\n)"))
334334
tk.MustExec("DROP TABLE timezone_test")
335335

336336
// Note that the result of "show create table" varies with time_zone.
@@ -341,11 +341,11 @@ func (ts *testSuite) TestTimeZoneChange(c *C) {
341341
" `creation_dt` timestamp DEFAULT CURRENT_TIMESTAMP\n" +
342342
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin\n" +
343343
"PARTITION BY RANGE ( unix_timestamp(`creation_dt`) ) (\n" +
344-
" PARTITION p5 VALUES LESS THAN (1578064200),\n" +
345-
" PARTITION p6 VALUES LESS THAN (1578064500),\n" +
346-
" PARTITION p7 VALUES LESS THAN (1578064800),\n" +
347-
" PARTITION p8 VALUES LESS THAN (1578065100),\n" +
348-
" PARTITION p9 VALUES LESS THAN (MAXVALUE)\n)"))
344+
" PARTITION `p5` VALUES LESS THAN (1578064200),\n" +
345+
" PARTITION `p6` VALUES LESS THAN (1578064500),\n" +
346+
" PARTITION `p7` VALUES LESS THAN (1578064800),\n" +
347+
" PARTITION `p8` VALUES LESS THAN (1578065100),\n" +
348+
" PARTITION `p9` VALUES LESS THAN (MAXVALUE)\n)"))
349349

350350
// Change time zone and insert data, check the data locates in the correct partition.
351351
tk.MustExec("SET @@time_zone = 'Asia/Shanghai'")

0 commit comments

Comments
 (0)