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 1jr2A4-0008Qn-3M for pgsql-general@arkaria.postgresql.org; Thu, 02 Jul 2020 16:34:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jr2A2-00070u-CS for pgsql-general@arkaria.postgresql.org; Thu, 02 Jul 2020 16:34:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jr27E-0001bT-Jt for pgsql-general@lists.postgresql.org; Thu, 02 Jul 2020 16:31:13 +0000 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jr27A-0008SL-Sl for pgsql-general@lists.postgresql.org; Thu, 02 Jul 2020 16:31:11 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id EDFB310B2; Thu, 2 Jul 2020 12:31:06 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 02 Jul 2020 12:31:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=L 6WZ935qvAaMtB14IQKA66mlVM3MQuRm5I1F6qLSUZI=; b=AeuiOeOuFjlKsKnvc 9/SnQU6toeDrzFSK07OVnhvJHoYjaSr7XMdRLIkVeyYUxiSoamuU5s6JHz2v98Yq VevZkX9aHmu4MdUe8cTYyE3STgjTB5Y5ioUuIogINcKuxQWig3yv7UeVZ0OyaTG8 4xKsV+1hG7Lr6iI7GF/7ijIbvsOwgor2wAVYKUu78Q9pqKsoDXC6Q4v5u8zcIIj/ NEezb49VPXfg1Hph4A9UhMvp9uq+4sh/dg3kGhPExypymGBBifGKPp5SXJj2R6fs ZHnbry3PtSGAUBFYRoWsP3ulQ3cTPzpdPScYLuS6GO1kBGFFdVZWZm8O0XpJQodm HTtnw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=L6WZ935qvAaMtB14IQKA66mlVM3MQuRm5I1F6qLSU ZI=; b=vQBEnt0V9wsRLDZlww08ayxu2+h7NOD5huD+ndnajNvyicPsj6FBBeIUh tlbIq2/Z5M40MtD4EnWsBgYBv8R+ntxoNnwERWFyLWAfkVQ9E9912hmmUNPYSQTp OXeQ4mpi1JQ4BGvLbSQkj3o2Eb6DyWpd14fIW9iU+B6HR7alAyDKUByxrIK5nMap 981qs92lN2XuuxAsxbx/xYeymsBddQfHld6qHmrhi9aA8h1RPVuJT+faLx5IyGWk eYNmii9C+tVBuaws68hJMNtDpgG3XESGIV6nTLjnxpyORBKhsgWGjzpF2yUKlnGY 7BNpO2yaQA+optxqcG5ReP+5jeIig== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrtdeggdeliecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhffkffgfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecuggftrfgrthhtvghrnhepuddufeejteevffehgfduhedthfdvteekieeuheefveev udetkeelueehgeduhefhnecuffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrghenuc fkphepjeehrddujedvrdehrddvfedunecuvehluhhsthgvrhfuihiivgeptdenucfrrghr rghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homh X-ME-Proxy: Received: from [192.168.1.3] (75-172-5-231.tukw.qwest.net [75.172.5.231]) by mail.messagingengine.com (Postfix) with ESMTPA id AC5F83280064; Thu, 2 Jul 2020 12:31:05 -0400 (EDT) Subject: Re: survey: psql syntax errors abort my transactions To: Jeremy Schneider , "pgsql-general@lists.postgresql.org" References: From: Adrian Klaver Message-ID: Date: Thu, 2 Jul 2020 09:31:04 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 7/2/20 8:54 AM, Jeremy Schneider wrote: > Maybe it's just me, but I'm wondering if it's worth changing the default > behavior of psql so it doesn't abort transactions in interactive mode > when I mistakenly mis-spell "select" or something silly like that.  This > is of course easily remedied in my psqlrc file by adding "\set > ON_ERROR_ROLLBACK interactive". I don't know whether there are > equivalent settings for pgAdmin and Toad and whatever other tools people > are using for their interactive SQL sessions. But I do know that for all > the new people coming to PostgreSQL right now (including lots at my > company), none of them are going to know about this setting and > personally I think the default is user-unfriendly. > > https://www.postgresql.org/docs/current/app-psql.html#id-1.9.4.18.8.5.2.9.17.1.2 > > A couple years back, some hackers discussed changing the default, and it > was decided against (IIUC) because of concerns about broken scripts > suddenly causing damage rather than aborting out. (About which... I > think if a script is sending broken SQL, then it might not be checking > error return values either and will likely keep running even after > PostgreSQL ignores a few SQL statements after the error in the current > session...) > > https://www.postgresql.org/message-id/flat/CABTbUpiAOKZ405uArt8cJFtC72RhzthmvWETQK_6Qw0Ad-HquQ%40mail.gmail.com > > This thread on hackers actually seemed kindof short to me. Not nearly > enough bike-shedding to call it a closed case. It also seems to me that > the community has made significant changes across new major versions in > the past, and this idea here might not be entirely off the table quite yet. > > So... > > Survey for the user community here on the pgsql-general list: it would > be great if lots of people could chime in by answering two questions > about your very own production environment: > > question 1) are you worried about scripts in your production environment > where damage could be caused by a different default in a future new > major version of postgresql?  (not aborting transactions in interactive > mode when syntax errors occur) > > question 2) do you think the increased user-friendliness of changing > this default behavior would be worthwhile for specific users in your > organization who use postgresql?  (including both yourself and others > you know of) I would say just add a message to the ERROR that points out ON_ERROR_ROLLBACK = 'on' is available. For instance: test(5432)=# begin ; BEGIN test(5432)=# select 1/0; ERROR: division by zero test(5432)=# select 1; ERROR: current transaction is aborted, commands ignored until end of transaction block New part of message HINT: \set ON_ERROR_ROLLBACK on to rollback on error. > > As someone working at a large company with an aweful lot of PostgreSQL, > thinking of the internal production systems I'm aware of, I'd personally > vote pretty strongly in favor of changing the default. > > -Jeremy > > > -- > Jeremy Schneider > Database Engineer > Amazon Web Services > -- Adrian Klaver adrian.klaver@aklaver.com