v2-0001-Change-output-of-ECHO_HIDDEN-comments-to-be-SQL-comm.patch

text/plain

Filename: v2-0001-Change-output-of-ECHO_HIDDEN-comments-to-be-SQL-comm.patch
Type: text/plain
Part: 0
Message: Re: psql: Could we get "-- " prefixing on the **** QUERY **** outputs? (ECHO_HIDDEN)
From e8b520941154a09b350adf73cabc18dcc0596515 Mon Sep 17 00:00:00 2001
From: Kirk Wolak <wolakk@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 <wolakk@gmail.com>
Reviewed By: Pavel Stehule <pavel.stehule@gmail.com>
Reviewed By: Laurenz Albe <laurenz.albe@cybertec.at>
Thread: https://postgr.es/m/CACLU5mTFJRJYtbvmZ26txGgmXWQo0hkGhH2o3hEquUPmSbGtBw@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