diff --git a/connection_details.go b/connection_details.go index 83895380..75a6996f 100644 --- a/connection_details.go +++ b/connection_details.go @@ -55,6 +55,8 @@ type ConnectionDetails struct { RawOptions string // TracerProvider is the OpenTelemetry tracer provider to use for tracing SQL calls. TracerProvider trace.TracerProvider + // AllowMinPool enables min pool enforcement. + AllowMinPool bool } var dialectX = regexp.MustCompile(`\S+://`) diff --git a/connection_instrumented.go b/connection_instrumented.go index bc80a7df..dbe95fe3 100644 --- a/connection_instrumented.go +++ b/connection_instrumented.go @@ -37,7 +37,7 @@ func openPotentiallyInstrumentedConnection(ctx context.Context, c dialect, dsn s } ) // If "pool_min_conns" is set in the DSN, it means that we use the pgx pool feature flag. - if strings.Contains(dsn, "pool_min_conns=") && (CanonicalDialect(driver) == nameCockroach || CanonicalDialect(driver) == namePostgreSQL) { + if c.Details().AllowMinPool && strings.Contains(dsn, "pool_min_conns=") && (CanonicalDialect(driver) == nameCockroach || CanonicalDialect(driver) == namePostgreSQL) { pool, err := pgxpool.New(ctx, dsn) if err != nil { return nil, nil, err