mirror of
https://github.com/postgres/postgres.git
synced 2025-12-12 02:37:31 +03:00
Fixed psql's Control-C handling when COPY in progress
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* 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"
|
||||
@@ -246,6 +246,11 @@ volatile bool cancel_pressed;
|
||||
void
|
||||
handle_sigint(SIGNAL_ARGS)
|
||||
{
|
||||
cancel_pressed = true;
|
||||
|
||||
if (copy_state)
|
||||
return;
|
||||
|
||||
if (cancelConn == NULL)
|
||||
#ifndef WIN32
|
||||
siglongjmp(main_loop_jmp, 1);
|
||||
@@ -253,8 +258,6 @@ handle_sigint(SIGNAL_ARGS)
|
||||
return;
|
||||
#endif
|
||||
|
||||
cancel_pressed = true;
|
||||
|
||||
/* Try to send cancel request */
|
||||
if (PQrequestCancel(cancelConn))
|
||||
write_stderr("\nCancel request sent\n");
|
||||
@@ -297,6 +300,9 @@ PSQLexec(const char *query)
|
||||
|
||||
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)
|
||||
@@ -388,6 +394,9 @@ SendQuery(const char *query)
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user