Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WDbvs-0002rF-F0 for pgsql-bugs@arkaria.postgresql.org; Wed, 12 Feb 2014 15:41:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WDbvr-0005GI-B2 for pgsql-bugs@arkaria.postgresql.org; Wed, 12 Feb 2014 15:41:03 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WDbvq-0005GC-IZ for pgsql-bugs@postgresql.org; Wed, 12 Feb 2014 15:41:02 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WDbvj-0007hs-KU for pgsql-bugs@postgresql.org; Wed, 12 Feb 2014 15:41:02 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s1CFeqVg025095; Wed, 12 Feb 2014 10:40:52 -0500 From: Tom Lane To: christoph.berg@credativ.de cc: pgsql-bugs@postgresql.org Subject: Re: BUG #9198: psql -c 'SET; ...' not working In-reply-to: <20140212125626.2710.94912@wrigleys.postgresql.org> References: <20140212125626.2710.94912@wrigleys.postgresql.org> Comments: In-reply-to christoph.berg@credativ.de message dated "Wed, 12 Feb 2014 12:56:26 +0000" Date: Wed, 12 Feb 2014 10:40:52 -0500 Message-ID: <25094.1392219652@sss.pgh.pa.us> X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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