Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should be use the database name from the configuration when query pg database size? #558

Open
GangZhuo opened this issue Oct 9, 2024 · 0 comments

Comments

@GangZhuo
Copy link

GangZhuo commented Oct 9, 2024

The following 201 lines of code: rows, err := db.Query("select pg_database_size('homer_data');")

func (r *Rotator) GetDatabaseSize(db *sql.DB, schema string) (float64, error) {
var databaseSize string
var size float64
var err error
switch schema {
case "maxusage":
rows, err := db.Query("select pg_database_size('homer_data');")
checkDBErr(err)
if err == nil {
if rows.Next() {
err = rows.Scan(&databaseSize)
if err != nil {
logp.Err("%v", err)
return 0, err
}
}
size, err = strconv.ParseFloat(databaseSize, 64)
} else {
logp.Err("Error maxusage: %v", err)
return 0, err
}
default:
rows, err := db.Query("select * from sys_df();")
checkDBErr(err)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant