Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 2E21E930E1E for ; Fri, 3 Aug 2012 15:03:41 -0300 (ADT) Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SxMDn-0007iV-Fs for pgsql-bugs@postgresql.org; Fri, 03 Aug 2012 18:03:40 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1SxMDZ-0000lm-8M; Fri, 03 Aug 2012 14:03:21 -0400 Date: Fri, 3 Aug 2012 14:03:21 -0400 From: Bruce Momjian 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? Message-ID: <20120803180321.GE3463@momjian.us> References: <201107132053.p6DKrmmV052152@wwwmaster.postgresql.org> <4E1E5014.2080101@postnewspapers.com.au> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="JYK4vJDZwFMowpUq" Content-Disposition: inline In-Reply-To: <4E1E5014.2080101@postnewspapers.com.au> User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201208/13 X-Sequence-Number: 33737 --JYK4vJDZwFMowpUq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. + --JYK4vJDZwFMowpUq Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="psql.diff" diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml new file mode 100644 index b6bf6a3..1ba5ea8 *** a/doc/src/sgml/ref/psql-ref.sgml --- b/doc/src/sgml/ref/psql-ref.sgml *************** PostgreSQL documentation *** 99,105 **** BEGIN/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 ! psql's standard input. --- 99,106 ---- BEGIN/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 ! psql's standard input. Also, only ! the result of the last SQL command is returned. --JYK4vJDZwFMowpUq--