aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tcop/postgres.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2002-09-04 20:31:48 +0000
committerBruce Momjian <bruce@momjian.us>2002-09-04 20:31:48 +0000
commite50f52a074bdf0d6a9dc384840e641c4c0b0bb1a (patch)
treeab73e8c8ec94a6ddc774c1f9c49b87aa6b93fd13 /src/backend/tcop/postgres.c
parentc91ceec21d357d6d857163d897ac75a79c883dee (diff)
downloadpostgresql-e50f52a074bdf0d6a9dc384840e641c4c0b0bb1a.tar.gz
postgresql-e50f52a074bdf0d6a9dc384840e641c4c0b0bb1a.zip
pgindent run.
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r--src/backend/tcop/postgres.c167
1 files changed, 87 insertions, 80 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index a1acc242973..01d810088c8 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.290 2002/09/02 05:25:37 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.291 2002/09/04 20:31:26 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@@ -69,12 +69,13 @@
extern int optind;
extern char *optarg;
-char *debug_query_string; /* for pgmonitor and log_min_error_statement*/
+char *debug_query_string; /* for pgmonitor and
+ * log_min_error_statement */
/* Note: whereToSendOutput is initialized for the bootstrap/standalone case */
CommandDest whereToSendOutput = Debug;
-extern int StatementTimeout;
+extern int StatementTimeout;
static bool dontExecute = false;
@@ -551,7 +552,7 @@ pg_plan_query(Query *querytree)
*/
void
-pg_exec_query_string(StringInfo query_string, /* string to execute */
+pg_exec_query_string(StringInfo query_string, /* string to execute */
CommandDest dest, /* where results should go */
MemoryContext parse_context) /* context for
* parsetrees */
@@ -561,14 +562,15 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */
List *parsetree_list,
*parsetree_item;
struct timezone tz;
- struct timeval start_t, stop_t;
+ struct timeval start_t,
+ stop_t;
bool save_Log_duration = Log_duration;
debug_query_string = query_string->data;
/*
- * We use save_Log_duration so setting Log_duration to true doesn't
- * report incorrect time because gettimeofday() wasn't called.
+ * We use save_Log_duration so setting Log_duration to true doesn't
+ * report incorrect time because gettimeofday() wasn't called.
*/
if (save_Log_duration)
gettimeofday(&start_t, &tz);
@@ -627,9 +629,9 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */
isTransactionStmt = IsA(parsetree, TransactionStmt);
/*
- * First we set the command-completion tag to the main query
- * (as opposed to each of the others that may be generated by
- * analyze and rewrite). Also set ps_status and do any special
+ * First we set the command-completion tag to the main query (as
+ * opposed to each of the others that may be generated by analyze
+ * and rewrite). Also set ps_status and do any special
* start-of-SQL-command processing needed by the destination.
*/
commandTag = CreateCommandTag(parsetree);
@@ -807,15 +809,16 @@ 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
- * transaction statement before reporting command-complete. This is
- * so that any end-of-transaction errors are reported before the
- * command-complete message is issued, to avoid confusing clients
- * who will expect either a command-complete message or an error,
- * not one and then the other. But for compatibility with
+ * transaction statement before reporting command-complete. This
+ * is so that any end-of-transaction errors are reported before
+ * the command-complete message is issued, to avoid confusing
+ * clients who will expect either a command-complete message or an
+ * error, not one and then the other. But for compatibility with
* historical Postgres behavior, we do not force a transaction
* boundary between queries appearing in a single query string.
*/
@@ -826,12 +829,11 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */
}
/*
- * It is possible that the original query was removed due to
- * a DO INSTEAD rewrite rule. In that case we will still have
- * the default completion tag, which is fine for most purposes,
- * but it may confuse clients if it's INSERT/UPDATE/DELETE.
- * Clients expect those tags to have counts after them (cf.
- * ProcessQuery).
+ * It is possible that the original query was removed due to a DO
+ * INSTEAD rewrite rule. In that case we will still have the
+ * default completion tag, which is fine for most purposes, but it
+ * may confuse clients if it's INSERT/UPDATE/DELETE. Clients
+ * expect those tags to have counts after them (cf. ProcessQuery).
*/
if (strcmp(commandTag, "INSERT") == 0)
commandTag = "INSERT 0 0";
@@ -842,10 +844,10 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */
/*
* Tell client that we're done with this query. Note we emit
- * exactly one EndCommand report for each raw parsetree, thus
- * one for each SQL command the client sent, regardless of
- * rewriting. (But a command aborted by error will not send
- * an EndCommand report at all.)
+ * exactly one EndCommand report for each raw parsetree, thus one
+ * for each SQL command the client sent, regardless of rewriting.
+ * (But a command aborted by error will not send an EndCommand
+ * report at all.)
*/
EndCommand(commandTag, dest);
} /* end loop over parsetrees */
@@ -853,8 +855,8 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */
disable_sig_alarm(true);
/*
- * Close down transaction statement, if one is open.
- * (Note that this will only happen if the querystring was empty.)
+ * Close down transaction statement, if one is open. (Note that this
+ * will only happen if the querystring was empty.)
*/
if (xact_started)
finish_xact_command();
@@ -868,8 +870,8 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */
stop_t.tv_usec += 1000000;
}
elog(LOG, "duration: %ld.%06ld sec",
- (long int) stop_t.tv_sec - start_t.tv_sec,
- (long int) stop_t.tv_usec - start_t.tv_usec);
+ (long int) stop_t.tv_sec - start_t.tv_sec,
+ (long int) stop_t.tv_usec - start_t.tv_usec);
}
debug_query_string = NULL;
@@ -1165,9 +1167,7 @@ PostgresMain(int argc, char *argv[], const char *username)
* If we are running under the postmaster, this is done already.
*/
if (!IsUnderPostmaster)
- {
MemoryContextInit();
- }
set_ps_display("startup");
@@ -1244,14 +1244,16 @@ PostgresMain(int argc, char *argv[], const char *username)
/* Set server debugging level. */
if (atoi(optarg) != 0)
{
- char *debugstr = palloc(strlen("debug") + strlen(optarg) + 1);
+ char *debugstr = palloc(strlen("debug") + strlen(optarg) + 1);
sprintf(debugstr, "debug%s", optarg);
SetConfigOption("server_min_messages", debugstr, ctx, gucsource);
pfree(debugstr);
+
/*
- * -d is not the same as setting client_min_messages
- * because it enables other output options.
+ * -d is not the same as setting
+ * client_min_messages because it enables other
+ * output options.
*/
if (atoi(optarg) >= 1)
SetConfigOption("log_connections", "true", ctx, gucsource);
@@ -1265,9 +1267,10 @@ PostgresMain(int argc, char *argv[], const char *username)
SetConfigOption("debug_print_rewritten", "true", ctx, gucsource);
}
else
+
/*
- * -d 0 allows user to prevent postmaster debug from
- * propagating to backend.
+ * -d 0 allows user to prevent postmaster debug
+ * from propagating to backend.
*/
SetConfigOption("server_min_messages", "notice",
ctx, gucsource);
@@ -1543,17 +1546,17 @@ PostgresMain(int argc, char *argv[], const char *username)
* Also note: it's best not to use any signals that are SIG_IGNored in
* the postmaster. If such a signal arrives before we are able to
* change the handler to non-SIG_IGN, it'll get dropped. Instead,
- * make a dummy handler in the postmaster to reserve the signal.
- * (Of course, this isn't an issue for signals that are locally generated,
+ * make a dummy handler in the postmaster to reserve the signal. (Of
+ * course, this isn't an issue for signals that are locally generated,
* such as SIGALRM and SIGPIPE.)
*/
pqsignal(SIGHUP, SigHupHandler); /* set flag to read config file */
- pqsignal(SIGINT, StatementCancelHandler); /* 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, handle_sig_alarm); /* check for deadlock after
- * timeout */
+ pqsignal(SIGALRM, handle_sig_alarm); /* check for deadlock
+ * after timeout */
/*
* Ignore failure to write to frontend. Note: if frontend closes
@@ -1686,7 +1689,7 @@ PostgresMain(int argc, char *argv[], const char *username)
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
- puts("$Revision: 1.290 $ $Date: 2002/09/02 05:25:37 $\n");
+ puts("$Revision: 1.291 $ $Date: 2002/09/04 20:31:26 $\n");
}
/*
@@ -1873,9 +1876,10 @@ PostgresMain(int argc, char *argv[], const char *username)
if (HandleFunctionRequest() == EOF)
{
/* lost frontend connection during F message input */
+
/*
- * Reset whereToSendOutput to prevent elog from attempting
- * to send any more messages to client.
+ * Reset whereToSendOutput to prevent elog from
+ * attempting to send any more messages to client.
*/
if (whereToSendOutput == Remote)
whereToSendOutput = None;
@@ -1924,12 +1928,13 @@ PostgresMain(int argc, char *argv[], const char *username)
break;
/*
- * 'X' means that the frontend is closing down the socket.
- * EOF means unexpected loss of frontend connection.
- * Either way, perform normal shutdown.
+ * 'X' means that the frontend is closing down the socket.
+ * EOF means unexpected loss of frontend connection.
+ * Either way, perform normal shutdown.
*/
case 'X':
case EOF:
+
/*
* Reset whereToSendOutput to prevent elog from attempting
* to send any more messages to client.
@@ -1995,7 +2000,7 @@ ShowUsage(const char *title)
struct timeval elapse_t;
struct timezone tz;
struct rusage r;
- char *bufusage;
+ char *bufusage;
getrusage(RUSAGE_SELF, &r);
gettimeofday(&elapse_t, &tz);
@@ -2030,45 +2035,45 @@ ShowUsage(const char *title)
appendStringInfo(&str, "! system usage stats:\n");
appendStringInfo(&str,
"!\t%ld.%06ld elapsed %ld.%06ld user %ld.%06ld system sec\n",
- (long int) elapse_t.tv_sec - Save_t.tv_sec,
- (long int) elapse_t.tv_usec - Save_t.tv_usec,
- (long int) r.ru_utime.tv_sec - Save_r.ru_utime.tv_sec,
- (long int) r.ru_utime.tv_usec - Save_r.ru_utime.tv_usec,
- (long int) r.ru_stime.tv_sec - Save_r.ru_stime.tv_sec,
- (long int) r.ru_stime.tv_usec - Save_r.ru_stime.tv_usec);
+ (long int) elapse_t.tv_sec - Save_t.tv_sec,
+ (long int) elapse_t.tv_usec - Save_t.tv_usec,
+ (long int) r.ru_utime.tv_sec - Save_r.ru_utime.tv_sec,
+ (long int) r.ru_utime.tv_usec - Save_r.ru_utime.tv_usec,
+ (long int) r.ru_stime.tv_sec - Save_r.ru_stime.tv_sec,
+ (long int) r.ru_stime.tv_usec - Save_r.ru_stime.tv_usec);
appendStringInfo(&str,
- "!\t[%ld.%06ld user %ld.%06ld sys total]\n",
- (long int) user.tv_sec,
- (long int) user.tv_usec,
- (long int) sys.tv_sec,
- (long int) sys.tv_usec);
+ "!\t[%ld.%06ld user %ld.%06ld sys total]\n",
+ (long int) user.tv_sec,
+ (long int) user.tv_usec,
+ (long int) sys.tv_sec,
+ (long int) sys.tv_usec);
/* BeOS has rusage but only has some fields, and not these... */
#if defined(HAVE_GETRUSAGE)
appendStringInfo(&str,
- "!\t%ld/%ld [%ld/%ld] filesystem blocks in/out\n",
- r.ru_inblock - Save_r.ru_inblock,
+ "!\t%ld/%ld [%ld/%ld] filesystem blocks in/out\n",
+ r.ru_inblock - Save_r.ru_inblock,
/* they only drink coffee at dec */
- r.ru_oublock - Save_r.ru_oublock,
- r.ru_inblock, r.ru_oublock);
+ r.ru_oublock - Save_r.ru_oublock,
+ r.ru_inblock, r.ru_oublock);
appendStringInfo(&str,
"!\t%ld/%ld [%ld/%ld] page faults/reclaims, %ld [%ld] swaps\n",
- r.ru_majflt - Save_r.ru_majflt,
- r.ru_minflt - Save_r.ru_minflt,
- r.ru_majflt, r.ru_minflt,
- r.ru_nswap - Save_r.ru_nswap,
- r.ru_nswap);
+ r.ru_majflt - Save_r.ru_majflt,
+ r.ru_minflt - Save_r.ru_minflt,
+ r.ru_majflt, r.ru_minflt,
+ r.ru_nswap - Save_r.ru_nswap,
+ r.ru_nswap);
appendStringInfo(&str,
"!\t%ld [%ld] signals rcvd, %ld/%ld [%ld/%ld] messages rcvd/sent\n",
- r.ru_nsignals - Save_r.ru_nsignals,
- r.ru_nsignals,
- r.ru_msgrcv - Save_r.ru_msgrcv,
- r.ru_msgsnd - Save_r.ru_msgsnd,
- r.ru_msgrcv, r.ru_msgsnd);
+ r.ru_nsignals - Save_r.ru_nsignals,
+ r.ru_nsignals,
+ r.ru_msgrcv - Save_r.ru_msgrcv,
+ r.ru_msgsnd - Save_r.ru_msgsnd,
+ r.ru_msgrcv, r.ru_msgsnd);
appendStringInfo(&str,
"!\t%ld/%ld [%ld/%ld] voluntary/involuntary context switches\n",
- r.ru_nvcsw - Save_r.ru_nvcsw,
- r.ru_nivcsw - Save_r.ru_nivcsw,
- r.ru_nvcsw, r.ru_nivcsw);
+ r.ru_nvcsw - Save_r.ru_nvcsw,
+ r.ru_nivcsw - Save_r.ru_nivcsw,
+ r.ru_nvcsw, r.ru_nivcsw);
#endif /* HAVE_GETRUSAGE */
bufusage = ShowBufferUsage();
@@ -2076,7 +2081,7 @@ ShowUsage(const char *title)
pfree(bufusage);
/* remove trailing newline */
- if (str.data[str.len-1] == '\n')
+ if (str.data[str.len - 1] == '\n')
str.data[--str.len] = '\0';
elog(LOG, "%s\n%s", title, str.data);
@@ -2094,7 +2099,7 @@ ShowUsage(const char *title)
static const char *
CreateCommandTag(Node *parsetree)
{
- const char *tag;
+ const char *tag;
switch (nodeTag(parsetree))
{
@@ -2150,6 +2155,7 @@ CreateCommandTag(Node *parsetree)
case T_FetchStmt:
{
FetchStmt *stmt = (FetchStmt *) parsetree;
+
tag = (stmt->ismove) ? "MOVE" : "FETCH";
}
break;
@@ -2211,7 +2217,7 @@ CreateCommandTag(Node *parsetree)
break;
case T_RenameStmt:
- if (((RenameStmt *)parsetree)->renameType == RENAME_TRIGGER)
+ if (((RenameStmt *) parsetree)->renameType == RENAME_TRIGGER)
tag = "ALTER TRIGGER";
else
tag = "ALTER TABLE";
@@ -2224,6 +2230,7 @@ CreateCommandTag(Node *parsetree)
case T_GrantStmt:
{
GrantStmt *stmt = (GrantStmt *) parsetree;
+
tag = (stmt->is_grant) ? "GRANT" : "REVOKE";
}
break;