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, 9 insertions, 6 deletions
diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c
index 4b749154adf..90f4a24fa5d 100644
--- a/src/bin/psql/copy.c
+++ b/src/bin/psql/copy.c
@@ -517,8 +517,8 @@ bool
handleCopyIn(PGconn *conn, FILE *copystream, bool isbinary, PGresult **res)
{
bool OK;
- const char *prompt;
char buf[COPYBUFSIZ];
+ bool showprompt = false;
/*
* Establish longjmp destination for exiting from wait-for-input. (This is
@@ -540,21 +540,20 @@ handleCopyIn(PGconn *conn, FILE *copystream, bool isbinary, PGresult **res)
/* Prompt if interactive input */
if (isatty(fileno(copystream)))
{
+ showprompt = true;
if (!pset.quiet)
puts(_("Enter data to be copied followed by a newline.\n"
"End with a backslash and a period on a line by itself."));
- prompt = get_prompt(PROMPT_COPY);
}
- else
- prompt = NULL;
OK = true;
if (isbinary)
{
/* interactive input probably silly, but give one prompt anyway */
- if (prompt)
+ if (showprompt)
{
+ const char *prompt = get_prompt(PROMPT_COPY);
fputs(prompt, stdout);
fflush(stdout);
}
@@ -589,8 +588,9 @@ handleCopyIn(PGconn *conn, FILE *copystream, bool isbinary, PGresult **res)
bool firstload;
bool linedone;
- if (prompt)
+ if (showprompt)
{
+ const char *prompt = get_prompt(PROMPT_COPY);
fputs(prompt, stdout);
fflush(stdout);
}
@@ -650,7 +650,10 @@ handleCopyIn(PGconn *conn, FILE *copystream, bool isbinary, PGresult **res)
}
if (copystream == pset.cur_cmd_source)
+ {
pset.lineno++;
+ pset.stmt_lineno++;
+ }
}
}