GetPartitionNames get partition names from a specified table
(tctx *tcontext.Context, db *BaseConn, schema, table string)
| 1440 | |
| 1441 | // GetPartitionNames get partition names from a specified table |
| 1442 | func 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 |
no test coverage detected