Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gZNAO-0002mN-3O for pgsql-general@arkaria.postgresql.org; Tue, 18 Dec 2018 21:44:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gZNAM-0003YV-H4 for pgsql-general@arkaria.postgresql.org; Tue, 18 Dec 2018 21:44:38 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1gZNAM-0003YJ-9K for pgsql-general@lists.postgresql.org; Tue, 18 Dec 2018 21:44:38 +0000 Received: from mta1.recol.net ([64.207.103.6]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gZNAJ-0006DC-Ef for pgsql-general@lists.postgresql.org; Tue, 18 Dec 2018 21:44:37 +0000 Received: from wrkhors.com (unknown [75.37.52.9]) by mta1.recol.net (Postfix) with ESMTPSA id A314D398A38; Tue, 18 Dec 2018 16:44:31 -0500 (EST) Date: Tue, 18 Dec 2018 15:42:14 -0600 From: Steven Lembark To: pgsql-general@lists.postgresql.org Cc: lembark@wrkhors.com Subject: Re: conditionally terminate psql script Message-ID: <20181218154214.06bd0904.lembark@wrkhors.com> In-Reply-To: References: Organization: Workhorse Computing X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, 17 Dec 2018 13:42:14 +0100 Pavel Stehule wrote: > you need psql from PostgreSQL 10 and higher > > there is a \if statement Q: What is the "abort cycle command"? e.g., select count(1) < 1 as "lacks_rows"; from foobar where blah blah \gset \if :lacks_rows \echo foobar lacks rows to process. \echo goodnight :-) ????????? <--- what goes here to stop execution? \endif The point is that adding many levels of if-block logic is becomes difficult to maintain. It would be nice to stop execution without having to nest everything one level deeper. -- Steven Lembark 3920 10th Ave South Workhorse Computing Birmingham, AL 35222 lembark@wrkhors.com +1 888 359 3508