MCPcopy
hub / github.com/pingcap/tidb / GetPrimaryKeyAndColumnTypes

Function GetPrimaryKeyAndColumnTypes

dumpling/export/sql.go:624–639  ·  view source on GitHub ↗

GetPrimaryKeyAndColumnTypes gets all primary columns and their types in ordinal order

(tctx *tcontext.Context, conn *BaseConn, meta TableMeta)

Source from the content-addressed store, hash-verified

622
623// GetPrimaryKeyAndColumnTypes gets all primary columns and their types in ordinal order
624func GetPrimaryKeyAndColumnTypes(tctx *tcontext.Context, conn *BaseConn, meta TableMeta) ([]string, []string, error) {
625 var (
626 colNames, colTypes []string
627 err error
628 )
629 colNames, err = GetPrimaryKeyColumns(tctx, conn, meta.DatabaseName(), meta.TableName())
630 if err != nil {
631 return nil, nil, err
632 }
633 colName2Type := string2Map(meta.ColumnNames(), meta.ColumnTypes())
634 colTypes = make([]string, len(colNames))
635 for i, colName := range colNames {
636 colTypes[i] = colName2Type[colName]
637 }
638 return colNames, colTypes, nil
639}
640
641// GetPrimaryKeyColumns gets all primary columns in ordinal order
642func GetPrimaryKeyColumns(tctx *tcontext.Context, db *BaseConn, database, table string) ([]string, error) {

Callers 1

selectTiDBRowKeyFieldsFunction · 0.85

Calls 6

GetPrimaryKeyColumnsFunction · 0.85
string2MapFunction · 0.85
DatabaseNameMethod · 0.65
TableNameMethod · 0.65
ColumnNamesMethod · 0.65
ColumnTypesMethod · 0.65

Tested by

no test coverage detected