Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oZLwq-00020V-Kf for pgsql-hackers@arkaria.postgresql.org; Sat, 17 Sep 2022 00:44:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oZLwp-000390-BP for pgsql-hackers@arkaria.postgresql.org; Sat, 17 Sep 2022 00:44:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oZLwp-00038r-2C for pgsql-hackers@lists.postgresql.org; Sat, 17 Sep 2022 00:44:43 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oZLwm-0007Vo-36 for pgsql-hackers@lists.postgresql.org; Sat, 17 Sep 2022 00:44:42 +0000 Received: from oss.nttdata.com (localhost [127.0.0.1]) by oss.nttdata.com (Postfix) with ESMTPA id CE83260A15; Sat, 17 Sep 2022 09:44:33 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.7 at oss.nttdata.com MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Sat, 17 Sep 2022 09:44:33 +0900 From: bt22nakamorit To: Kyotaro Horiguchi Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Make ON_ERROR_STOP stop on shell script failure In-Reply-To: <20220916.173035.322733707258561235.horikyota.ntt@gmail.com> References: <20220916.173035.322733707258561235.horikyota.ntt@gmail.com> User-Agent: Roundcube Webmail/1.4.11 Message-ID: <4c61d434cb72b2237b3279797b2a387f@oss.nttdata.com> X-Sender: bt22nakamorit@oss.nttdata.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 2022-09-16 17:30 に Kyotaro Horiguchi さんは書きました: > At Fri, 16 Sep 2022 15:55:33 +0900, bt22nakamorit > wrote in >> Hi, >> >> """\set ON_ERROR_STOP on""" stops any subsequent incoming query that >> comes after an error of an SQL, but does not stop after a shell script >> ran by """\! """ returning values other than 0, -1, or >> 127, which suggests a failure in the result of the shell script. >> >> For example, suppose that below is an SQL file. >> \set ON_ERROR_STOP on >> SELECT 1; >> \! false >> SELECT 2; >> >> The current design allows SELECT 2 even though the shell script >> returns a value indicating a failure. > > Since the "false" command did not "error out"? > >> I thought that this action is rather unexpected since, based on the >> word """ON_ERROR_STOP""", ones may expect that failures of shell >> scripts should halt the incoming instructions as well. >> One clear solution is to let failures of shell script stop incoming >> queries just like how errors of SQLs do currently. Thoughts? > > I'm not sure we want to regard any exit status from a succssful run as > a failure. > > On the other hand, the proposed behavior seems useful to me. > > So +1 from me to the proposal, assuming the corresponding edit of the > documentation happens. > > regards. > Since the "false" command did not "error out"? "false" command returns 1 which is an exit status code that indicates failure, but not error. I think it does not "error out" if that is what you mean. > So +1 from me to the proposal, assuming the corresponding edit of the > documentation happens. I will work on editing the document and share further updates. Thank you! Tatsu