Skip to content

Commit

Permalink
fix: mysql数据库为空时无法备份
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Oct 28, 2024
1 parent 8ad7867 commit 9541ff8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/db/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (m *MySQL) DatabaseExists(name string) (bool, error) {

func (m *MySQL) DatabaseSize(name string) (int64, error) {
var size int64
err := m.QueryRow(fmt.Sprintf("SELECT SUM(data_length + index_length) FROM information_schema.tables WHERE table_schema = '%s'", name)).Scan(&size)
err := m.QueryRow(fmt.Sprintf("SELECT COALESCE(SUM(data_length) + SUM(index_length), 0) FROM information_schema.tables WHERE table_schema = '%s'", name)).Scan(&size)
return size, err
}

Expand Down

0 comments on commit 9541ff8

Please sign in to comment.