pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephen Frost <sfrost@snowman.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Marko Tiikkaja <marko@joh.to>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #10794: psql sometimes ignores .psqlrc
Date: Tue, 15 Jul 2014 22:05:14 -0400
Message-ID: <20140716020514.GU16422@tamriel.snowman.net> (raw)
In-Reply-To: <7716.1405475499@sss.pgh.pa.us>
References: <20140628211359.15697.92594@wrigleys.postgresql.org>
	<53C5A4B1.8040107@joh.to>
	<7716.1405475499@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

* Tom Lane (tgl@sss.pgh.pa.us) wrote:
> Marko Tiikkaja <marko@joh.to> 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?

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 or 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

Attachments:

  signature.asc (application/pgp-signature, 818B) download

view thread (9+ messages)  latest in thread

Message-ID: <20140716020514.GU16422@tamriel.snowman.net>
Permalink:  ../20140716020514.GU16422@tamriel.snowman.net/
Also on:    postgresql.org/message-id/20140716020514.GU16422@tamriel.snowman.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: sfrost@snowman.net, tgl@sss.pgh.pa.us, marko@joh.to
  Subject: Re: BUG #10794: psql sometimes ignores .psqlrc
  In-Reply-To: <20140716020514.GU16422@tamriel.snowman.net>
  References: <20140628211359.15697.92594@wrigleys.postgresql.org> <53C5A4B1.8040107@joh.to> <7716.1405475499@sss.pgh.pa.us> <20140716020514.GU16422@tamriel.snowman.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox