pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: christoph.berg@credativ.de
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #9198: psql -c 'SET; ...' not working
Date: Wed, 12 Feb 2014 10:40:52 -0500
Message-ID: <25094.1392219652@sss.pgh.pa.us> (raw)
In-Reply-To: <20140212125626.2710.94912@wrigleys.postgresql.org>
References: <20140212125626.2710.94912@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

christoph.berg@credativ.de writes:
> This seems to be a bug:

> time psql -c "SET statement_timeout = '3s'; SELECT pg_sleep(2)"
> ERROR:  canceling statement due to statement timeout
> real    0m1.065s

The reason this isn't a bug is that a -c command string is sent to the
server as a single statement (PQexec call), and what "statement timeout"
controls is the total time for the whole thing.  The SET operation can't
change the already-running timer for the current statement.  It would
affect the timeout for the next statement ... but there won't be one.

Many people have complained that it's unintuitive that -c works this way
rather than breaking up the string into multiple submissions the same way
psql would do with normal input.  We're afraid to change it for fear of
breaking applications, though.  If you want behavior more like psql's
normal operation, consider

echo "SET statement_timeout = '3s'; SELECT pg_sleep(2)" | psql

			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



view thread (9+ messages)  latest in thread

Message-ID: <25094.1392219652@sss.pgh.pa.us>
Permalink:  ../25094.1392219652@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/25094.1392219652@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, christoph.berg@credativ.de
  Subject: Re: BUG #9198: psql -c 'SET; ...' not working
  In-Reply-To: <25094.1392219652@sss.pgh.pa.us>
  References: <20140212125626.2710.94912@wrigleys.postgresql.org> <25094.1392219652@sss.pgh.pa.us>

* 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