While working on something in "psql/common.c" I noticed some triplicated
code, including a long translatable string. This minor patch refactors
this in one function.
--
Fabien.
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c
index 7a95465111..4fd80ec6bb 100644
--- a/src/bin/psql/common.c
+++ b/src/bin/psql/common.c
@@ -523,6 +523,15 @@ PrintTiming(double elapsed_msec)
elapsed_msec, days, (int) hours, (int) minutes, seconds);
}
+static void
+echoQuery(FILE *out, const char *query)
+{
+ fprintf(out,
+ _("********* QUERY **********\n"
+ "%s\n"
+ "**************************\n\n"), query);
+ fflush(out);
+}
/*
* PSQLexec
@@ -549,18 +558,9 @@ PSQLexec(const char *query)
if (pset.echo_hidden != PSQL_ECHO_HIDDEN_OFF)
{
- printf(_("********* QUERY **********\n"
- "%s\n"
- "**************************\n\n"), query);
- fflush(stdout);
+ echoQuery(stdout, query);
if (pset.logfile)
- {
- fprintf(pset.logfile,
- _("********* QUERY **********\n"
- "%s\n"
- "**************************\n\n"), query);
- fflush(pset.logfile);
- }
+ echoQuery(pset.logfile, query);
if (pset.echo_hidden == PSQL_ECHO_HIDDEN_NOEXEC)
return NULL;
@@ -1226,13 +1226,7 @@ SendQuery(const char *query)
}
if (pset.logfile)
- {
- fprintf(pset.logfile,
- _("********* QUERY **********\n"
- "%s\n"
- "**************************\n\n"), query);
- fflush(pset.logfile);
- }
+ echoQuery(pset.logfile, query);
SetCancelConn(pset.db);