Commit ea7b4f1f authored by Tom Lane's avatar Tom Lane

Ensure previous setting of pset.queryFout is restored after a failed

backslash-g command.
parent 08372d4e
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2000 by PostgreSQL Global Development Group * Copyright 2000 by PostgreSQL Global Development Group
* *
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.30 2001/02/10 02:31:28 tgl Exp $ * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.31 2001/03/01 18:34:29 tgl Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -429,34 +429,35 @@ SendQuery(const char *query) ...@@ -429,34 +429,35 @@ SendQuery(const char *query)
FILE *queryFout_copy = pset.queryFout; FILE *queryFout_copy = pset.queryFout;
bool queryFoutPipe_copy = pset.queryFoutPipe; bool queryFoutPipe_copy = pset.queryFoutPipe;
pset.queryFout = NULL; /* so it doesn't get pset.queryFout = stdout; /* so it doesn't get
* closed */ * closed */
/* open file/pipe */ /* open file/pipe */
if (!setQFout(pset.gfname)) if (!setQFout(pset.gfname))
{ {
pset.queryFout = queryFout_copy;
pset.queryFoutPipe = queryFoutPipe_copy;
success = false; success = false;
break; break;
} }
printQuery(results, &pset.popt, pset.queryFout); printQuery(results, &pset.popt, pset.queryFout);
/* close file/pipe */ /* close file/pipe, restore old setting */
setQFout(NULL); setQFout(NULL);
free(pset.gfname);
pset.gfname = NULL;
pset.queryFout = queryFout_copy; pset.queryFout = queryFout_copy;
pset.queryFoutPipe = queryFoutPipe_copy; pset.queryFoutPipe = queryFoutPipe_copy;
free(pset.gfname);
pset.gfname = NULL;
success = true; success = true;
break;
} }
else else
{ {
success = true;
printQuery(results, &pset.popt, pset.queryFout); printQuery(results, &pset.popt, pset.queryFout);
success = true;
} }
break; break;
case PGRES_EMPTY_QUERY: case PGRES_EMPTY_QUERY:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment