mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Properly recognize and announce input errors.
This commit is contained in:
		@@ -3,7 +3,7 @@
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 * Copyright (c) 2000-2007, PostgreSQL Global Development Group
 | 
					 * Copyright (c) 2000-2007, PostgreSQL Global Development Group
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.62 2007/01/05 22:19:49 momjian Exp $
 | 
					 * $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.63 2007/11/28 09:17:46 petere Exp $
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
#include "postgres_fe.h"
 | 
					#include "postgres_fe.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -147,7 +147,7 @@ pg_send_history(PQExpBuffer history_buf)
 | 
				
			|||||||
 * gets_fromFile
 | 
					 * gets_fromFile
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Gets a line of noninteractive input from a file (which could be stdin).
 | 
					 * Gets a line of noninteractive input from a file (which could be stdin).
 | 
				
			||||||
 * The result is a malloc'd string.
 | 
					 * The result is a malloc'd string, or NULL on EOF or input error.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Caller *must* have set up sigint_interrupt_jmp before calling.
 | 
					 * Caller *must* have set up sigint_interrupt_jmp before calling.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
@@ -179,9 +179,16 @@ gets_fromFile(FILE *source)
 | 
				
			|||||||
		/* Disable SIGINT again */
 | 
							/* Disable SIGINT again */
 | 
				
			||||||
		sigint_interrupt_enabled = false;
 | 
							sigint_interrupt_enabled = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* EOF? */
 | 
							/* EOF or error? */
 | 
				
			||||||
		if (result == NULL)
 | 
							if (result == NULL)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								if (ferror(source))
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									psql_error("could not read from input file: %s\n", strerror(errno));
 | 
				
			||||||
 | 
									return NULL;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		appendPQExpBufferStr(buffer, line);
 | 
							appendPQExpBufferStr(buffer, line);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,7 @@
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 * Copyright (c) 2000-2007, PostgreSQL Global Development Group
 | 
					 * Copyright (c) 2000-2007, PostgreSQL Global Development Group
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.85 2007/01/05 22:19:49 momjian Exp $
 | 
					 * $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.86 2007/11/28 09:17:46 petere Exp $
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
#include "postgres_fe.h"
 | 
					#include "postgres_fe.h"
 | 
				
			||||||
#include "mainloop.h"
 | 
					#include "mainloop.h"
 | 
				
			||||||
@@ -129,7 +129,11 @@ MainLoop(FILE *source)
 | 
				
			|||||||
			line = gets_interactive(get_prompt(prompt_status));
 | 
								line = gets_interactive(get_prompt(prompt_status));
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
			line = gets_fromFile(source);
 | 
								line = gets_fromFile(source);
 | 
				
			||||||
 | 
								if (!line && ferror(source))
 | 
				
			||||||
 | 
									successResult = EXIT_FAILURE;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/*
 | 
							/*
 | 
				
			||||||
		 * query_buf holds query already accumulated.  line is the malloc'd
 | 
							 * query_buf holds query already accumulated.  line is the malloc'd
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user