Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fBC4t-0006m2-H5 for pgsql-bugs@arkaria.postgresql.org; Wed, 25 Apr 2018 04:30:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fBC4o-0003ug-47 for pgsql-bugs@arkaria.postgresql.org; Wed, 25 Apr 2018 04:30:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fBC4n-0003uX-UH for pgsql-bugs@lists.postgresql.org; Wed, 25 Apr 2018 04:30:41 +0000 Received: from sender-pp-092.zoho.com ([135.84.80.237]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fBC4j-0001IP-V7 for pgsql-bugs@lists.postgresql.org; Wed, 25 Apr 2018 04:30:41 +0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=date:from:to:cc:message-id:in-reply-to:references:subject:mime-version:content-type:user-agent; b=Gj1gkkf/bI2nkM+jkndsMo0OO/GapcvoOnHcbkCe2EwnroNxzyE1GG2KjPdaevmVVFg6MKi7EX9/ wOpGYY0aoXDpk03pPTYogeK7wMyDS5rovu7NnXWX7kl4iLHf9twO Received: from mail.zoho.com by mx.zohomail.com with SMTP id 1524630630875308.87083703298276; Tue, 24 Apr 2018 21:30:30 -0700 (PDT) Received: from [50.38.82.1] by mail.zoho.com with HTTP;Tue, 24 Apr 2018 21:30:30 -0700 (PDT) Date: Tue, 24 Apr 2018 21:30:30 -0700 From: jake To: "David G. Johnston" Cc: "pgsql-bugs@lists.postgresql.org" Message-Id: <162fb1131d6.12ac3be2b9673.5239359614834465495@zoho.com> In-Reply-To: <162facd1147.ba69cee29221.2693379920764956968@zoho.com> References: <152454331410.19803.86605614092680300@wrigleys.postgresql.org> <162f93f6c75.cdd696776295.5991878161692757736@zoho.com> <162fa45b1f0.e784e91e8344.4158165001514423492@zoho.com> <162facd1147.ba69cee29221.2693379920764956968@zoho.com> Subject: Re: BUG #15168: "pg_isready -d" effectively ignores given database name MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_24408_250200058.1524630630870" X-Priority: Medium User-Agent: Zoho Mail X-Mailer: Zoho Mail List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_24408_250200058.1524630630870 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit 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. ------=_Part_24408_250200058.1524630630870 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: 7bit
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.


------=_Part_24408_250200058.1524630630870--