| 241 | } |
| 242 | |
| 243 | func setPlanCacheMode(config *pgx.ConnConfig) { |
| 244 | // Default plan cache mode |
| 245 | const defaultMode = "auto" |
| 246 | |
| 247 | // Extract connection string |
| 248 | connStr := config.ConnString() |
| 249 | planCacheMode := defaultMode |
| 250 | |
| 251 | // Check for specific plan cache modes in the connection string |
| 252 | for key, value := range planCacheModes { |
| 253 | if strings.Contains(connStr, "plan_cache_mode="+key) { |
| 254 | if key == "disable" { |
| 255 | delete(config.RuntimeParams, "plan_cache_mode") |
| 256 | slog.Info("setPlanCacheMode", slog.String("mode", "disabled")) |
| 257 | return |
| 258 | } |
| 259 | planCacheMode = value |
| 260 | slog.Info("setPlanCacheMode", slog.String("mode", key)) |
| 261 | break |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | // Set the plan cache mode |
| 266 | config.RuntimeParams["plan_cache_mode"] = planCacheMode |
| 267 | if planCacheMode == defaultMode { |
| 268 | slog.Warn("setPlanCacheMode", slog.String("mode", defaultMode)) |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | // createPools initializes read and write connection pools with appropriate configurations and error handling. |
| 273 | func createPools(ctx context.Context, wConfig, rConfig *pgxpool.Config) (*pgxpool.Pool, *pgxpool.Pool, error) { |