Skip to content

Commit

Permalink
Add comment on why we do not error out when prepare fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
srebhan committed May 5, 2023
1 parent cc180ff commit 755a306
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plugins/inputs/sql/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,11 @@ func (s *SQL) Start(_ telegraf.Accumulator) error {
stmt, err := s.db.PrepareContext(ctx, q.Query)
cancel()
if err != nil {
// Some database drivers or databases do not support prepare
// statements and report an error here. However, we can still
// execute unprepared queries for those setups so do not bail-out
// here but simply do leave the `statement` with a `nil` value
// indicating no prepared statement.
s.Log.Warnf("preparing query %q failed: %w; falling back to unprepared query", q.Query, err)
continue
}
Expand Down

0 comments on commit 755a306

Please sign in to comment.