summaryrefslogtreecommitdiff
path: root/src/bin/psql/mainloop.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2000-02-20 14:28:28 +0000
committerPeter Eisentraut <peter_e@gmx.net>2000-02-20 14:28:28 +0000
commit718bb2cc9c8483bed143d071aa000f9027c74a41 (patch)
tree119cdaab557c73785ad13f6dd6a37920dc687175 /src/bin/psql/mainloop.c
parent5253c518aef4c906dc6c922c51c2d77b0a78bf75 (diff)
Moved psql \eset and \eshow to \encoding
Improved psql's Ctrl-C handling Fixed configure test for sigsetjmp that now even recognizes it if it's a macro
Diffstat (limited to 'src/bin/psql/mainloop.c')
-rw-r--r--src/bin/psql/mainloop.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c
index 28d7b58bb06..9b3834cca7d 100644
--- a/src/bin/psql/mainloop.c
+++ b/src/bin/psql/mainloop.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.21 2000/02/20 02:37:40 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.22 2000/02/20 14:28:20 petere Exp $
*/
#include "postgres.h"
#include "mainloop.h"
@@ -16,6 +16,11 @@
#include "common.h"
#include "command.h"
+#ifndef WIN32
+#include <setjmp.h>
+
+sigjmp_buf main_loop_jmp;
+#endif
/*
@@ -88,6 +93,40 @@ MainLoop(FILE *source)
/* main loop to get queries and execute them */
while (1)
{
+ /*
+ * Welcome code for Control-C
+ */
+ if (cancel_pressed)
+ {
+ cancel_pressed = false;
+ if (!pset.cur_cmd_interactive)
+ {
+ /*
+ * You get here if you stopped a script with Ctrl-C and a query
+ * cancel was issued. In that case we don't do the longjmp, so
+ * the query routine can finish nicely.
+ */
+ successResult = EXIT_USER;
+ break;
+ }
+ }
+#ifndef WIN32
+ if (sigsetjmp(main_loop_jmp, 1) != 0)
+ {
+ /* got here with longjmp */
+ if (pset.cur_cmd_interactive)
+ {
+ fputc('\n', stdout);
+ resetPQExpBuffer(query_buf);
+ }
+ else
+ {
+ successResult = EXIT_USER;
+ break;
+ }
+ }
+#endif
+
if (slashCmdStatus == CMD_NEWEDIT)
{
/*
@@ -213,7 +252,7 @@ MainLoop(FILE *source)
/* echo back if flag is set */
var = GetVariable(pset.vars, "ECHO");
- if (var && strcmp(var, "all")==0)
+ if (!pset.cur_cmd_interactive && var && strcmp(var, "all")==0)
puts(line);
fflush(stdout);