MCPcopy Index your code
hub / github.com/netdata/netdata / QueryRows

Function QueryRows

src/go/plugin/go.d/pkg/sqlquery/query.go:21–33  ·  view source on GitHub ↗

QueryRows executes query and streams row values through assign. The returned duration measures query submission latency (QueryContext call).

(ctx context.Context, q Queryer, query string, assign AssignFunc, args ...any)

Source from the content-addressed store, hash-verified

19// QueryRows executes query and streams row values through assign.
20// The returned duration measures query submission latency (QueryContext call).
21func QueryRows(ctx context.Context, q Queryer, query string, assign AssignFunc, args ...any) (time.Duration, error) {
22 start := time.Now()
23 rows, err := q.QueryContext(ctx, query, args...)
24 queryDuration := time.Since(start)
25 if err != nil {
26 return 0, err
27 }
28 defer func() { _ = rows.Close() }()
29 if err := readRows(rows, assign); err != nil {
30 return queryDuration, err
31 }
32 return queryDuration, nil
33}
34
35// readRows scans all rows and invokes assign for every column value.
36func readRows(rows *sql.Rows, assign AssignFunc) error {

Callers 1

TestQueryRowsFunction · 0.85

Calls 3

readRowsFunction · 0.70
QueryContextMethod · 0.65
CloseMethod · 0.65

Tested by 1

TestQueryRowsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…