Skip to content

Commit 89c2f57

Browse files
committed
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 b291c0f), 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.
1 parent 3433c6b commit 89c2f57

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/bin/psql/command.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,14 +2062,17 @@ process_file(char *filename, bool single_txn, bool use_relative_path)
20622062
}
20632063

20642064
fd = fopen(filename, PG_BINARY_R);
2065+
2066+
if (!fd)
2067+
{
2068+
psql_error("%s: %s\n", filename, strerror(errno));
2069+
return EXIT_FAILURE;
2070+
}
20652071
}
20662072
else
2067-
fd = stdin;
2068-
2069-
if (!fd)
20702073
{
2071-
psql_error("%s: %s\n", filename, strerror(errno));
2072-
return EXIT_FAILURE;
2074+
fd = stdin;
2075+
filename = "<stdin>"; /* for future error messages */
20732076
}
20742077

20752078
oldfilename = pset.inputfile;

src/bin/psql/startup.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,6 @@ main(int argc, char *argv[])
313313
printf(_("Type \"help\" for help.\n\n"));
314314
if (!pset.notty)
315315
initializeInput(options.no_readline ? 0 : 1);
316-
if (options.action_string) /* -f - was used */
317-
pset.inputfile = "<stdin>";
318316

319317
successResult = MainLoop(stdin);
320318
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy