Cache these types in memory
(ctx context.Context, oid uint32)
| 73 | |
| 74 | // Cache these types in memory |
| 75 | func (a *Analyzer) tableInfo(ctx context.Context, oid uint32) (*pgTable, error) { |
| 76 | ctbl, ok := a.tables.Load(oid) |
| 77 | if ok { |
| 78 | return ctbl.(*pgTable), nil |
| 79 | } |
| 80 | rows, err := a.pool.Query(ctx, tableQuery, oid) |
| 81 | if err != nil { |
| 82 | return nil, err |
| 83 | } |
| 84 | tbl, err := pgx.CollectOneRow(rows, pgx.RowToStructByName[pgTable]) |
| 85 | if err != nil { |
| 86 | return nil, err |
| 87 | } |
| 88 | a.tables.Store(oid, &tbl) |
| 89 | return &tbl, nil |
| 90 | } |
| 91 | |
| 92 | type pgColumn struct { |
| 93 | DataType string `db:"data_type"` |
no test coverage detected