*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.16 2000/02/20 14:28:20 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.17 2000/02/21 19:40:41 petere Exp $
*/
#include "postgres.h"
#include "common.h"
void
handle_sigint(SIGNAL_ARGS)
{
+ cancel_pressed = true;
+
+ if (copy_state)
+ return;
+
if (cancelConn == NULL)
#ifndef WIN32
siglongjmp(main_loop_jmp, 1);
return;
#endif
- cancel_pressed = true;
-
/* Try to send cancel request */
if (PQrequestCancel(cancelConn))
write_stderr("\nCancel request sent\n");
cancelConn = pset.db;
res = PQexec(pset.db, query);
+ if (PQresultStatus(res) == PGRES_COPY_IN ||
+ PQresultStatus(res) == PGRES_COPY_OUT)
+ copy_state = true;
cancelConn = NULL;
if (PQstatus(pset.db) == CONNECTION_BAD)
cancelConn = pset.db;
results = PQexec(pset.db, query);
+ if (PQresultStatus(results) == PGRES_COPY_IN ||
+ PQresultStatus(results) == PGRES_COPY_OUT)
+ copy_state = true;
cancelConn = NULL;
if (results == NULL)
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.10 2000/02/16 13:15:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.11 2000/02/21 19:40:41 petere Exp $
*/
#include "postgres.h"
#include "copy.h"
#include <errno.h>
#include <assert.h>
+#include <signal.h>
#ifndef WIN32
#include <unistd.h> /* for isatty */
#else
#endif
#include "libpq-fe.h"
+#include "pqsignal.h"
#include "settings.h"
#include "common.h"
#define strcasecmp(x,y) stricmp(x,y)
#endif
+bool copy_state;
+
/*
* parse_slash_copy
* -- parses \copy command line
}
}
fflush(copystream);
- return !PQendcopy(conn);
+ ret = !PQendcopy(conn);
+ copy_state = false;
+ return ret;
}
char *s;
int bufleft;
int c = 0;
+ int ret;
if (prompt) /* disable prompt if not interactive */
{
}
PQputline(conn, "\n");
}
- return !PQendcopy(conn);
+ ret = !PQendcopy(conn);
+ copy_state = false;
+ return ret;
}
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/copy.h,v 1.7 2000/02/16 13:15:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/copy.h,v 1.8 2000/02/21 19:40:42 petere Exp $
*/
#ifndef COPY_H
#define COPY_H
#include "libpq-fe.h"
+extern bool copy_state;
+
/* handler for \copy */
bool do_copy(const char *args);