Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X7Eay-00035W-14 for pgsql-bugs@arkaria.postgresql.org; Wed, 16 Jul 2014 02:05:24 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1X7Eax-0000cy-Gd for pgsql-bugs@arkaria.postgresql.org; Wed, 16 Jul 2014 02:05:23 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1X7Eaw-0000bo-JV for pgsql-bugs@postgresql.org; Wed, 16 Jul 2014 02:05:22 +0000 Received: from tamriel.snowman.net ([2001:4830:167b::11]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X7Eap-0007fa-6c for pgsql-bugs@postgresql.org; Wed, 16 Jul 2014 02:05:20 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id AB3305F7C1; Tue, 15 Jul 2014 22:05:14 -0400 (EDT) Date: Tue, 15 Jul 2014 22:05:14 -0400 From: Stephen Frost To: Tom Lane Cc: Marko Tiikkaja , pgsql-bugs@postgresql.org Subject: Re: BUG #10794: psql sometimes ignores .psqlrc Message-ID: <20140716020514.GU16422@tamriel.snowman.net> References: <20140628211359.15697.92594@wrigleys.postgresql.org> <53C5A4B1.8040107@joh.to> <7716.1405475499@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="3wDDcJ525A5nbDoJ" Content-Disposition: inline In-Reply-To: <7716.1405475499@sss.pgh.pa.us> X-Editor: Vim http://www.vim.org/ X-Info: http://www.snowman.net X-Operating-System: Linux/3.11.0-19-generic (x86_64) X-Uptime: 21:57:14 up 98 days, 12:16, 8 users, load average: 0.01, 0.02, 0.05 User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --3wDDcJ525A5nbDoJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Tom Lane (tgl@sss.pgh.pa.us) wrote: > Marko Tiikkaja writes: > > On 6/28/14, 11:13 PM, marko@joh.to wrote: > >> If I press ctrl-C while psql is prompting for a password but then log = in > >> (either because I used -W and the server isn't expecting a password or= if I > >> subsequently typed in the correct password), .psqlrc isn't processed. = This > >> seems quite dangerous if the user is e.g. assuming a specific value for > >> AUTOCOMMIT. >=20 > > (seeing that back branch releases are upcoming..) Ping? >=20 > I can reproduce that in 9.3, but not in 9.4/HEAD: now, if you control-C at > the password prompt, the program just exits instantly. That's evidently a > result of commit 9099e4afe, which postponed the installation of the SIGINT > handler till after the password prompt. What is happening in the earlier > branches is that the SIGINT handler is setting cancel_pressed, which > doesn't affect collection of the password, but which the main loop then > takes as an indication that you wanted to abandon processing of the script > file (ie, .psqlrc). >=20 > There's a bit of a race condition here, in that if you press control-C > just *after* connection setup, it will still allow psql to start up after > having not processed the .psqlrc file. I think though that we'd be ill > advised to try to prevent that by postponing control-C setup even further; > what if the .psqlrc file is broken and initiates some long-running > operation? This I agree with. > So I'm satisfied with the behavior of HEAD in this area. There's a case > to be made for back-patching commit 9099e4afe into older branches, but > I'm not sure if that'd be a good idea or not. People might be depending > on the old behavior. I've not looked at this closely, but I have to say that I've always felt that ignoring ctrl-c at the password prompt is really bad form- it's confusing to those who don't understand what's going on and really annoying for those who do. While we're at it, we should fix the complaint about .psql_history being missing.. This isn't an error, imv: could not save history to file "/home/sfrost/.psql_history": No such file o= r directory Not sure where we started doing that. > A different line of thought would be to reset cancel_pressed before > starting the processing of any script file, so that you actually have to > press control-C *during* the processing of a file to cancel it. That's > just narrowing the race condition window some more, but it might be > worth doing. Narrowing the window would probably be good to do, but I don't see a need to back-patch that. > In any case, I'm disinclined to mess with this in the back branches ... If we have a simple/clean patch to fix the "Ctrl-C ignored at password prompt", such that, instead, psql exits more-or-less immediately then I'd be for back-patching just that as it certainly has always felt like a wart or even a bug to me, but I agree that we don't want to introduce other behavior changes beyond that in back-branches. Thanks, Stephen --3wDDcJ525A5nbDoJ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJTxd3aAAoJEO1sijiDR2RVHPMP/RB5P/fMMYF3Jbw9+VSlKVum DW6HusQ8FITvJab/pYu4ehH9YdGY4+1ohartXHVK4saln8s0hW3oicdeSNZNByLf U+bqDvLoBtg8s2rX0f8Vh3OOEDw+FxWJVP8+mT/34WD/TwCdMORR2NulXVPxHIG5 3UJr8fMU/L9J/pJTopCHA4XLes9GGr/iNbphDgzP9WcN4dycJEDN0wXZG1NqECm4 qf/QRmTZxXNskTL2vyOlHDXhu/bkgR+rZI5S0e5l4zq+p4NhvnSufwh0cjaJyR7H Nmz6nvxGmMK2ljOaIhs5lgyx4qLfyaDgjFKiRgOwWAt/TI+650WfbgyRWyio79yy hjQDMtYkkpUN6vauFYc024SysEEGAKMM3VDprMiJDC3ocqn3bmO1NJzIN76j1xW7 P9BwrqQhWtcW/u+PbQCU80TXX5XqBT3H0oQlWrtkESeW+vVpPSP28o1DkZCzzBzv LY1/9nom8Rn0YUPELFTvLez//fi96NmH8mK36xPe0hSEMD8R0Q5AV4/colJ1Xkav 14fx95DN29TKG9G5kAWNPifFBfsOQnlfEsvKDYJVblruvsjyRpr5vI4yOONsj3Rq aDv19lLFoAaSPwJXF1DweX7KF0rhOjTf6d63mUi6u+Vi30+HYDCo0nrbFvcfEall lffAyhK1Rtv0SUzpwaD+ =3OnY -----END PGP SIGNATURE----- --3wDDcJ525A5nbDoJ--