2

When I execute SQL, I see the query echoed back at me.

=# \d
LOG:  statement: SELECT n.nspname as "Schema",
  c.relname as "Name",
  CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm' THEN
  [... LOT OF STUFF CUT]
                   List of relations
 Schema |          Name          |   Type   |  Owner   
--------+------------------------+----------+----------

All queries get echoed too,

=# SELECT * FROM ( VALUES (1) ) AS t(x);
LOG:  statement: SELECT * FROM ( VALUES (1) ) AS t(x);
 x 
---
 1
(1 row)

How do I disable this feature? I've tried lots of things.

2

There are two methods that can cause the query to be echoed.

  • With psql -E (or \set ECHO_HIDDEN) the queries that psql executes with client commands \command are echoed back at you. You can see if this is set by running \set and looking for ECHO_HIDDEN. If set, you should try running without -E, not setting the option yourself, and making sure it's not set in the ~/.psqlrc. If set the query will look like this above every client command

    ********* QUERY **********
    query
    **************************
    
  • If you see LOG: statement:, you may have awkward configurations on the server, like

    client_min_messages='LOG';
    log_statement='all';
    

    See the docs on Error Reporting and Logging for more information. You should check,

    SHOW client_min_messages;
    SHOW log_statement;
    

    If set, this is an indicator that someone opened up the server-configuration file and wanted more logging but didn't know what they were doing.

In your case you have LOG: statement: so check the server settings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.