Skip site navigation (1) Skip section navigation (2)

Re: BUG #6117: psql -c does not work as expected. a documentation bug? a program bug?

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
Cc: Aleksey Tsalolikhin <atsaloli(dot)tech(at)gmail(dot)com>,pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6117: psql -c does not work as expected. a documentation bug? a program bug?
Date: 2012-08-03 18:03:21
Message-ID: 20120803180321.GE3463@momjian.us (view raw or flat)
Thread:
Lists: pgsql-bugs
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(dot)tech(at)gmail(dot)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(at)momjian(dot)us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +

Attachment: psql.diff
Description: text/x-diff (981 bytes)

In response to

pgsql-bugs by date

Next:From: Bruce MomjianDate: 2012-08-03 22:51:45
Subject: Re: BUG #6126: CC parameter in to_char() behaves incorrectly
Previous:From: Craig RingerDate: 2012-08-03 14:01:06
Subject: Re: BUG #7479: SERVICE NOT START

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group