Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 064E8B5DC49 for ; Wed, 13 Jul 2011 17:53:50 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 84282-04 for ; Wed, 13 Jul 2011 20:53:49 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by mail.postgresql.org (Postfix) with ESMTP id 73865B5DC45 for ; Wed, 13 Jul 2011 17:53:49 -0300 (ADT) Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by wwwmaster.postgresql.org (8.14.3/8.14.3) with ESMTP id p6DKrnbg052153 for ; Wed, 13 Jul 2011 20:53:49 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id p6DKrmmV052152; Wed, 13 Jul 2011 20:53:48 GMT (envelope-from www) Date: Wed, 13 Jul 2011 20:53:48 GMT Message-Id: <201107132053.p6DKrmmV052152@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #6117: psql -c does not work as expected. a documentation bug? a program bug? From: "Aleksey Tsalolikhin" Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 201107/112 X-Sequence-Number: 30724 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. For example: # psql -U postgres -c "select now(); select now(); select version();" version ---------------------------------------------------------------------------- -------------------------------------- PostgreSQL 8.4.8 on x86_64-redhat-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48), 64-bit (1 row) # Yet this works fine: # echo "select now(); select now(); select version();"|psql -f- -U postgres now ------------------------------- 2011-07-13 13:51:01.594725-07 (1 row) now ------------------------------- 2011-07-13 13:51:01.597903-07 (1 row) version ---------------------------------------------------------------------------- -------------------------------------- PostgreSQL 8.4.8 on x86_64-redhat-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48), 64-bit (1 row) # This is what I expect to see. Could you please fix psql or make the documentation for the -c option more clear? Thanks very much and thanks for a great product! Yours truly, Aleksey