Am Mittwoch, 14. November 2007 schrieb Martijn van Oosterhout:
> It's not the fopen that fails, it's the fgets that returns NULL. We
> don't subsequently check if that's due to an I/O error or EISDIR or if
> it's an end-of-file.

Here is a patch for this.

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/
diff -ru ../../../../cvs-pgsql/src/bin/psql/input.c ./input.c
--- ../../../../cvs-pgsql/src/bin/psql/input.c	2007-01-05 23:19:49.000000000 +0100
+++ ./input.c	2007-11-15 13:59:22.000000000 +0100
@@ -179,7 +179,7 @@
 		/* Disable SIGINT again */
 		sigint_interrupt_enabled = false;
 
-		/* EOF? */
+		/* EOF or error? */
 		if (result == NULL)
 			break;
 
diff -ru ../../../../cvs-pgsql/src/bin/psql/mainloop.c ./mainloop.c
--- ../../../../cvs-pgsql/src/bin/psql/mainloop.c	2007-01-05 23:19:49.000000000 +0100
+++ ./mainloop.c	2007-11-15 13:57:36.000000000 +0100
@@ -129,7 +129,14 @@
 			line = gets_interactive(get_prompt(prompt_status));
 		}
 		else
+		{
 			line = gets_fromFile(source);
+			if (!line && ferror(source))
+			{
+				psql_error("could not read from input file: %s\n", strerror(errno));
+				successResult = EXIT_FAILURE;
+			}
+		}
 
 		/*
 		 * query_buf holds query already accumulated.  line is the malloc'd
---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to