Skip to content

Commit b69fd32

Browse files
committed
Support connect_query via PGBOUNCER_CONNECT_QUERY
Squashed version of #1 and heroku#95 to make patches easier to carry forward.
1 parent 75ea228 commit b69fd32

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ Some settings are configurable through app config vars at runtime. Refer to the
146146
- `PGBOUNCER_SERVER_RESET_QUERY` Default is empty when pool mode is transaction, and "DISCARD ALL;" when session.
147147
- `PGBOUNCER_IGNORE_STARTUP_PARAMETERS` Adds parameters to ignore when pgbouncer is starting. Some postgres libraries, like Go's pq, append this parameter, making it impossible to use this buildpack. Default is empty and the most common ignored parameter is `extra_float_digits`. Multiple parameters can be seperated via commas. Example: `PGBOUNCER_IGNORE_STARTUP_PARAMETERS="extra_float_digits, some_other_param"`
148148
- `PGBOUNCER_QUERY_WAIT_TIMEOUT` Default is 120 seconds, helps when the server is down or the database rejects connections for any reason. If this is disabled, clients will be queued infinitely.
149+
- `PGBOUNCER_CONNECT_QUERY` Default is empty. The query to be executed on newly created connections. This is useful for setting things like `statement_timeout`. e.g. `PGBOUNCER_CONNECT_QUERY="set statement_timeout to 10000"`
149150

150151
For more info, see [CONTRIBUTING.md](CONTRIBUTING.md)
151152

bin/gen-pgbouncer-conf.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ do
9090
EOFEOF
9191

9292
cat >> "$CONFIG_DIR/pgbouncer.ini" << EOFEOF
93-
$CLIENT_DB_NAME= host=$DB_HOST dbname=$DB_NAME port=$DB_PORT
93+
$CLIENT_DB_NAME= host=$DB_HOST dbname=$DB_NAME port=$DB_PORT ${PGBOUNCER_CONNECT_QUERY:+connect_query=\'${PGBOUNCER_CONNECT_QUERY//\'/\'\'}\'}
9494
EOFEOF
9595

9696
(( n += 1 ))

0 commit comments

Comments
 (0)