psql --echo-queries does not echo all queries - Mailing list pgsql-bugs

From Gavin Wahl
Subject psql --echo-queries does not echo all queries
Date
Msg-id CACPudh2Xf1OSPaFD0tcBMoGAjqyUz_PXCwKWKW4XcAUozsR=4g@mail.gmail.com
Whole thread Raw
Responses Re: psql --echo-queries does not echo all queries
List pgsql-bugs
The -e/--echo-queries psql option is documented to "Copy all SQL
commands sent to the server to standard output as well." However, it
does not show queries sent to the server by -1/--single-transaction or
by ON_ERROR_ROLLBACK.

For example:

$ psql -e  -1 -c 'SELECT 1'
SELECT 1
 ?column?
----------
        1
(1 row)

While the server log reports:
2025-10-24 12:01:57.937 MDT [1970796] LOG:  duration: 0.035 ms  statement: BEGIN
2025-10-24 12:01:57.937 MDT [1970796] LOG:  duration: 0.085 ms
statement: SELECT 1
2025-10-24 12:01:57.937 MDT [1970796] LOG:  duration: 0.004 ms
statement: COMMIT

The BEGIN/END are not reported by psql.


$ psql -e -v ON_ERROR_ROLLBACK=on
psql (16.9)
Type "help" for help.

# BEGIN;
BEGIN;
BEGIN
# SELECT 1;
SELECT 1;
 ?column?
----------
        1
(1 row)

While the server log reports:
2025-10-24 12:12:21.517 MDT [1974726] LOG:  duration: 0.077 ms
statement: BEGIN;
2025-10-24 12:12:25.757 MDT [1974726] LOG:  duration: 0.048 ms
statement: SAVEPOINT pg_psql_temporary_savepoint
2025-10-24 12:12:25.757 MDT [1974726] LOG:  duration: 0.156 ms
statement: SELECT 1;
2025-10-24 12:12:25.757 MDT [1974726] LOG:  duration: 0.012 ms
statement: RELEASE pg_psql_temporary_savepoint

The savepoints are not reported by psql.



pgsql-bugs by date:

Previous
From: "Euler Taveira"
Date:
Subject: Re: BUG #19093: Behavioral change in walreceiver termination between PostgreSQL 14.17 and 14.18
Next
From: Daniel Gustafsson
Date:
Subject: Re: BUG #19042: Option --help not recognized at the end of command line in pg_restore