mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
psql: Improve error display for psql -f -
Running "psql -f -" used to print
psql:<stdin>:1: ERROR: blah
but that got broken between 8.4 and 9.0 (commit
b291c0fba8
), and now it printed
psql:-:1: ERROR: blah
This reverts to the old behavior and cleans up some code that was left
dead or useless by the mentioned commit.
This commit is contained in:
@ -2062,15 +2062,18 @@ process_file(char *filename, bool single_txn, bool use_relative_path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fd = fopen(filename, PG_BINARY_R);
|
fd = fopen(filename, PG_BINARY_R);
|
||||||
}
|
|
||||||
else
|
|
||||||
fd = stdin;
|
|
||||||
|
|
||||||
if (!fd)
|
if (!fd)
|
||||||
{
|
{
|
||||||
psql_error("%s: %s\n", filename, strerror(errno));
|
psql_error("%s: %s\n", filename, strerror(errno));
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fd = stdin;
|
||||||
|
filename = "<stdin>"; /* for future error messages */
|
||||||
|
}
|
||||||
|
|
||||||
oldfilename = pset.inputfile;
|
oldfilename = pset.inputfile;
|
||||||
pset.inputfile = filename;
|
pset.inputfile = filename;
|
||||||
|
@ -313,8 +313,6 @@ main(int argc, char *argv[])
|
|||||||
printf(_("Type \"help\" for help.\n\n"));
|
printf(_("Type \"help\" for help.\n\n"));
|
||||||
if (!pset.notty)
|
if (!pset.notty)
|
||||||
initializeInput(options.no_readline ? 0 : 1);
|
initializeInput(options.no_readline ? 0 : 1);
|
||||||
if (options.action_string) /* -f - was used */
|
|
||||||
pset.inputfile = "<stdin>";
|
|
||||||
|
|
||||||
successResult = MainLoop(stdin);
|
successResult = MainLoop(stdin);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user