Re: Determine if a user and database are available

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: noloader(at)gmail(dot)com
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Determine if a user and database are available
Date: 2022-09-02 22:21:03
Message-ID: 1229132.1662157263@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jeffrey Walton <noloader(at)gmail(dot)com> writes:
> I have another beginner question. I am trying to use pg_isready to
> determine if a database and user are present. The program seems to
> always succeed, even when I delete the user or the database.

That's a feature actually. The intended use of pg_isready is to
find out if the server is alive, not whether any particular user
or database name is correct. So it treats responses like "no such
database" as sufficient proof that the server is alive.

As David says, you could try to log in with any other client
software, or connect using known-good parameters and check
the system catalogs.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ron 2022-09-03 00:33:26 Re: Determine if a user and database are available
Previous Message David G. Johnston 2022-09-02 22:00:04 Re: Determine if a user and database are available