* Chris Bitmead <chrisb@nimrod.itg.telstra.com.au> [000217 16:20] wrote:
> Peter Eisentraut wrote:
> >
> > Some people have indicated that they don't like how psql currently handles
> > Control-C if no query is in progress. I consider the behaviour of the
> > shells desirable but, quite frankly, I don't know how to do it.
>
> The typical way to do this sort of thing is to longjmp back to the main
> loop. And I think if you look at sig.c in bash, this is probably what
> they are doing.
>
> > Actually, shouldn't a Ctrl-C in a script cancel the query *and* stop the
> > script at all times?
>
> Yes.
Whoa whoa... It's a bit more complicated than you think, there's a lot
of state that gets put into libpq, i guess the simplest way would be
to do so and also cancel the transaction, but a simple longjump won't
work reliably and you'd also have to take very careful steps to make
sure you handle everything _just right_ from a signal context.
I'd rather have the inconvience of psql exiting than a not entirely
thought out mechanism for doing this properly potentially having psql
run amok on my database. :)
--
-Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org]