Skip to content

Commit b715982

Browse files
committed
Return proper value for psql -f filename failure if filename open fails.
Backpatch to 8.0.X.
1 parent 408c140 commit b715982

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/bin/psql/command.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.152 2005/08/14 18:49:30 tgl Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.153 2005/09/20 18:59:01 momjian Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "command.h"
@@ -1314,7 +1314,8 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
13141314
* process_file
13151315
*
13161316
* Read commands from filename and then them to the main processing loop
1317-
* Handler for \i, but can be used for other things as well.
1317+
* Handler for \i, but can be used for other things as well. Returns
1318+
* MainLoop() error code.
13181319
*/
13191320
int
13201321
process_file(char *filename)
@@ -1324,15 +1325,15 @@ process_file(char *filename)
13241325
char *oldfilename;
13251326

13261327
if (!filename)
1327-
return false;
1328+
return EXIT_FAILURE;
13281329

13291330
canonicalize_path(filename);
13301331
fd = fopen(filename, PG_BINARY_R);
13311332

13321333
if (!fd)
13331334
{
13341335
psql_error("%s: %s\n", filename, strerror(errno));
1335-
return false;
1336+
return EXIT_FAILURE;
13361337
}
13371338

13381339
oldfilename = pset.inputfile;

src/bin/psql/startup.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.122 2005/09/05 18:05:13 tgl Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.123 2005/09/20 18:59:02 momjian Exp $
77
*/
88
#include "postgres_fe.h"
99

@@ -690,9 +690,9 @@ process_psqlrc_file(char *filename)
690690
sprintf(psqlrc, "%s-%s", filename, PG_VERSION);
691691

692692
if (access(psqlrc, R_OK) == 0)
693-
process_file(psqlrc);
693+
(void)process_file(psqlrc);
694694
else if (access(filename, R_OK) == 0)
695-
process_file(filename);
695+
(void)process_file(filename);
696696
free(psqlrc);
697697
}
698698

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