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

Function FetchTableColumns

src/go/plugin/go.d/pkg/sqlquery/columns.go:38–64  ·  view source on GitHub ↗

FetchTableColumns returns the set of column names for schema.table. If transform is non-nil, it is applied to each column name before insertion.

(ctx context.Context, q Queryer, schema, table string, style PlaceholderStyle, transform func(string) string)

Source from the content-addressed store, hash-verified

36// FetchTableColumns returns the set of column names for schema.table.
37// If transform is non-nil, it is applied to each column name before insertion.
38func FetchTableColumns(ctx context.Context, q Queryer, schema, table string, style PlaceholderStyle, transform func(string) string) (map[string]bool, error) {
39 query, err := tableColumnsQuery(style)
40 if err != nil {
41 return nil, err
42 }
43 rows, err := q.QueryContext(ctx, query, schema, table)
44 if err != nil {
45 return nil, err
46 }
47 defer func() { _ = rows.Close() }()
48
49 cols := make(map[string]bool)
50 for rows.Next() {
51 var name string
52 if err := rows.Scan(&name); err != nil {
53 return nil, err
54 }
55 if transform != nil {
56 name = transform(name)
57 }
58 cols[name] = true
59 }
60 if err := rows.Err(); err != nil {
61 return nil, err
62 }
63 return cols, nil
64}

Callers 1

TestFetchTableColumnsFunction · 0.85

Calls 6

tableColumnsQueryFunction · 0.85
QueryContextMethod · 0.65
CloseMethod · 0.65
NextMethod · 0.65
ScanMethod · 0.65
ErrMethod · 0.65

Tested by 1

TestFetchTableColumnsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…