diff options
| author | Peter Eisentraut | 2012-03-01 17:58:10 +0000 |
|---|---|---|
| committer | Peter Eisentraut | 2012-03-01 17:58:10 +0000 |
| commit | 89c2f573a392e3995fffc619d4faed23f8649269 (patch) | |
| tree | 6d18aabed73d306a9664c81828633e3d8cc26b57 /src/bin/psql/command.c | |
| parent | 3433c6ba002f711a60352c3518f30cda73d06087 (diff) | |
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
b291c0fba83a1e93868e2f69c03be195d620f30c), 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.
Diffstat (limited to 'src/bin/psql/command.c')
| -rw-r--r-- | src/bin/psql/command.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 8421ad00860..aa000735dc5 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -2062,14 +2062,17 @@ process_file(char *filename, bool single_txn, bool use_relative_path) } fd = fopen(filename, PG_BINARY_R); + + if (!fd) + { + psql_error("%s: %s\n", filename, strerror(errno)); + return EXIT_FAILURE; + } } else - fd = stdin; - - if (!fd) { - psql_error("%s: %s\n", filename, strerror(errno)); - return EXIT_FAILURE; + fd = stdin; + filename = "<stdin>"; /* for future error messages */ } oldfilename = pset.inputfile; |
