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

Function ShowMasterStatus

dumpling/export/sql.go:748–779  ·  view source on GitHub ↗

ShowMasterStatus get SHOW MASTER STATUS result from database

(db *sql.Conn, serverInfo version.ServerInfo)

Source from the content-addressed store, hash-verified

746
747// ShowMasterStatus get SHOW MASTER STATUS result from database
748func ShowMasterStatus(db *sql.Conn, serverInfo version.ServerInfo) ([]string, error) {
749 var oneRow []string
750 handleOneRow := func(rows *sql.Rows) error {
751 cols, err := rows.Columns()
752 if err != nil {
753 return errors.Trace(err)
754 }
755 fieldNum := len(cols)
756 oneRow = make([]string, fieldNum)
757 addr := make([]any, fieldNum)
758 for i := range oneRow {
759 addr[i] = &oneRow[i]
760 }
761 return rows.Scan(addr...)
762 }
763
764 // MySQL 8.4.0 and newer: SHOW BINARY LOG STATUS
765 // TiDB, MariaDB, Old MySQL: SHOW MASTER STATUS
766 showMasterStatusQuery := "SHOW MASTER STATUS"
767 if serverInfo.ServerVersion != nil {
768 if serverInfo.ServerType == version.ServerTypeMySQL &&
769 !serverInfo.ServerVersion.LessThan(*minNewTerminologyMySQL) {
770 showMasterStatusQuery = "SHOW BINARY LOG STATUS"
771 }
772 }
773
774 err := simpleQuery(db, showMasterStatusQuery, handleOneRow)
775 if err != nil {
776 return nil, errors.Annotatef(err, "sql: %s", showMasterStatusQuery)
777 }
778 return oneRow, nil
779}
780
781// GetSpecifiedColumnValueAndClose get columns' values whose name is equal to columnName and close the given rows
782func GetSpecifiedColumnValueAndClose(rows *sql.Rows, columnName string) ([]string, error) {

Callers 2

getSnapshotFunction · 0.85
recordGlobalMetaDataFunction · 0.85

Calls 4

simpleQueryFunction · 0.85
LessThanMethod · 0.80
ColumnsMethod · 0.65
ScanMethod · 0.65

Tested by

no test coverage detected