diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 61d23dade87..73ac9b4265d 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4051,7 +4051,7 @@ process_file(char *filename, bool use_relative_path) } oldfilename = pset.inputfile; - pset.inputfile = filename; + pset.inputfile = ignore_log_file ? NULL : filename; pg_logging_config(pset.inputfile ? 0 : PG_LOG_FLAG_TERSE); diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index a888ae71c1b..5935a05363e 100644 --- a/src/bin/psql/help.c +++ b/src/bin/psql/help.c @@ -100,6 +100,7 @@ usage(unsigned short int pager) fprintf(output, _(" -e, --echo-queries echo commands sent to server\n")); fprintf(output, _(" -E, --echo-hidden display queries that internal commands generate\n")); fprintf(output, _(" -L, --log-file=FILENAME send session log to file\n")); + fprintf(output, _(" --ignore-log-file do not log psql:filename prefix in log file\n")); fprintf(output, _(" -n, --no-readline disable enhanced command line editing (readline)\n")); fprintf(output, _(" -o, --output=FILENAME send query results to file (or |pipe)\n")); fprintf(output, _(" -q, --quiet run quietly (no messages, only query output)\n")); diff --git a/src/bin/psql/settings.h b/src/bin/psql/settings.h index 83f2e6f254e..562f9992491 100644 --- a/src/bin/psql/settings.h +++ b/src/bin/psql/settings.h @@ -152,7 +152,7 @@ typedef struct _psqlSettings } PsqlSettings; extern PsqlSettings pset; - +extern bool ignore_log_file; #ifndef EXIT_SUCCESS #define EXIT_SUCCESS 0 diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c index 0097cae940f..c9b95b3b92a 100644 --- a/src/bin/psql/startup.c +++ b/src/bin/psql/startup.c @@ -85,6 +85,8 @@ static void process_psqlrc(char *argv0); static void process_psqlrc_file(char *filename); static void showVersion(void); static void EstablishVariableSpace(void); +/* ignore psql:filename in log output */ +bool ignore_log_file = false; #define NOPAGER 0 @@ -498,6 +500,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts *options) {"no-psqlrc", no_argument, NULL, 'X'}, {"help", optional_argument, NULL, 1}, {"csv", no_argument, NULL, 2}, + {"ignore-log-file", no_argument, NULL, 256}, {NULL, 0, NULL, 0} }; @@ -694,6 +697,9 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts *options) case 2: pset.popt.topt.format = PRINT_CSV; break; + case 256: + ignore_log_file = true; + break; default: unknown_option: fprintf(stderr, _("Try \"%s --help\" for more information.\n"), diff --git a/src/test/regress/pg_regress_main.c b/src/test/regress/pg_regress_main.c index 1e946c0d609..e3c4b244dfa 100644 --- a/src/test/regress/pg_regress_main.c +++ b/src/test/regress/pg_regress_main.c @@ -129,11 +129,21 @@ psql_start_test(const char *testname, * psql < \"%s\" 2>&1 < \"%s\" 2>&1 " + "-f \"%s\" -f \"%s\" --ignore-log-file\n", use_utility_mode ? "env PGOPTIONS='-c gp_role=utility'" : "", bindir ? bindir : "", bindir ? "/" : "",