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 1oZ5GJ-00018S-54 for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Sep 2022 06:55:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oZ5GH-0007J9-RZ for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Sep 2022 06:55:41 +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 1oZ5GH-0007Iz-Iv for pgsql-hackers@lists.postgresql.org; Fri, 16 Sep 2022 06:55:41 +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 1oZ5GE-0004YC-Jx for pgsql-hackers@lists.postgresql.org; Fri, 16 Sep 2022 06:55:41 +0000 Received: from oss.nttdata.com (localhost [127.0.0.1]) by oss.nttdata.com (Postfix) with ESMTPA id 8C6EE60605 for ; Fri, 16 Sep 2022 15:55: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: multipart/mixed; boundary="=_856c1916e74b5da2f72e00e8b6334b76" Content-Transfer-Encoding: 7bit Date: Fri, 16 Sep 2022 15:55:33 +0900 From: bt22nakamorit To: PostgreSQL Hackers Subject: Make ON_ERROR_STOP stop on shell script failure User-Agent: Roundcube Webmail/1.4.11 Message-ID: X-Sender: bt22nakamorit@oss.nttdata.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=_856c1916e74b5da2f72e00e8b6334b76 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed 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. 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? Tatsu --=_856c1916e74b5da2f72e00e8b6334b76 Content-Transfer-Encoding: base64 Content-Type: text/x-diff; name=stop_error.patch Content-Disposition: attachment; filename=stop_error.patch; size=363 ZGlmZiAtLWdpdCBhL3NyYy9iaW4vcHNxbC9jb21tYW5kLmMgYi9zcmMvYmluL3BzcWwvY29tbWFu ZC5jCmluZGV4IGExNDExNDZlNzAuLjc0NDVjYTA0ZmYgMTAwNjQ0Ci0tLSBhL3NyYy9iaW4vcHNx bC9jb21tYW5kLmMKKysrIGIvc3JjL2Jpbi9wc3FsL2NvbW1hbmQuYwpAQCAtNDk4OSw2ICs0OTg5 LDEwIEBAIGRvX3NoZWxsKGNvbnN0IGNoYXIgKmNvbW1hbmQpCiAJCXBnX2xvZ19lcnJvcigiXFwh OiBmYWlsZWQiKTsKIAkJcmV0dXJuIGZhbHNlOwogCX0KKwllbHNlIGlmIChyZXN1bHQgIT0gMCkg eworCQlwZ19sb2dfZXJyb3IoImNvbW1hbmQgZmFpbGVkIik7CisJCXJldHVybiBmYWxzZTsKKwl9 CiAJcmV0dXJuIHRydWU7CiB9CiAK --=_856c1916e74b5da2f72e00e8b6334b76--