MCPcopy Index your code
hub / github.com/pingcap/tidb / GetPartitionNames

Function GetPartitionNames

dumpling/export/sql.go:1442–1458  ·  view source on GitHub ↗

GetPartitionNames get partition names from a specified table

(tctx *tcontext.Context, db *BaseConn, schema, table string)

Source from the content-addressed store, hash-verified

1440
1441// GetPartitionNames get partition names from a specified table
1442func GetPartitionNames(tctx *tcontext.Context, db *BaseConn, schema, table string) (partitions []string, err error) {
1443 partitions = make([]string, 0)
1444 var partitionName sql.NullString
1445 err = db.QuerySQL(tctx, func(rows *sql.Rows) error {
1446 err := rows.Scan(&partitionName)
1447 if err != nil {
1448 return errors.Trace(err)
1449 }
1450 if partitionName.Valid {
1451 partitions = append(partitions, partitionName.String)
1452 }
1453 return nil
1454 }, func() {
1455 partitions = partitions[:0]
1456 }, "SELECT PARTITION_NAME from INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?", schema, table)
1457 return
1458}
1459
1460// GetPartitionTableIDs get partition tableIDs through histograms.
1461// SHOW STATS_HISTOGRAMS has db_name,table_name,partition_name but doesn't have partition id

Callers 1

Calls 2

QuerySQLMethod · 0.80
ScanMethod · 0.65

Tested by

no test coverage detected