diff --git a/pkg/common/utils/mysql/doris.go b/pkg/common/utils/mysql/doris.go index 68609cdd..608049a6 100644 --- a/pkg/common/utils/mysql/doris.go +++ b/pkg/common/utils/mysql/doris.go @@ -18,11 +18,12 @@ package mysql import ( - _ "github.com/go-sql-driver/mysql" - "k8s.io/klog/v2" "sort" "strconv" "strings" + + _ "github.com/go-sql-driver/mysql" + "k8s.io/klog/v2" ) const ( @@ -67,7 +68,6 @@ type Backend struct { TabletNum int64 `json:"tablet_num" db:"TabletNum"` DataUsedCapacity string `json:"data_used_capacity" db:"DataUsedCapacity"` TrashUsedCapacity string `json:"trash_used_capacity" db:"TrashUsedCapacity"` - TrashUsedCapcacity string `json:"trash_used_capcacity" db:"TrashUsedCapcacity"` AvailCapacity string `json:"avail_capacity" db:"AvailCapacity"` TotalCapacity string `json:"total_capacity" db:"TotalCapacity"` UsedPct string `json:"used_pct" db:"UsedPct"` diff --git a/pkg/common/utils/mysql/mysql.go b/pkg/common/utils/mysql/mysql.go index faa0076c..dbfda27e 100644 --- a/pkg/common/utils/mysql/mysql.go +++ b/pkg/common/utils/mysql/mysql.go @@ -60,6 +60,9 @@ type DB struct { *sqlx.DB } +// Debugging this code cannot be done through a standalone process on the host machine; +// it can only be done by building the operator because it depends on the network configuration of the Kubernetes cluster. + func NewDorisSqlDB(cfg DBConfig, tlsConfig *TLSConfig, secret *corev1.Secret) (*DB, error) { dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s", cfg.User, cfg.Password, cfg.Host, cfg.Port, cfg.Database) rootCertPool := x509.NewCertPool() @@ -140,22 +143,26 @@ func (db *DB) Close() error { } func (db *DB) Exec(query string, args ...interface{}) (sql.Result, error) { - return db.DB.Exec(query, args...) + return db.DB.Unsafe().Exec(query, args...) } func (db *DB) Select(dest interface{}, query string, args ...interface{}) error { return db.DB.Select(dest, query, args...) } +func (db *DB) USelect(dest interface{}, query string, args ...interface{}) error { + return db.DB.Unsafe().Select(dest, query, args...) +} + func (db *DB) ShowFrontends() ([]*Frontend, error) { var fes []*Frontend - err := db.Unsafe().Select(&fes, "show frontends") + err := db.USelect(&fes, "show frontends") return fes, err } func (db *DB) ShowBackends() ([]*Backend, error) { var bes []*Backend - err := db.Unsafe().Select(&bes, "show backends") + err := db.USelect(&bes, "show backends") return bes, err }