On Wed, May 17, 2023 at 2:13 PM Tom Lane <t...@sss.pgh.pa.us> wrote:

> Laurenz Albe <laurenz.a...@cybertec.at> writes:
> > You removed the ******** QUERY ******** at the end of the query.
>
> Fixed
Also Fixed Pavel's name.
Also Added Laurenze as a Reviewed By: (not sure, never want to NOT ack
someone)

>
> Also, you'd have to avoid copying-and-pasting the query output
> anyway, so I'm not entirely sold that there's much of
> a usability gain here.
>

My output never contains query output results intermixed.  I get a handful
of queries.
Then I get the output of the "\d t1"  (Which makes me wonder if I am doing
something wrong,
or there is another use case I should be testing).

I labelled this v2.  I also edited the Thread: (I realized I can find the
thread, go to the Whole Thread,
and then include the link to the first item in the thread.  I assume that
is what's expected).

Kirk...

psql>
create table t1(id bigint not null primary key generated always as
identity);
\set ECHO_HIDDEN on
\d t1

Generates:
/********* QUERY **********/
... Clipped ...
FROM pg_catalog.pg_publication p
WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('24577')
ORDER BY 1;
/**************************/

/********* QUERY **********/
SELECT c.oid::pg_catalog.regclass
FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i
WHERE c.oid = i.inhparent AND i.inhrelid = '24577'
  AND c.relkind != 'p' AND c.relkind != 'I'
ORDER BY inhseqno;
/**************************/

/********* QUERY **********/
SELECT c.oid::pg_catalog.regclass, c.relkind, inhdetachpending,
pg_catalog.pg_get_expr(c.relpartbound, c.oid)
FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i
WHERE c.oid = i.inhrelid AND i.inhparent = '24577'
ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',
c.oid::pg_catalog.regclass::pg_catalog.text;
/**************************/

                           Table "public.t1"
 ... End Clip...
-- NOTICE: there is no output between queries using ECHO_HIDDEN
From e8b520941154a09b350adf73cabc18dcc0596515 Mon Sep 17 00:00:00 2001
From: Kirk Wolak <wol...@gmail.com>
Date: Wed, 17 May 2023 16:59:02 -0400
Subject: [PATCH] [PATCH v2] Change output of ECHO_HIDDEN comments to be SQL 
comments

Simply Add the "/" Required before/after the ********* QUERY ********** 
(SHOW_HIDDEN on)
so that they are comments and are ignored if you copy and paste a series of 
them.

Author: Kirk Wolak <wol...@gmail.com>
Reviewed By: Pavel Stehule <pavel.steh...@gmail.com>
Reviewed By: Laurenz Albe <laurenz.a...@cybertec.at>
Thread: 
https://postgr.es/m/caclu5mtfjrjytbvmz26txggmxwqo0hkghh2o3hequupmsbg...@mail.gmail.com
---
 src/bin/psql/command.c | 8 ++++----
 src/bin/psql/common.c  | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 607a57715a..186beb83f5 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -5388,16 +5388,16 @@ echo_hidden_command(const char *query)
 {
        if (pset.echo_hidden != PSQL_ECHO_HIDDEN_OFF)
        {
-               printf(_("********* QUERY **********\n"
+               printf(_("/********* QUERY **********/\n"
                                 "%s\n"
-                                "**************************\n\n"), query);
+                                "/**************************/\n\n"), query);
                fflush(stdout);
                if (pset.logfile)
                {
                        fprintf(pset.logfile,
-                                       _("********* QUERY **********\n"
+                                       _("/********* QUERY **********/\n"
                                          "%s\n"
-                                         "**************************\n\n"), 
query);
+                                         "/**************************/\n\n"), 
query);
                        fflush(pset.logfile);
                }
 
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c
index c0e6e8e6ed..07a6c33fb4 100644
--- a/src/bin/psql/common.c
+++ b/src/bin/psql/common.c
@@ -589,16 +589,16 @@ PSQLexec(const char *query)
 
        if (pset.echo_hidden != PSQL_ECHO_HIDDEN_OFF)
        {
-               printf(_("********* QUERY **********\n"
+               printf(_("/********* QUERY **********/\n"
                                 "%s\n"
-                                "**************************\n\n"), query);
+                                "/**************************/\n\n"), query);
                fflush(stdout);
                if (pset.logfile)
                {
                        fprintf(pset.logfile,
-                                       _("********* QUERY **********\n"
+                                       _("/********* QUERY **********/\n"
                                          "%s\n"
-                                         "**************************\n\n"), 
query);
+                                         "/**************************/\n\n"), 
query);
                        fflush(pset.logfile);
                }
 
-- 
2.34.1

Reply via email to