Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bin/psql/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions src/bin/psql/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
2 changes: 1 addition & 1 deletion src/bin/psql/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ typedef struct _psqlSettings
} PsqlSettings;

extern PsqlSettings pset;

extern bool ignore_log_file;

#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
Expand Down
6 changes: 6 additions & 0 deletions src/bin/psql/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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}
};

Expand Down Expand Up @@ -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"),
Expand Down
16 changes: 13 additions & 3 deletions src/test/regress/pg_regress_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,21 @@ psql_start_test(const char *testname,
* psql <<EOF
* $(cat prehook infile)
* EOF
*
* CBDB:
* However the above command will have strange behavior on some platforms,
* like UOS1050a, UOS1060e. The input stream is unexpectedly changed
* for psql. It looks like a system-level problem that we have nothing
* to do. We change the above command to
*
* psql -f prehook -f infile --ignore-log-file
*
* --ignore-log-file will suppress additional logging prefix that has
* the same effect like no filename is provided.
*/
offset += snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
"%s \"%s%spsql\" -X -a -q -d \"%s\" %s > \"%s\" 2>&1 <<EOF\n"
"$(cat \"%s\" \"%s\")\n"
"EOF",
"%s \"%s%spsql\" -X -a -q -d \"%s\" %s > \"%s\" 2>&1 "
"-f \"%s\" -f \"%s\" --ignore-log-file\n",
use_utility_mode ? "env PGOPTIONS='-c gp_role=utility'" : "",
bindir ? bindir : "",
bindir ? "/" : "",
Expand Down