Cache these types in memory
(ctx context.Context, field pgconn.FieldDescription)
| 102 | |
| 103 | // Cache these types in memory |
| 104 | func (a *Analyzer) columnInfo(ctx context.Context, field pgconn.FieldDescription) (*pgColumn, error) { |
| 105 | key := columnKey{field.TableOID, field.TableAttributeNumber} |
| 106 | cinfo, ok := a.columns.Load(key) |
| 107 | if ok { |
| 108 | return cinfo.(*pgColumn), nil |
| 109 | } |
| 110 | rows, err := a.pool.Query(ctx, columnQuery, field.TableOID, int16(field.TableAttributeNumber)) |
| 111 | if err != nil { |
| 112 | return nil, err |
| 113 | } |
| 114 | col, err := pgx.CollectOneRow(rows, pgx.RowToStructByName[pgColumn]) |
| 115 | if err != nil { |
| 116 | return nil, err |
| 117 | } |
| 118 | a.columns.Store(key, &col) |
| 119 | return &col, nil |
| 120 | } |
| 121 | |
| 122 | type formatKey struct { |
| 123 | OID uint32 |
no test coverage detected