pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
psql command line client behaviour
2+ messages / 2 participants
[nested] [flat]

* psql command line client behaviour
@ 2011-05-05 09:34 Jiri Sadek <jiri.sadek@gmail.com>
  2011-05-05 15:16 ` Re: psql command line client behaviour Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: Jiri Sadek @ 2011-05-05 09:34 UTC (permalink / raw)
  To: pgsql-bugs

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). This can have bad consequences (e.g. 
if first query is BEGIN;):

sample (postgresql 8.3.15):

(test@[local:/var/opt/testdb/pg_sockets]:20000) 10:55:34 [testdb]
#> select 10; select 20;
  ?column?
----------
        10
(1 row)

Time: 0.142 ms
  ?column?
----------
        20
(1 row)

Time: 0.039 ms
(test@[local:/var/opt/testdb/pg_sockets]:20000) 10:55:42 [testdb]
#> select 10; select 20;
FATAL:  terminating connection due to administrator command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Succeeded.
  ?column?
----------
        20
(1 row)

Time: 0.193 ms

I would suggest to not execute any query or all of them after reconnect.

Jiri



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: psql command line client behaviour
  2011-05-05 09:34 psql command line client behaviour Jiri Sadek <jiri.sadek@gmail.com>
@ 2011-05-05 15:16 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2011-05-05 15:16 UTC (permalink / raw)
  To: Jiri Sadek <jiri.sadek@gmail.com>; +Cc: pgsql-bugs

Jiri Sadek <jiri.sadek@gmail.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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2011-05-05 15:16 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-05-05 09:34 psql command line client behaviour Jiri Sadek <jiri.sadek@gmail.com>
2011-05-05 15:16 ` Tom Lane <tgl@sss.pgh.pa.us>

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