Received: from maia.hub.org (unknown [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 3FFCAB5DDF0 for ; Thu, 14 Jul 2011 12:38:28 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 31868-02 for ; Thu, 14 Jul 2011 15:36:16 +0000 (UTC) Received: from mx1.hub.org (mx1.hub.org [200.46.208.106]) by mail.postgresql.org (Postfix) with ESMTP id D9DDDB5DE5A for ; Thu, 14 Jul 2011 12:36:16 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mx1.hub.org (Postfix) with ESMTP id CAE4E27FDFDE for ; Thu, 14 Jul 2011 12:36:10 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p6EFYsYc029984; Thu, 14 Jul 2011 11:34:54 -0400 (EDT) To: Craig Ringer cc: Aleksey Tsalolikhin , pgsql-bugs@postgresql.org Subject: Re: BUG #6117: psql -c does not work as expected. a documentation bug? a program bug? In-reply-to: <4E1E5014.2080101@postnewspapers.com.au> References: <201107132053.p6DKrmmV052152@wwwmaster.postgresql.org> <4E1E5014.2080101@postnewspapers.com.au> Comments: In-reply-to Craig Ringer message dated "Thu, 14 Jul 2011 10:10:28 +0800" Date: Thu, 14 Jul 2011 11:34:54 -0400 Message-ID: <29983.1310657694@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201107/116 X-Sequence-Number: 30728 Craig Ringer writes: > What's happening is that all of them are processed, but only the output > for the last one is emitted. I agree that the documentation isn't clear > about that, and I'm not sure whether or not that was the intended result. > ... > Comments anybody? Just fix the docs, or is this a behaviour issue? This is a byproduct of the fact that psql shoves the -c string out to the backend as a single Query message, rather than splitting it at semicolons and sending each command individually, which is what would happen if you typed a multi-command line normally. That has a bunch of indirect semantic implications, like the commands all being done in one transaction and execution of the whole thing always being abandoned after the first error. We've talked many times about changing that, but always been too afraid of breaking user scripts that rely on the current behavior. We could possibly address Aleksey's complaint without changing the behavior otherwise, but I'm not sure it's worth the trouble. So I vote for document-and-move-on. regards, tom lane