Re: psql --echo-queries does not echo all queries

Gavin Wahl <gavinwahl@gmail.com>

From: Gavin Wahl <gavinwahl@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>, pgsql-bugs@lists.postgresql.org
Date: 2025-10-27T22:24:32Z
Lists: pgsql-bugs
I tried with -E and it does echo the BEGIN/END used to implement
-1/--single-transaction, but not the SAVEPOINT queries for
ON_ERROR_ROLLBACK.  It looks like SendQuery is calling PQexec directly
instead of calling the PSQLexec wrapper function that does the
logging. I happened to notice that the queries emitted by \watch, nor
the BEGIN for autocommit, aren't logged by either option as well.

I think this may be a documentation bug as well? I would expect -e to
be a superset of -E:

 -E
 --echo-hidden
     Echo the actual queries generated by \d and other backslash commands.

 -e
 --echo-queries
     Copy *ALL* [emphasis mine] SQL commands sent to the server to
standard output as well