diff options
author | Bo Peng | 2025-07-17 05:31:02 +0000 |
---|---|---|
committer | Bo Peng | 2025-07-17 05:31:02 +0000 |
commit | 3cc3d2d848a9e0c0646961ab4fa7904fafac2d5f (patch) | |
tree | 0134e3d52e6affcd51727422ceb872c53d2db1e2 /src/pcp_con | |
parent | e138a1876fec3aba6132531ede340ee98c5cc730 (diff) |
Prior to version 4.6, the online recovery database was hardcoded to "template1".
This commit introduces a new configuration parameter, "recovery_database",
which allows users to specify the database used for online recovery.
The default value is "postgres".
Diffstat (limited to 'src/pcp_con')
-rw-r--r-- | src/pcp_con/recovery.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/pcp_con/recovery.c b/src/pcp_con/recovery.c index 598c1a28d..cc4dd5e14 100644 --- a/src/pcp_con/recovery.c +++ b/src/pcp_con/recovery.c @@ -463,16 +463,25 @@ connect_backend_libpq(BackendInfo * backend) { char port_str[16]; PGconn *conn; + char *dbname; char *password = get_pgpool_config_user_password(pool_config->recovery_user, pool_config->recovery_password); snprintf(port_str, sizeof(port_str), "%d", backend->backend_port); + /* + * If database is not specified, "postgres" database is assumed. + */ + if (*pool_config->recovery_database == '\0') + dbname = "postgres"; + else + dbname = pool_config->recovery_database; + conn = PQsetdbLogin(backend->backend_hostname, port_str, NULL, NULL, - "template1", + pool_config->recovery_database, pool_config->recovery_user, password ? password : ""); |