diff options
author | Alvaro Herrera | 2015-01-23 18:02:45 +0000 |
---|---|---|
committer | Alvaro Herrera | 2015-01-23 18:02:45 +0000 |
commit | a17923204736d8842eade3517d6a8ee81290fca4 (patch) | |
tree | 5e7c05d028e03a28cc013a2d06b7e46f73134cda /src/bin/scripts/common.c | |
parent | 5cefbf5a6c4466ac6b1cc2a4316b4eba9108c802 (diff) |
vacuumdb: enable parallel mode
This mode allows vacuumdb to open several server connections to vacuum
or analyze several tables simultaneously.
Author: Dilip Kumar. Some reworking by Álvaro Herrera
Reviewed by: Jeff Janes, Amit Kapila, Magnus Hagander, Andres Freund
Diffstat (limited to 'src/bin/scripts/common.c')
-rw-r--r-- | src/bin/scripts/common.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/bin/scripts/common.c b/src/bin/scripts/common.c index 6bfe2e628b1..da142aaa643 100644 --- a/src/bin/scripts/common.c +++ b/src/bin/scripts/common.c @@ -19,10 +19,9 @@ #include "common.h" -static void SetCancelConn(PGconn *conn); -static void ResetCancelConn(void); static PGcancel *volatile cancelConn = NULL; +bool CancelRequested = false; #ifdef WIN32 static CRITICAL_SECTION cancelConnLock; @@ -291,7 +290,7 @@ yesno_prompt(const char *question) * * Set cancelConn to point to the current database connection. */ -static void +void SetCancelConn(PGconn *conn) { PGcancel *oldCancelConn; @@ -321,7 +320,7 @@ SetCancelConn(PGconn *conn) * * Free the current cancel connection, if any, and set to NULL. */ -static void +void ResetCancelConn(void) { PGcancel *oldCancelConn; @@ -345,9 +344,8 @@ ResetCancelConn(void) #ifndef WIN32 /* - * Handle interrupt signals by canceling the current command, - * if it's being executed through executeMaintenanceCommand(), - * and thus has a cancelConn set. + * Handle interrupt signals by canceling the current command, if a cancelConn + * is set. */ static void handle_sigint(SIGNAL_ARGS) @@ -359,10 +357,15 @@ handle_sigint(SIGNAL_ARGS) if (cancelConn != NULL) { if (PQcancel(cancelConn, errbuf, sizeof(errbuf))) + { + CancelRequested = true; fprintf(stderr, _("Cancel request sent\n")); + } else fprintf(stderr, _("Could not send cancel request: %s"), errbuf); } + else + CancelRequested = true; errno = save_errno; /* just in case the write changed it */ } @@ -392,10 +395,16 @@ consoleHandler(DWORD dwCtrlType) if (cancelConn != NULL) { if (PQcancel(cancelConn, errbuf, sizeof(errbuf))) + { fprintf(stderr, _("Cancel request sent\n")); + CancelRequested = true; + } else fprintf(stderr, _("Could not send cancel request: %s"), errbuf); } + else + CancelRequested = true; + LeaveCriticalSection(&cancelConnLock); return TRUE; |