I would suggest that the struct gets the value (from option, environment or
default) and is always used elsewhere. The getPgPassFilename function
should disappear and PasswordFromFile should be simplified significantly.
I agree, however that's easier said than done because the "default" is only
constant by its definition, not by its location.
There is no "default" location as the home directory depends not only on the
system but also on the user. Afaics we can't entirely get rid of a function
to get the location of the default .pgpass file.
Hmmm... I thought to put the default if not set from the connection option
or the environment variable, say in connectOptions2(), just before getting
the password if it is needed? That is ensure that the pgpassfile field is
not NULL before calling PasswordFromFile, so that PasswordFromFile does
not have to do anything and then the error message can rely on the
Sent via pgsql-hackers mailing list (email@example.com)
To make changes to your subscription: