Skip to content

Commit

Permalink
fix (rotator): defer rows.Close after query errors checking (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
kirychukyurii authored Jul 19, 2023
1 parent 419aa21 commit 00bd5c6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rotator/rotator.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,11 @@ func (r *Rotator) dbExecDropTables(db *sql.DB, listfile, dropfile string, d int)
var partName string

rows, err := db.Query(listquery)
defer rows.Close()
if err != nil {
logp.Err("%v", err)
return err
}
defer rows.Close()

for rows.Next() {
err := rows.Scan(&partName)
Expand Down Expand Up @@ -372,12 +372,14 @@ func (r *Rotator) dbExecDropTablesForFreeSpace(db *sql.DB, listfile, dropfile st
listquery := strings.Replace(listfile, partitionDate, partDate, -1)
listquery = strings.Replace(listquery, partitionTime, partTime, -1)
var partName string

rows, err := db.Query(listquery)
defer rows.Close()
if err != nil {
logp.Err("%v", err)
return err
}
defer rows.Close()

i := 1
for rows.Next() {
err := rows.Scan(&partName)
Expand Down

0 comments on commit 00bd5c6

Please sign in to comment.