Skip to content

Commit

Permalink
Support connect_query via PGBOUNCER_CONNECT_QUERY
Browse files Browse the repository at this point in the history
Squashed version of #1 and
heroku#95 to make
patches easier to carry forward.
  • Loading branch information
nixme committed Jan 26, 2024
1 parent 75ea228 commit b69fd32
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ Some settings are configurable through app config vars at runtime. Refer to the
- `PGBOUNCER_SERVER_RESET_QUERY` Default is empty when pool mode is transaction, and "DISCARD ALL;" when session.
- `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"`
- `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.
- `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"`

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

Expand Down
2 changes: 1 addition & 1 deletion bin/gen-pgbouncer-conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ do
EOFEOF

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

(( n += 1 ))
Expand Down

0 comments on commit b69fd32

Please sign in to comment.