aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/copy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/psql/copy.c')
-rw-r--r--src/bin/psql/copy.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c
index 9e815b136ed..a058f2ff0d4 100644
--- a/src/bin/psql/copy.c
+++ b/src/bin/psql/copy.c
@@ -269,11 +269,8 @@ do_copy(const char *args)
{
PQExpBufferData query;
FILE *copystream;
- FILE *save_file;
- FILE **override_file;
struct copy_options *options;
bool success;
- struct stat st;
/* parse options */
options = parse_slash_copy(args);
@@ -287,8 +284,6 @@ do_copy(const char *args)
if (options->from)
{
- override_file = &pset.cur_cmd_source;
-
if (options->file)
{
if (options->program)
@@ -308,8 +303,6 @@ do_copy(const char *args)
}
else
{
- override_file = &pset.queryFout;
-
if (options->file)
{
if (options->program)
@@ -345,6 +338,7 @@ do_copy(const char *args)
if (!options->program)
{
+ struct stat st;
int result;
/* make sure the specified file is not a directory */
@@ -375,11 +369,10 @@ do_copy(const char *args)
if (options->after_tofrom)
appendPQExpBufferStr(&query, options->after_tofrom);
- /* Run it like a user command, interposing the data source or sink. */
- save_file = *override_file;
- *override_file = copystream;
+ /* run it like a user command, but with copystream as data source/sink */
+ pset.copyStream = copystream;
success = SendQuery(query.data);
- *override_file = save_file;
+ pset.copyStream = NULL;
termPQExpBuffer(&query);
if (options->file != NULL)