agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Michael Moore <michaeljmoore@gmail.com>
To: postgres list <pgsql-sql@postgresql.org>
Subject: Re: How to get pgsql to echo commands in a command file
Date: Fri, 22 Apr 2016 15:58:35 -0700
Message-ID: <4b482dc1-d2ac-e61a-5401-74820591fb09@aklaver.com> (raw)
In-Reply-To: <CACpWLjPKcSmLXPi8xr5_8kJZirRf9WMx0ea7SnBCZb1DbzZHeg@mail.gmail.com>
References: <CACpWLjPKcSmLXPi8xr5_8kJZirRf9WMx0ea7SnBCZb1DbzZHeg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

On 04/22/2016 03:50 PM, Michael Moore wrote:
> I log into pgsql and then type:
> \i test.sql
>
> test.sql contains a single SELECT command and when I run that file I see
> the result of the select command.. The problem is, I also want to see
> the SELECT command itself.
>
> I've tried
> /echo
> /qecho
> and a lot of other commands, but nothing works.

http://www.postgresql.org/docs/9.5/interactive/app-psql.html
"
ECHO

     If set to all, all nonempty input lines are printed to standard 
output as they are read. (This does not apply to lines read 
interactively.) To select this behavior on program start-up, use the 
switch -a. If set to queries, psql prints each query to standard output 
as it is sent to the server. The switch for this is -e. If set to 
errors, then only failed queries are displayed on standard error output. 
The switch for this is -b. If unset, or if set to none (or any other 
value than those above) then no queries are displayed.
"


aklaver@panda:~> cat psql_test.sql
select * from a ;

aklaver@panda:~> psql -a -d test -U  postgres -h localhost
psql (9.4.6)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, 
bits: 256, compression: off)
Type "help" for help.

test=# \i psql_test.sql
select * from a ;
  id | v1 | v2 | v3
----+----+----+----
   1 |  2 |  3 |  4
   2 |  2 |  3 |  4
(2 rows)



>
> What do I need to do in order to see the commands in test.sql as well as
> the output of those commands on my pgsql window?
>
> I'm running on Windows 7 if that matters.
>
> TIA,
> Mike


-- 
Adrian Klaver
adrian.klaver@aklaver.com


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (4+ messages)  latest in thread

Message-ID: <4b482dc1-d2ac-e61a-5401-74820591fb09@aklaver.com>
Permalink:  ../4b482dc1-d2ac-e61a-5401-74820591fb09@aklaver.com/
Also on:    postgresql.org/message-id/4b482dc1-d2ac-e61a-5401-74820591fb09@aklaver.com

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: adrian.klaver@aklaver.com, michaeljmoore@gmail.com
  Subject: Re: How to get pgsql to echo commands in a command file
  In-Reply-To: <4b482dc1-d2ac-e61a-5401-74820591fb09@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox