Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/common/utils/mysql/doris.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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"`
Expand Down
13 changes: 10 additions & 3 deletions pkg/common/utils/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
}

Expand Down