Skip to content

Commit

Permalink
fix(inputs.mysql): Revert slice declarations with non-zero initial le…
Browse files Browse the repository at this point in the history
…ngth (#12409)

Co-authored-by: Pawel Zak <Pawel Zak>
(cherry picked from commit 9b24184)
  • Loading branch information
zak-pawel authored and Sven Rebhan committed Jan 30, 2023
1 parent 05940d8 commit 385c39a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions plugins/inputs/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,13 +607,12 @@ func (m *Mysql) gatherSlaveStatuses(db *sql.DB, serv string, acc telegraf.Accumu
return err
}

vals := make([]sql.RawBytes, 0, len(cols))
valPtrs := make([]interface{}, 0, len(cols))
vals := make([]sql.RawBytes, len(cols))
valPtrs := make([]interface{}, len(cols))
// fill the array with sql.Rawbytes
for range cols {
rawBytes := sql.RawBytes{}
vals = append(vals, rawBytes)
valPtrs = append(valPtrs, &rawBytes)
for i := range vals {
vals[i] = sql.RawBytes{}
valPtrs[i] = &vals[i]
}
if err = rows.Scan(valPtrs...); err != nil {
return err
Expand Down

0 comments on commit 385c39a

Please sign in to comment.