Skip to content

Commit

Permalink
infoschema: support query partition_id from infoschema.partitions (pi…
Browse files Browse the repository at this point in the history
…ngcap#22240)

Signed-off-by: lysu <[email protected]>
  • Loading branch information
lysu authored Jan 22, 2021
1 parent cd390bd commit b24095d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions executor/infoschema_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ func (e *memtableRetriever) setDataFromPartitions(ctx sessionctx.Context, schema
nil, // PARTITION_COMMENT
nil, // NODEGROUP
nil, // TABLESPACE_NAME
nil, // TIDB_PARTITION_ID
)
rows = append(rows, record)
} else {
Expand Down Expand Up @@ -785,6 +786,7 @@ func (e *memtableRetriever) setDataFromPartitions(ctx sessionctx.Context, schema
pi.Comment, // PARTITION_COMMENT
nil, // NODEGROUP
nil, // TABLESPACE_NAME
pi.ID, // TIDB_PARTITION_ID
)
rows = append(rows, record)
}
Expand Down
3 changes: 3 additions & 0 deletions executor/infoschema_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,9 @@ func (s *testInfoschemaTableSerialSuite) TestPartitionsTable(c *C) {

tk.MustExec("create table test_partitions (a bigint, b date) partition by list columns (a,b) (partition p0 values in ((1,'2020-09-28'),(1,'2020-09-29')));")
tk.MustQuery("select PARTITION_NAME,PARTITION_METHOD,PARTITION_EXPRESSION from information_schema.partitions where table_name = 'test_partitions';").Check(testkit.Rows("p0 LIST COLUMNS a,b"))
pid, err := strconv.Atoi(tk.MustQuery("select TIDB_PARTITION_ID from information_schema.partitions where table_name = 'test_partitions';").Rows()[0][0].(string))
c.Assert(err, IsNil)
c.Assert(pid, Greater, 0)
tk.MustExec("drop table test_partitions")
}

Expand Down
1 change: 1 addition & 0 deletions infoschema/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ var partitionsCols = []columnInfo{
{name: "PARTITION_COMMENT", tp: mysql.TypeVarchar, size: 80},
{name: "NODEGROUP", tp: mysql.TypeVarchar, size: 12},
{name: "TABLESPACE_NAME", tp: mysql.TypeVarchar, size: 64},
{name: "TIDB_PARTITION_ID", tp: mysql.TypeLonglong, size: 21},
}

var tableConstraintsCols = []columnInfo{
Expand Down

0 comments on commit b24095d

Please sign in to comment.