99
1010 "github.com/boringsql/queries"
1111 "github.com/jackc/pgx/v5"
12- "github.com/jackc/pgx/v5/pgxpool"
1312)
1413
1514// scanAll wraps the standard rows.Next loop. The scan callback receives the
@@ -27,7 +26,7 @@ func scanAll[T any](rows pgx.Rows, scan func(pgx.Rows) (T, error)) ([]T, error)
2726 return out , rows .Err ()
2827}
2928
30- func query (ctx context.Context , pool * pgxpool. Pool , name string ) (pgx.Rows , error ) {
29+ func query (ctx context.Context , pool Querier , name string ) (pgx.Rows , error ) {
3130 return pool .Query (ctx , q (name ))
3231}
3332
@@ -48,7 +47,7 @@ func q(name string) string {
4847}
4948
5049// DDL-only introspection; planner/activity stats now flow through CapturePlannerStats / CaptureActivityStats
51- func IntrospectSchema (ctx context.Context , pool * pgxpool. Pool ) (* SchemaSnapshot , error ) {
50+ func IntrospectSchema (ctx context.Context , pool Querier ) (* SchemaSnapshot , error ) {
5251 var pgVersion string
5352 if err := pool .QueryRow (ctx , "SELECT version()" ).Scan (& pgVersion ); err != nil {
5453 return nil , fmt .Errorf ("query pg version: %w" , err )
@@ -253,7 +252,7 @@ type (
253252
254253// Fetchers - each uses a named query from sql/introspect.sql
255254
256- func fetchTables (ctx context.Context , pool * pgxpool. Pool ) ([]rawTable , error ) {
255+ func fetchTables (ctx context.Context , pool Querier ) ([]rawTable , error ) {
257256 rows , err := query (ctx , pool , "fetch-tables" )
258257 if err != nil {
259258 return nil , err
@@ -267,7 +266,7 @@ func fetchTables(ctx context.Context, pool *pgxpool.Pool) ([]rawTable, error) {
267266 })
268267}
269268
270- func fetchColumns (ctx context.Context , pool * pgxpool. Pool ) ([]rawColumn , error ) {
269+ func fetchColumns (ctx context.Context , pool Querier ) ([]rawColumn , error ) {
271270 rows , err := query (ctx , pool , "fetch-columns" )
272271 if err != nil {
273272 return nil , err
@@ -281,7 +280,7 @@ func fetchColumns(ctx context.Context, pool *pgxpool.Pool) ([]rawColumn, error)
281280 })
282281}
283282
284- func fetchConstraints (ctx context.Context , pool * pgxpool. Pool ) ([]rawConstraint , error ) {
283+ func fetchConstraints (ctx context.Context , pool Querier ) ([]rawConstraint , error ) {
285284 rows , err := query (ctx , pool , "fetch-constraints" )
286285 if err != nil {
287286 return nil , err
@@ -295,7 +294,7 @@ func fetchConstraints(ctx context.Context, pool *pgxpool.Pool) ([]rawConstraint,
295294 })
296295}
297296
298- func fetchTableComments (ctx context.Context , pool * pgxpool. Pool ) ([]rawTableComment , error ) {
297+ func fetchTableComments (ctx context.Context , pool Querier ) ([]rawTableComment , error ) {
299298 rows , err := query (ctx , pool , "fetch-table-comments" )
300299 if err != nil {
301300 return nil , err
@@ -309,7 +308,7 @@ func fetchTableComments(ctx context.Context, pool *pgxpool.Pool) ([]rawTableComm
309308 })
310309}
311310
312- func fetchColumnComments (ctx context.Context , pool * pgxpool. Pool ) ([]rawColumnComment , error ) {
311+ func fetchColumnComments (ctx context.Context , pool Querier ) ([]rawColumnComment , error ) {
313312 rows , err := query (ctx , pool , "fetch-column-comments" )
314313 if err != nil {
315314 return nil , err
@@ -323,7 +322,7 @@ func fetchColumnComments(ctx context.Context, pool *pgxpool.Pool) ([]rawColumnCo
323322 })
324323}
325324
326- func fetchEnums (ctx context.Context , pool * pgxpool. Pool ) ([]EnumType , error ) {
325+ func fetchEnums (ctx context.Context , pool Querier ) ([]EnumType , error ) {
327326 rows , err := query (ctx , pool , "fetch-enums" )
328327 if err != nil {
329328 return nil , err
@@ -335,7 +334,7 @@ func fetchEnums(ctx context.Context, pool *pgxpool.Pool) ([]EnumType, error) {
335334 })
336335}
337336
338- func fetchDomains (ctx context.Context , pool * pgxpool. Pool ) ([]DomainType , error ) {
337+ func fetchDomains (ctx context.Context , pool Querier ) ([]DomainType , error ) {
339338 rows , err := query (ctx , pool , "fetch-domains" )
340339 if err != nil {
341340 return nil , err
@@ -349,7 +348,7 @@ func fetchDomains(ctx context.Context, pool *pgxpool.Pool) ([]DomainType, error)
349348 })
350349}
351350
352- func fetchComposites (ctx context.Context , pool * pgxpool. Pool ) ([]CompositeType , error ) {
351+ func fetchComposites (ctx context.Context , pool Querier ) ([]CompositeType , error ) {
353352 rows , err := pool .Query (ctx , q ("fetch-composites" ))
354353 if err != nil {
355354 return nil , err
@@ -400,7 +399,7 @@ func fetchComposites(ctx context.Context, pool *pgxpool.Pool) ([]CompositeType,
400399 return out , nil
401400}
402401
403- func fetchIndexes (ctx context.Context , pool * pgxpool. Pool ) ([]rawIndex , error ) {
402+ func fetchIndexes (ctx context.Context , pool Querier ) ([]rawIndex , error ) {
404403 rows , err := query (ctx , pool , "fetch-indexes" )
405404 if err != nil {
406405 return nil , err
@@ -432,7 +431,7 @@ func fetchIndexes(ctx context.Context, pool *pgxpool.Pool) ([]rawIndex, error) {
432431 })
433432}
434433
435- func fetchPartitionInfo (ctx context.Context , pool * pgxpool. Pool ) ([]rawPartitionInfo , error ) {
434+ func fetchPartitionInfo (ctx context.Context , pool Querier ) ([]rawPartitionInfo , error ) {
436435 rows , err := query (ctx , pool , "fetch-partition-info" )
437436 if err != nil {
438437 return nil , err
@@ -446,7 +445,7 @@ func fetchPartitionInfo(ctx context.Context, pool *pgxpool.Pool) ([]rawPartition
446445 })
447446}
448447
449- func fetchPartitionChildren (ctx context.Context , pool * pgxpool. Pool ) ([]rawPartitionChild , error ) {
448+ func fetchPartitionChildren (ctx context.Context , pool Querier ) ([]rawPartitionChild , error ) {
450449 rows , err := query (ctx , pool , "fetch-partition-children" )
451450 if err != nil {
452451 return nil , err
@@ -466,7 +465,7 @@ func fetchPartitionChildren(ctx context.Context, pool *pgxpool.Pool) ([]rawParti
466465 })
467466}
468467
469- func fetchPolicies (ctx context.Context , pool * pgxpool. Pool ) ([]rawPolicy , error ) {
468+ func fetchPolicies (ctx context.Context , pool Querier ) ([]rawPolicy , error ) {
470469 rows , err := query (ctx , pool , "fetch-policies" )
471470 if err != nil {
472471 return nil , err
@@ -480,7 +479,7 @@ func fetchPolicies(ctx context.Context, pool *pgxpool.Pool) ([]rawPolicy, error)
480479 })
481480}
482481
483- func fetchTriggers (ctx context.Context , pool * pgxpool. Pool ) ([]rawTrigger , error ) {
482+ func fetchTriggers (ctx context.Context , pool Querier ) ([]rawTrigger , error ) {
484483 rows , err := query (ctx , pool , "fetch-triggers" )
485484 if err != nil {
486485 return nil , err
@@ -495,7 +494,7 @@ func fetchTriggers(ctx context.Context, pool *pgxpool.Pool) ([]rawTrigger, error
495494}
496495
497496
498- func fetchViews (ctx context.Context , pool * pgxpool. Pool ) ([]View , error ) {
497+ func fetchViews (ctx context.Context , pool Querier ) ([]View , error ) {
499498 rows , err := query (ctx , pool , "fetch-views" )
500499 if err != nil {
501500 return nil , err
@@ -513,7 +512,7 @@ func fetchViews(ctx context.Context, pool *pgxpool.Pool) ([]View, error) {
513512 })
514513}
515514
516- func fetchFunctions (ctx context.Context , pool * pgxpool. Pool ) ([]Function , error ) {
515+ func fetchFunctions (ctx context.Context , pool Querier ) ([]Function , error ) {
517516 rows , err := query (ctx , pool , "fetch-functions" )
518517 if err != nil {
519518 return nil , err
@@ -541,7 +540,7 @@ func fetchFunctions(ctx context.Context, pool *pgxpool.Pool) ([]Function, error)
541540 })
542541}
543542
544- func fetchExtensions (ctx context.Context , pool * pgxpool. Pool ) ([]Extension , error ) {
543+ func fetchExtensions (ctx context.Context , pool Querier ) ([]Extension , error ) {
545544 rows , err := query (ctx , pool , "fetch-extensions" )
546545 if err != nil {
547546 return nil , err
@@ -553,7 +552,7 @@ func fetchExtensions(ctx context.Context, pool *pgxpool.Pool) ([]Extension, erro
553552 })
554553}
555554
556- func fetchGUCs (ctx context.Context , pool * pgxpool. Pool ) ([]GucSetting , error ) {
555+ func fetchGUCs (ctx context.Context , pool Querier ) ([]GucSetting , error ) {
557556 rows , err := query (ctx , pool , "fetch-gucs" )
558557 if err != nil {
559558 return nil , err
0 commit comments