Hello,
> root@29243fe45836:/# pg_isready -d 123456 -h localhost -p 5432 -U postgres # the DB 123456 doesn't exist
> localhost:5432 - accepting connections # but it shows all is good
> root@29243fe45836:/# echo $?
> 0
I can confirm, but I'm afraid it is a feature.
The server *is* indeed accepting connections… it does not say that the
connection with the parameters you supplied worked.
The feature relies on "PQpingParams" function which states the following
somehow strange sentence:
"It is not necessary to supply correct user name, password, or database
name values to obtain the server status; however, if incorrect values are
provided, the server will log a failed connection attempt."
The same occurs with a non existing user (-U).
Basically a connection is merely attempted, but it does not report success
of said connection. The sentence of "pg_isready --help" is somehow
ambiguous:
"pg_isready issues a connection check to a PostgreSQL database.", but no
one specified whaa a "connection check" is. I can understand that you
would expect to be an actual connection:-)
ISTM that the doc should be clarified about what is a "connection check",
and that it is not working a connection.
If you want to check that your parameters are ok, probably you want to
issue an actual psql run, eg:
psql <my param> -c "SELECT 'ok'"
--
Fabien.