Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X7ENm-0002g8-Nz for pgsql-bugs@arkaria.postgresql.org; Wed, 16 Jul 2014 01:51:46 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1X7ENm-0007wh-1m for pgsql-bugs@arkaria.postgresql.org; Wed, 16 Jul 2014 01:51:46 +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 1X7ENl-0007wa-0O for pgsql-bugs@postgresql.org; Wed, 16 Jul 2014 01:51:45 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1X7ENh-0007Ss-UN for pgsql-bugs@postgresql.org; Wed, 16 Jul 2014 01:51:43 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s6G1pdri007717; Tue, 15 Jul 2014 21:51:39 -0400 From: Tom Lane To: Marko Tiikkaja cc: pgsql-bugs@postgresql.org Subject: Re: BUG #10794: psql sometimes ignores .psqlrc In-reply-to: <53C5A4B1.8040107@joh.to> References: <20140628211359.15697.92594@wrigleys.postgresql.org> <53C5A4B1.8040107@joh.to> Comments: In-reply-to Marko Tiikkaja message dated "Wed, 16 Jul 2014 00:01:21 +0200" Date: Tue, 15 Jul 2014 21:51:39 -0400 Message-ID: <7716.1405475499@sss.pgh.pa.us> 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 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. > (seeing that back branch releases are upcoming..) Ping? 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). 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? 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. 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. In any case, I'm disinclined to mess with this in the back branches ... regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs