From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | jake <jakelist(at)zoho(dot)com> |
Cc: | "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
Subject: | Re: BUG #15168: "pg_isready -d" effectively ignores given database name |
Date: | 2018-04-25 04:41:05 |
Message-ID: | CAKFQuwbuc2_cLvakSwOyqbnUx7uXKNpt392YU1fpToL=1DoPvw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Tuesday, April 24, 2018, jake <jakelist(at)zoho(dot)com> wrote:
> Well, after fleshing out your command, I got:
>
> psql -tc "select 1 from pg_catalog.pg_database where datname='snowdrift';"
> | grep -qw 1
>
> That looks more complicated than the StackOverflow solution:
>
> psql -lt | cut -f1 -d \| | grep -qw <db-name>
>
> Or at least it's longer. Hmm. I guess personal taste is a big factor here.
>
> Jake T.
>
>
>
If your psql connection is logging you onto the snowdrift database checking
for its existence explicitly seems pointless...otherwise, yes, using the -l
option (which connects you, generally, to the default postgres database) in
psql is going to be the better way to check for database presence since -l
basically invokes the pg_database query for you.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Kyotaro HORIGUCHI | 2018-04-25 08:31:39 | Re: set/reset issues in create function and set_config |
Previous Message | jake | 2018-04-25 04:30:30 | Re: BUG #15168: "pg_isready -d" effectively ignores given database name |