From d32b284abad48b7438dd53fc298facdb963cdb81 Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Wed, 25 Jun 2008 17:06:34 +0000 Subject: [PATCH] New config parameter: ignore_startup_parameters Can be used to allow clients issue random parameters. Mostly needed to handle JDBC extra_float_digits braindamage. --- doc/config.txt | 10 ++++++++++ etc/pgbouncer.ini | 6 ++++++ include/bouncer.h | 2 ++ src/client.c | 5 ++++- src/main.c | 3 +++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/doc/config.txt b/doc/config.txt index 25c9a6a..116573c 100644 --- a/doc/config.txt +++ b/doc/config.txt @@ -145,6 +145,16 @@ achieving uniform load. Default: 0 +==== ignore_startup_parameters ==== + +By default, PgBouncer allows only parameters it can keep track of in startup +packets - `client_encoding`, `datestyle`, `timezone` and `standard_conforming_strings`. + +All others raise error. To allow but ignore others too, they can be specified here, +so that pgbouncer knows that they are handled by admin and it can ignore them. + +Default: empty + === Log settings === ==== syslog ==== diff --git a/etc/pgbouncer.ini b/etc/pgbouncer.ini index fef3bdc..95d6a8a 100644 --- a/etc/pgbouncer.ini +++ b/etc/pgbouncer.ini @@ -69,6 +69,12 @@ pool_mode = session ; server_reset_query = +; +; Comma-separated list of parameters to ignore when given +; in startup packet. +; +;ignore_startup_parameters = extra_float_digits + ; ; When taking idle server into use, this query is ran first. ; SELECT 1 diff --git a/include/bouncer.h b/include/bouncer.h index 83cd1a5..608472a 100644 --- a/include/bouncer.h +++ b/include/bouncer.h @@ -324,6 +324,8 @@ extern char *cf_auth_file; extern char *cf_logfile; extern char *cf_pidfile; +extern char *cf_ignore_startup_params; + extern char *cf_admin_users; extern char *cf_stats_users; extern int cf_stats_period; diff --git a/src/client.c b/src/client.c index 5bd5087..bda55b7 100644 --- a/src/client.c +++ b/src/client.c @@ -113,7 +113,10 @@ static bool decide_startup_pool(PgSocket *client, PktHdr *pkt) username = val; else if (varcache_set(&client->vars, key, val)) slog_debug(client, "got var: %s=%s", key, val); - else { + else if (strlist_contains(cf_ignore_startup_params, key)) { + slog_debug(client, "ignoring startup parameter: %s=%s", key, val); + } else { + slog_warning(client, "unsupported startup parameter: %s=%s", key, val); disconnect_client(client, true, "Unknown startup parameter"); return false; } diff --git a/src/main.c b/src/main.c index d2c1a8c..f19d147 100644 --- a/src/main.c +++ b/src/main.c @@ -94,6 +94,8 @@ char *cf_server_check_query = "select 1"; usec_t cf_server_check_delay = 30 * USEC; int cf_server_round_robin = 0; +char *cf_ignore_startup_params = ""; + usec_t cf_server_lifetime = 60*60*USEC; usec_t cf_server_idle_timeout = 10*60*USEC; usec_t cf_server_connect_timeout = 15*USEC; @@ -149,6 +151,7 @@ ConfElem bouncer_params[] = { {"server_login_retry", true, CF_TIME, &cf_server_login_retry}, {"server_round_robin", true, CF_INT, &cf_server_round_robin}, {"suspend_timeout", true, CF_TIME, &cf_suspend_timeout}, +{"ignore_startup_parameters", true, CF_STR, &cf_ignore_startup_params}, {"pkt_buf", false, CF_INT, &cf_sbuf_len}, {"tcp_defer_accept", true, {cf_get_int, set_defer_accept}, &cf_tcp_defer_accept}, -- 2.40.0