aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tcop/postgres.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2002-07-13 01:02:14 +0000
committerBruce Momjian <bruce@momjian.us>2002-07-13 01:02:14 +0000
commit4db8718e84a40125e8a7c2ffcfccf50932cdfd85 (patch)
tree8bc5fe0215602ad80001676193f47918ad1df29d /src/backend/tcop/postgres.c
parentccb3f90f0695d87e29ee066dd64183fa29edfc3f (diff)
downloadpostgresql-4db8718e84a40125e8a7c2ffcfccf50932cdfd85.tar.gz
postgresql-4db8718e84a40125e8a7c2ffcfccf50932cdfd85.zip
Add SET statement_timeout capability. Timeout is in ms. A value of
zero turns off the timer.
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r--src/backend/tcop/postgres.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index c6b8fcfafd6..154e478687b 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.269 2002/07/11 07:39:26 ishii Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.270 2002/07/13 01:02:14 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@@ -78,6 +78,8 @@ char *debug_query_string; /* used by pgmonitor */
/* Note: whereToSendOutput is initialized for the bootstrap/standalone case */
CommandDest whereToSendOutput = Debug;
+extern int StatementTimeout;
+
static bool dontExecute = false;
/* note: these declarations had better match tcopprot.h */
@@ -717,6 +719,9 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */
xact_started = true;
}
+ if (StatementTimeout)
+ enable_sig_alarm(StatementTimeout, true);
+
/*
* If we got a cancel signal in analysis or prior command,
* quit
@@ -791,6 +796,8 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */
ShowUsage("EXECUTOR STATISTICS");
}
+ disable_sig_alarm(true);
+
/*
* In a query block, we want to increment the command counter
* between queries so that the effects of early queries are
@@ -821,9 +828,7 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */
finish_xact_command();
xact_started = false;
}
-
- } /* end loop over queries generated from a
- * parsetree */
+ } /* end loop over queries generated from a parsetree */
/*
* If this is the last parsetree of the query string, close down
@@ -996,7 +1001,7 @@ authdie(SIGNAL_ARGS)
* at soonest convenient time
*/
static void
-QueryCancelHandler(SIGNAL_ARGS)
+StatementCancelHandler(SIGNAL_ARGS)
{
int save_errno = errno;
@@ -1551,10 +1556,10 @@ PostgresMain(int argc, char *argv[], const char *username)
*/
pqsignal(SIGHUP, SigHupHandler); /* set flag to read config file */
- pqsignal(SIGINT, QueryCancelHandler); /* cancel current query */
+ pqsignal(SIGINT, StatementCancelHandler); /* cancel current query */
pqsignal(SIGTERM, die); /* cancel current query and exit */
pqsignal(SIGQUIT, quickdie); /* hard crash time */
- pqsignal(SIGALRM, HandleDeadLock); /* check for deadlock after
+ pqsignal(SIGALRM, handle_sig_alarm); /* check for deadlock after
* timeout */
/*
@@ -1688,7 +1693,7 @@ PostgresMain(int argc, char *argv[], const char *username)
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
- puts("$Revision: 1.269 $ $Date: 2002/07/11 07:39:26 $\n");
+ puts("$Revision: 1.270 $ $Date: 2002/07/13 01:02:14 $\n");
}
/*
@@ -1820,6 +1825,9 @@ PostgresMain(int argc, char *argv[], const char *username)
QueryCancelPending = false; /* forget any earlier CANCEL
* signal */
+ /* Stop any statement timer */
+ disable_sig_alarm(true);
+
EnableNotifyInterrupt();
/* Allow "die" interrupt to be processed while waiting */