From 5f8c8ba57cf5918955e8ce0be735d00a60769c57 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 21 Feb 2026 10:20:08 +0000 Subject: [PATCH 1/4] Initial plan From 5619fc4d60446b24f7a9c53fe24d1d5e42ef9464 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 21 Feb 2026 10:31:01 +0000 Subject: [PATCH 2/4] Align postgresDefault() and dbConnect() docs with libpq defaults Update documentation to accurately reflect libpq's full default chain: - dbname: mention PGDATABASE env var, then fallback to user name - user: add OS username fallback when PGUSER is not set - host,port: add libpq defaults (Unix socket, port 5432) when env vars unset - service: add PGSERVICE env var mention - postgresHasDefault(): clarify not all env vars are required Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com> --- R/dbConnect_PqDriver.R | 18 ++++++++++++------ R/default.R | 8 +++++--- man/Postgres.Rd | 18 ++++++++++++------ man/Redshift.Rd | 18 ++++++++++++------ 4 files changed, 41 insertions(+), 21 deletions(-) diff --git a/R/dbConnect_PqDriver.R b/R/dbConnect_PqDriver.R index b06b8c9c1..a1cc583b3 100644 --- a/R/dbConnect_PqDriver.R +++ b/R/dbConnect_PqDriver.R @@ -18,21 +18,27 @@ #' PostgreSQL(-ish) database or [Redshift()] to connect to an AWS Redshift #' cluster. Use an existing [DBI::DBIConnection-class] object to clone an #' existing connection. -#' @param dbname Database name. If `NULL`, defaults to the user name. +#' @param dbname Database name. If `NULL`, will be +#' retrieved from the `PGDATABASE` env var, or defaults to the user name. #' Note that this argument can only contain the database name, it will not #' be parsed as a connection string (internally, `expand_dbname` is set to #' `false` in the call to #' [`PQconnectdbParams()`](https://www.postgresql.org/docs/current/libpq-connect.html)). #' @param user,password User name and password. If `NULL`, will be #' retrieved from `PGUSER` and `PGPASSWORD` envvars, or from the -#' appropriate line in `~/.pgpass`. See -#' for +#' appropriate line in `~/.pgpass`. If `PGUSER` is not set, +#' defaults to the operating system user name. +#' See for #' more details. #' @param host,port Host and port. If `NULL`, will be retrieved from -#' `PGHOST` and `PGPORT` env vars. +#' `PGHOST` and `PGPORT` env vars. If those are not set either, +#' defaults to a local Unix-domain socket connection and port `5432`, +#' as documented in +#' [libpq connection parameter docs](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS). #' @param service Name of service to connect as. If `NULL`, will be -#' ignored. Otherwise, connection parameters will be loaded from the pg_service.conf -#' file and used. See +#' retrieved from `PGSERVICE` env var. If defined, connection parameters +#' will be loaded from the pg_service.conf file and used. See +#' #' for details on this file and syntax. #' @param ... Other name-value pairs that describe additional connection #' options as described at diff --git a/R/default.R b/R/default.R index a89ac3623..ffd652565 100644 --- a/R/default.R +++ b/R/default.R @@ -24,9 +24,11 @@ postgresHasDefault <- function(...) { error = function(...) { message( "Could not initialise default postgres database. If postgres is running\n", - "check that the environment variables PGHOST, PGPORT, \n", - "PGUSER, PGPASSWORD, and PGDATABASE, are defined and\n", - "point to your database." + "check that the connection works with default libpq settings.\n", + "The default connection uses the PGHOST, PGPORT, PGUSER, PGPASSWORD,\n", + "and PGDATABASE environment variables. If unset, libpq defaults are\n", + "used (local socket, port 5432, OS user name).\n", + "See https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS" ) FALSE } diff --git a/man/Postgres.Rd b/man/Postgres.Rd index 76d1d75e7..c949bb4cf 100644 --- a/man/Postgres.Rd +++ b/man/Postgres.Rd @@ -34,24 +34,30 @@ PostgreSQL(-ish) database or \code{\link[=Redshift]{Redshift()}} to connect to a cluster. Use an existing \link[DBI:DBIConnection-class]{DBI::DBIConnection} object to clone an existing connection.} -\item{dbname}{Database name. If \code{NULL}, defaults to the user name. +\item{dbname}{Database name. If \code{NULL}, will be +retrieved from the \code{PGDATABASE} env var, or defaults to the user name. Note that this argument can only contain the database name, it will not be parsed as a connection string (internally, \code{expand_dbname} is set to \code{false} in the call to \href{https://www.postgresql.org/docs/current/libpq-connect.html}{\code{PQconnectdbParams()}}).} \item{host, port}{Host and port. If \code{NULL}, will be retrieved from -\code{PGHOST} and \code{PGPORT} env vars.} +\code{PGHOST} and \code{PGPORT} env vars. If those are not set either, +defaults to a local Unix-domain socket connection and port \code{5432}, +as documented in +\href{https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS}{libpq connection parameter docs}.} \item{user, password}{User name and password. If \code{NULL}, will be retrieved from \code{PGUSER} and \code{PGPASSWORD} envvars, or from the -appropriate line in \verb{~/.pgpass}. See -\url{https://www.postgresql.org/docs/current/libpq-pgpass.html} for +appropriate line in \verb{~/.pgpass}. If \code{PGUSER} is not set, +defaults to the operating system user name. +See \url{https://www.postgresql.org/docs/current/libpq-pgpass.html} for more details.} \item{service}{Name of service to connect as. If \code{NULL}, will be -ignored. Otherwise, connection parameters will be loaded from the pg_service.conf -file and used. See \url{https://www.postgresql.org/docs/current/libpq-pgservice.html} +retrieved from \code{PGSERVICE} env var. If defined, connection parameters +will be loaded from the pg_service.conf file and used. See +\url{https://www.postgresql.org/docs/current/libpq-pgservice.html} for details on this file and syntax.} \item{...}{Other name-value pairs that describe additional connection diff --git a/man/Redshift.Rd b/man/Redshift.Rd index cb1ea4a0b..b4fb439b1 100644 --- a/man/Redshift.Rd +++ b/man/Redshift.Rd @@ -31,24 +31,30 @@ PostgreSQL(-ish) database or \code{\link[=Redshift]{Redshift()}} to connect to a cluster. Use an existing \link[DBI:DBIConnection-class]{DBI::DBIConnection} object to clone an existing connection.} -\item{dbname}{Database name. If \code{NULL}, defaults to the user name. +\item{dbname}{Database name. If \code{NULL}, will be +retrieved from the \code{PGDATABASE} env var, or defaults to the user name. Note that this argument can only contain the database name, it will not be parsed as a connection string (internally, \code{expand_dbname} is set to \code{false} in the call to \href{https://www.postgresql.org/docs/current/libpq-connect.html}{\code{PQconnectdbParams()}}).} \item{host, port}{Host and port. If \code{NULL}, will be retrieved from -\code{PGHOST} and \code{PGPORT} env vars.} +\code{PGHOST} and \code{PGPORT} env vars. If those are not set either, +defaults to a local Unix-domain socket connection and port \code{5432}, +as documented in +\href{https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS}{libpq connection parameter docs}.} \item{user, password}{User name and password. If \code{NULL}, will be retrieved from \code{PGUSER} and \code{PGPASSWORD} envvars, or from the -appropriate line in \verb{~/.pgpass}. See -\url{https://www.postgresql.org/docs/current/libpq-pgpass.html} for +appropriate line in \verb{~/.pgpass}. If \code{PGUSER} is not set, +defaults to the operating system user name. +See \url{https://www.postgresql.org/docs/current/libpq-pgpass.html} for more details.} \item{service}{Name of service to connect as. If \code{NULL}, will be -ignored. Otherwise, connection parameters will be loaded from the pg_service.conf -file and used. See \url{https://www.postgresql.org/docs/current/libpq-pgservice.html} +retrieved from \code{PGSERVICE} env var. If defined, connection parameters +will be loaded from the pg_service.conf file and used. See +\url{https://www.postgresql.org/docs/current/libpq-pgservice.html} for details on this file and syntax.} \item{...}{Other name-value pairs that describe additional connection From e37adb23314438c9b1eb9509ac37280c3a5e2c2d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 21 Feb 2026 10:31:30 +0000 Subject: [PATCH 3/4] Use platform-neutral 'local connection' in postgresHasDefault() message Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com> --- R/default.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/default.R b/R/default.R index ffd652565..c6f3bbf7a 100644 --- a/R/default.R +++ b/R/default.R @@ -27,7 +27,7 @@ postgresHasDefault <- function(...) { "check that the connection works with default libpq settings.\n", "The default connection uses the PGHOST, PGPORT, PGUSER, PGPASSWORD,\n", "and PGDATABASE environment variables. If unset, libpq defaults are\n", - "used (local socket, port 5432, OS user name).\n", + "used (local connection, port 5432, OS user name).\n", "See https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS" ) FALSE From 7b95542f09488d1f8ed03b9eeae0bc0cf655c29d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 21 Feb 2026 12:50:37 +0000 Subject: [PATCH 4/4] Revert dbConnect docs per review: only change postgresHasDefault() message Per reviewer feedback, dbConnect should remain fully deterministic. Only the postgresHasDefault() error message in default.R is updated to clarify libpq defaults. All changes to dbConnect_PqDriver.R and generated man pages are reverted. Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com> --- R/dbConnect_PqDriver.R | 18 ++++++------------ man/Postgres.Rd | 18 ++++++------------ man/Redshift.Rd | 18 ++++++------------ 3 files changed, 18 insertions(+), 36 deletions(-) diff --git a/R/dbConnect_PqDriver.R b/R/dbConnect_PqDriver.R index a1cc583b3..b06b8c9c1 100644 --- a/R/dbConnect_PqDriver.R +++ b/R/dbConnect_PqDriver.R @@ -18,27 +18,21 @@ #' PostgreSQL(-ish) database or [Redshift()] to connect to an AWS Redshift #' cluster. Use an existing [DBI::DBIConnection-class] object to clone an #' existing connection. -#' @param dbname Database name. If `NULL`, will be -#' retrieved from the `PGDATABASE` env var, or defaults to the user name. +#' @param dbname Database name. If `NULL`, defaults to the user name. #' Note that this argument can only contain the database name, it will not #' be parsed as a connection string (internally, `expand_dbname` is set to #' `false` in the call to #' [`PQconnectdbParams()`](https://www.postgresql.org/docs/current/libpq-connect.html)). #' @param user,password User name and password. If `NULL`, will be #' retrieved from `PGUSER` and `PGPASSWORD` envvars, or from the -#' appropriate line in `~/.pgpass`. If `PGUSER` is not set, -#' defaults to the operating system user name. -#' See for +#' appropriate line in `~/.pgpass`. See +#' for #' more details. #' @param host,port Host and port. If `NULL`, will be retrieved from -#' `PGHOST` and `PGPORT` env vars. If those are not set either, -#' defaults to a local Unix-domain socket connection and port `5432`, -#' as documented in -#' [libpq connection parameter docs](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS). +#' `PGHOST` and `PGPORT` env vars. #' @param service Name of service to connect as. If `NULL`, will be -#' retrieved from `PGSERVICE` env var. If defined, connection parameters -#' will be loaded from the pg_service.conf file and used. See -#' +#' ignored. Otherwise, connection parameters will be loaded from the pg_service.conf +#' file and used. See #' for details on this file and syntax. #' @param ... Other name-value pairs that describe additional connection #' options as described at diff --git a/man/Postgres.Rd b/man/Postgres.Rd index c949bb4cf..76d1d75e7 100644 --- a/man/Postgres.Rd +++ b/man/Postgres.Rd @@ -34,30 +34,24 @@ PostgreSQL(-ish) database or \code{\link[=Redshift]{Redshift()}} to connect to a cluster. Use an existing \link[DBI:DBIConnection-class]{DBI::DBIConnection} object to clone an existing connection.} -\item{dbname}{Database name. If \code{NULL}, will be -retrieved from the \code{PGDATABASE} env var, or defaults to the user name. +\item{dbname}{Database name. If \code{NULL}, defaults to the user name. Note that this argument can only contain the database name, it will not be parsed as a connection string (internally, \code{expand_dbname} is set to \code{false} in the call to \href{https://www.postgresql.org/docs/current/libpq-connect.html}{\code{PQconnectdbParams()}}).} \item{host, port}{Host and port. If \code{NULL}, will be retrieved from -\code{PGHOST} and \code{PGPORT} env vars. If those are not set either, -defaults to a local Unix-domain socket connection and port \code{5432}, -as documented in -\href{https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS}{libpq connection parameter docs}.} +\code{PGHOST} and \code{PGPORT} env vars.} \item{user, password}{User name and password. If \code{NULL}, will be retrieved from \code{PGUSER} and \code{PGPASSWORD} envvars, or from the -appropriate line in \verb{~/.pgpass}. If \code{PGUSER} is not set, -defaults to the operating system user name. -See \url{https://www.postgresql.org/docs/current/libpq-pgpass.html} for +appropriate line in \verb{~/.pgpass}. See +\url{https://www.postgresql.org/docs/current/libpq-pgpass.html} for more details.} \item{service}{Name of service to connect as. If \code{NULL}, will be -retrieved from \code{PGSERVICE} env var. If defined, connection parameters -will be loaded from the pg_service.conf file and used. See -\url{https://www.postgresql.org/docs/current/libpq-pgservice.html} +ignored. Otherwise, connection parameters will be loaded from the pg_service.conf +file and used. See \url{https://www.postgresql.org/docs/current/libpq-pgservice.html} for details on this file and syntax.} \item{...}{Other name-value pairs that describe additional connection diff --git a/man/Redshift.Rd b/man/Redshift.Rd index b4fb439b1..cb1ea4a0b 100644 --- a/man/Redshift.Rd +++ b/man/Redshift.Rd @@ -31,30 +31,24 @@ PostgreSQL(-ish) database or \code{\link[=Redshift]{Redshift()}} to connect to a cluster. Use an existing \link[DBI:DBIConnection-class]{DBI::DBIConnection} object to clone an existing connection.} -\item{dbname}{Database name. If \code{NULL}, will be -retrieved from the \code{PGDATABASE} env var, or defaults to the user name. +\item{dbname}{Database name. If \code{NULL}, defaults to the user name. Note that this argument can only contain the database name, it will not be parsed as a connection string (internally, \code{expand_dbname} is set to \code{false} in the call to \href{https://www.postgresql.org/docs/current/libpq-connect.html}{\code{PQconnectdbParams()}}).} \item{host, port}{Host and port. If \code{NULL}, will be retrieved from -\code{PGHOST} and \code{PGPORT} env vars. If those are not set either, -defaults to a local Unix-domain socket connection and port \code{5432}, -as documented in -\href{https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS}{libpq connection parameter docs}.} +\code{PGHOST} and \code{PGPORT} env vars.} \item{user, password}{User name and password. If \code{NULL}, will be retrieved from \code{PGUSER} and \code{PGPASSWORD} envvars, or from the -appropriate line in \verb{~/.pgpass}. If \code{PGUSER} is not set, -defaults to the operating system user name. -See \url{https://www.postgresql.org/docs/current/libpq-pgpass.html} for +appropriate line in \verb{~/.pgpass}. See +\url{https://www.postgresql.org/docs/current/libpq-pgpass.html} for more details.} \item{service}{Name of service to connect as. If \code{NULL}, will be -retrieved from \code{PGSERVICE} env var. If defined, connection parameters -will be loaded from the pg_service.conf file and used. See -\url{https://www.postgresql.org/docs/current/libpq-pgservice.html} +ignored. Otherwise, connection parameters will be loaded from the pg_service.conf +file and used. See \url{https://www.postgresql.org/docs/current/libpq-pgservice.html} for details on this file and syntax.} \item{...}{Other name-value pairs that describe additional connection