Re: psql command line client behaviour

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jiri Sadek <jiri(dot)sadek(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: psql command line client behaviour
Date: 2011-05-05 15:16:23
Message-ID: 4016.1304608583@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Jiri Sadek <jiri(dot)sadek(at)gmail(dot)com> writes:
> I was told about behaviour of psql command line client that seems as bug
> to me. When I am connected to server (cmdline client, interactive mode)
> and server is restarted next query fails and client try to reconnect to
> server. Problem arise when I send more queries (not speaking that this
> may not be a good habit) at once - on first one client detects that
> connection is lost and try to reconnect and then rest of queries are
> executed (but not the first one).

The reason it does that is that ON_ERROR_STOP isn't set. If you don't
want execution of a multi-command string to continue after an error,
you should set that variable. It's not obvious to me that loss of
connection should be treated differently here from other reasons for a
command failure.

Example:

$ psql
psql (9.1beta1)
Type "help" for help.

regression=# select 1/0; select 2;
ERROR: division by zero
?column?
----------
2
(1 row)

regression=# \set ON_ERROR_STOP 1
regression=# select 1/0; select 2;
ERROR: division by zero
regression=#

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2011-05-05 15:28:31 Re: BUG #5718: Cannot start postgres (FATAL: invalid cache id: 19)
Previous Message gab 2011-05-05 15:04:41 BUG #6008: Can't contact Tom Lane :)