From: Bruce Momjian <bruce@momjian.us>
To: Craig Ringer <craig@postnewspapers.com.au>
Cc: Aleksey Tsalolikhin <atsaloli.tech@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6117: psql -c does not work as expected. a documentation bug? a program bug?
Date: Fri, 3 Aug 2012 14:03:21 -0400
Message-ID: <20120803180321.GE3463@momjian.us> (raw)
In-Reply-To: <4E1E5014.2080101@postnewspapers.com.au>
References: <201107132053.p6DKrmmV052152@wwwmaster.postgresql.org>
<4E1E5014.2080101@postnewspapers.com.au>
On Thu, Jul 14, 2011 at 10:10:28AM +0800, Craig Ringer wrote:
> On 14/07/2011 4:53 AM, Aleksey Tsalolikhin wrote:
> >The following bug has been logged online:
> >
> >Bug reference: 6117
> >Logged by: Aleksey Tsalolikhin
> >Email address: atsaloli.tech@gmail.com
> >PostgreSQL version: 8.4.8
> >Operating system: CentOS 5.5 (64-bit)
> >Description: psql -c does not work as expected. a documentation bug?
> > a program bug?
> >Details:
> >
> >The psql man page says, in the section for the -c option:
> >
> > If the command string contains multiple SQL
> > commands, they are processed in a single
> > transaction
> >
> >However when I run a command string with multiple
> >SQL commands, apparently only the last one is
> >processed.
> >
> 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.
>
> psql -c "CREATE TABLE test(x integer); INSERT INTO test(x) VALUES
> (1),(2),(3); SELECT version(); SELECT * FROM test;"
> x
> ---
> 1
> 2
> 3
> (3 rows)
>
>
> Comments anybody? Just fix the docs, or is this a behaviour issue?
I have added documentation for this behavior. Patch attached, and
backpatched to 9.2 and 9.1.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
Attachments:psql.diff (text/x-diff, 980B) downloaddiff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgmlnew file mode 100644index b6bf6a3..1ba5ea8
*** a/doc/src/sgml/ref/psql-ref.sgml
--- b/doc/src/sgml/ref/psql-ref.sgml
*************** PostgreSQL documentation
*** 99,105 ****
<command>BEGIN</>/<command>COMMIT</> commands included in the
string to divide it into multiple transactions. This is
different from the behavior when the same string is fed to
! <application>psql</application>'s standard input.
</para>
</listitem>
</varlistentry>
--- 99,106 ----
<command>BEGIN</>/<command>COMMIT</> commands included in the
string to divide it into multiple transactions. This is
different from the behavior when the same string is fed to
! <application>psql</application>'s standard input. Also, only
! the result of the last SQL command is returned.
</para>
</listitem>
</varlistentry>
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: bruce@momjian.us, craig@postnewspapers.com.au, atsaloli.tech@gmail.com
Subject: Re: BUG #6117: psql -c does not work as expected. a documentation bug? a program bug?
In-Reply-To: <20120803180321.GE3463@momjian.us>
References: <201107132053.p6DKrmmV052152@wwwmaster.postgresql.org> <4E1E5014.2080101@postnewspapers.com.au> <20120803180321.GE3463@momjian.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