MCPcopy
hub / github.com/sqlc-dev/sqlc / columnInfo

Method columnInfo

internal/engine/postgresql/analyzer/analyze.go:104–120  ·  view source on GitHub ↗

Cache these types in memory

(ctx context.Context, field pgconn.FieldDescription)

Source from the content-addressed store, hash-verified

102
103// Cache these types in memory
104func (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
122type formatKey struct {
123 OID uint32

Callers 1

AnalyzeMethod · 0.95

Implementers 3

CachedAnalyzerinternal/analyzer/analyzer.go
Analyzerinternal/engine/postgresql/analyzer/an
Analyzerinternal/engine/sqlite/analyzer/analyz

Calls 1

QueryMethod · 0.65

Tested by

no test coverage detected