aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tcop
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/tcop')
-rw-r--r--src/backend/tcop/dest.c7
-rw-r--r--src/backend/tcop/fastpath.c43
-rw-r--r--src/backend/tcop/postgres.c644
-rw-r--r--src/backend/tcop/pquery.c220
-rw-r--r--src/backend/tcop/utility.c92
5 files changed, 488 insertions, 518 deletions
diff --git a/src/backend/tcop/dest.c b/src/backend/tcop/dest.c
index 2b60c2c46e3..da164ecd0b7 100644
--- a/src/backend/tcop/dest.c
+++ b/src/backend/tcop/dest.c
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/dest.c,v 1.65 2005/03/16 21:38:08 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/dest.c,v 1.66 2005/10/15 02:49:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -173,9 +173,8 @@ NullCommand(CommandDest dest)
case RemoteExecute:
/*
- * tell the fe that we saw an empty query string. In
- * protocols before 3.0 this has a useless empty-string
- * message body.
+ * tell the fe that we saw an empty query string. In protocols
+ * before 3.0 this has a useless empty-string message body.
*/
if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 3)
pq_putemptymessage('I');
diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c
index fa105c560e0..7c7de52e57a 100644
--- a/src/backend/tcop/fastpath.c
+++ b/src/backend/tcop/fastpath.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.82 2005/09/24 17:53:15 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.83 2005/10/15 02:49:26 momjian Exp $
*
* NOTES
* This cruft is the server side of PQfn.
@@ -103,8 +103,8 @@ GetOldFunctionMessage(StringInfo buf)
/* FATAL here since no hope of regaining message sync */
ereport(FATAL,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("invalid argument size %d in function call message",
- argsize)));
+ errmsg("invalid argument size %d in function call message",
+ argsize)));
}
/* and arg contents */
if (argsize > 0)
@@ -204,11 +204,10 @@ fetch_fp_info(Oid func_id, struct fp_info * fip)
/*
* Since the validity of this structure is determined by whether the
* funcid is OK, we clear the funcid here. It must not be set to the
- * correct value until we are about to return with a good struct
- * fp_info, since we can be interrupted (i.e., with an ereport(ERROR,
- * ...)) at any time. [No longer really an issue since we don't save
- * the struct fp_info across transactions anymore, but keep it
- * anyway.]
+ * correct value until we are about to return with a good struct fp_info,
+ * since we can be interrupted (i.e., with an ereport(ERROR, ...)) at any
+ * time. [No longer really an issue since we don't save the struct
+ * fp_info across transactions anymore, but keep it anyway.]
*/
MemSet(fip, 0, sizeof(struct fp_info));
fip->funcid = InvalidOid;
@@ -294,14 +293,14 @@ HandleFunctionRequest(StringInfo msgBuf)
/*
* Now that we've eaten the input message, check to see if we actually
- * want to do the function call or not. It's now safe to ereport();
- * we won't lose sync with the frontend.
+ * want to do the function call or not. It's now safe to ereport(); we
+ * won't lose sync with the frontend.
*/
if (IsAbortedTransactionBlockState())
ereport(ERROR,
(errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
errmsg("current transaction is aborted, "
- "commands ignored until end of transaction block")));
+ "commands ignored until end of transaction block")));
/*
* Begin parsing the buffer contents.
@@ -440,8 +439,8 @@ parse_fcall_arguments(StringInfo msgBuf, struct fp_info * fip,
if (argsize < 0)
ereport(ERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("invalid argument size %d in function call message",
- argsize)));
+ errmsg("invalid argument size %d in function call message",
+ argsize)));
/* Reset abuf to empty, and insert raw data into it */
abuf.len = 0;
@@ -500,8 +499,8 @@ parse_fcall_arguments(StringInfo msgBuf, struct fp_info * fip,
if (abuf.cursor != abuf.len)
ereport(ERROR,
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
- errmsg("incorrect binary data format in function argument %d",
- i + 1)));
+ errmsg("incorrect binary data format in function argument %d",
+ i + 1)));
}
else
ereport(ERROR,
@@ -543,9 +542,9 @@ parse_fcall_arguments_20(StringInfo msgBuf, struct fp_info * fip,
* Copy supplied arguments into arg vector. In protocol 2.0 these are
* always assumed to be supplied in binary format.
*
- * Note: although the original protocol 2.0 code did not have any way for
- * the frontend to specify a NULL argument, we now choose to interpret
- * length == -1 as meaning a NULL.
+ * Note: although the original protocol 2.0 code did not have any way for the
+ * frontend to specify a NULL argument, we now choose to interpret length
+ * == -1 as meaning a NULL.
*/
for (i = 0; i < nargs; ++i)
{
@@ -563,8 +562,8 @@ parse_fcall_arguments_20(StringInfo msgBuf, struct fp_info * fip,
if (argsize < 0)
ereport(ERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("invalid argument size %d in function call message",
- argsize)));
+ errmsg("invalid argument size %d in function call message",
+ argsize)));
/* Reset abuf to empty, and insert raw data into it */
abuf.len = 0;
@@ -587,8 +586,8 @@ parse_fcall_arguments_20(StringInfo msgBuf, struct fp_info * fip,
if (abuf.cursor != abuf.len)
ereport(ERROR,
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
- errmsg("incorrect binary data format in function argument %d",
- i + 1)));
+ errmsg("incorrect binary data format in function argument %d",
+ i + 1)));
}
/* Desired result format is always binary in protocol 2.0 */
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 8b722c2e015..93bcc936602 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.465 2005/10/13 22:57:27 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.466 2005/10/15 02:49:27 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@@ -71,8 +71,7 @@ extern char *optarg;
* global variables
* ----------------
*/
-const char *debug_query_string; /* for pgmonitor and
- * log_min_error_statement */
+const char *debug_query_string; /* for pgmonitor and log_min_error_statement */
/* Note: whereToSendOutput is initialized for the bootstrap/standalone case */
CommandDest whereToSendOutput = Debug;
@@ -96,7 +95,7 @@ static int max_stack_depth_bytes = 2048 * 1024;
/* stack base pointer (initialized by PostgresMain) */
/* Do not make static so PL/Java can modifiy it */
-char *stack_base_ptr = NULL;
+char *stack_base_ptr = NULL;
/*
@@ -142,9 +141,7 @@ static bool EchoQuery = false; /* default don't echo */
* tcop/tcopdebug.h
*/
#ifndef TCOP_DONTUSENEWLINE
-static int UseNewLine = 1; /* Use newlines query delimiters (the
- * default) */
-
+static int UseNewLine = 1; /* Use newlines query delimiters (the default) */
#else
static int UseNewLine = 0; /* Use EOF as query delimiters */
#endif /* TCOP_DONTUSENEWLINE */
@@ -204,8 +201,8 @@ InteractiveBackend(StringInfo inBuf)
if (UseNewLine)
{
/*
- * if we are using \n as a delimiter, then read characters
- * until the \n.
+ * if we are using \n as a delimiter, then read characters until
+ * the \n.
*/
while ((c = getc(stdin)) != EOF)
{
@@ -297,12 +294,12 @@ SocketBackend(StringInfo inBuf)
}
/*
- * Validate message type code before trying to read body; if we have
- * lost sync, better to say "command unknown" than to run out of
- * memory because we used garbage as a length word.
+ * Validate message type code before trying to read body; if we have lost
+ * sync, better to say "command unknown" than to run out of memory because
+ * we used garbage as a length word.
*
- * This also gives us a place to set the doing_extended_query_message
- * flag as soon as possible.
+ * This also gives us a place to set the doing_extended_query_message flag as
+ * soon as possible.
*/
switch (qtype)
{
@@ -315,7 +312,7 @@ SocketBackend(StringInfo inBuf)
{
ereport(COMMERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("unexpected EOF on client connection")));
+ errmsg("unexpected EOF on client connection")));
return EOF;
}
}
@@ -342,7 +339,7 @@ SocketBackend(StringInfo inBuf)
if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3)
ereport(FATAL,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("invalid frontend message type %d", qtype)));
+ errmsg("invalid frontend message type %d", qtype)));
break;
case 'S': /* sync */
@@ -354,7 +351,7 @@ SocketBackend(StringInfo inBuf)
if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3)
ereport(FATAL,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("invalid frontend message type %d", qtype)));
+ errmsg("invalid frontend message type %d", qtype)));
break;
case 'd': /* copy data */
@@ -365,15 +362,15 @@ SocketBackend(StringInfo inBuf)
if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3)
ereport(FATAL,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("invalid frontend message type %d", qtype)));
+ errmsg("invalid frontend message type %d", qtype)));
break;
default:
/*
- * Otherwise we got garbage from the frontend. We treat this
- * as fatal because we have probably lost message boundary
- * sync, and there's no good way to recover.
+ * Otherwise we got garbage from the frontend. We treat this as
+ * fatal because we have probably lost message boundary sync, and
+ * there's no good way to recover.
*/
ereport(FATAL,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
@@ -382,9 +379,9 @@ SocketBackend(StringInfo inBuf)
}
/*
- * In protocol version 3, all frontend messages have a length word
- * next after the type code; we can read the message contents
- * independently of the type.
+ * In protocol version 3, all frontend messages have a length word next
+ * after the type code; we can read the message contents independently of
+ * the type.
*/
if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 3)
{
@@ -532,14 +529,14 @@ pg_parse_query(const char *query_string)
static bool
log_after_parse(List *raw_parsetree_list, const char *query_string,
- char **prepare_string)
+ char **prepare_string)
{
ListCell *parsetree_item;
bool log_this_statement = (log_statement == LOGSTMT_ALL);
*prepare_string = NULL;
- /* Check if we need to log the statement, and get prepare_string. */
+ /* Check if we need to log the statement, and get prepare_string. */
foreach(parsetree_item, raw_parsetree_list)
{
Node *parsetree = (Node *) lfirst(parsetree_item);
@@ -554,7 +551,7 @@ log_after_parse(List *raw_parsetree_list, const char *query_string,
if (IsA(parsetree, SelectStmt) &&
((SelectStmt *) parsetree)->into == NULL)
- continue; /* optimization for frequent command */
+ continue; /* optimization for frequent command */
if (log_statement == LOGSTMT_MOD &&
(IsA(parsetree, InsertStmt) ||
@@ -562,23 +559,23 @@ log_after_parse(List *raw_parsetree_list, const char *query_string,
IsA(parsetree, DeleteStmt) ||
IsA(parsetree, TruncateStmt) ||
(IsA(parsetree, CopyStmt) &&
- ((CopyStmt *) parsetree)->is_from))) /* COPY FROM */
+ ((CopyStmt *) parsetree)->is_from))) /* COPY FROM */
log_this_statement = true;
commandTag = CreateCommandTag(parsetree);
if ((log_statement == LOGSTMT_MOD ||
log_statement == LOGSTMT_DDL) &&
(strncmp(commandTag, "CREATE ", strlen("CREATE ")) == 0 ||
- IsA(parsetree, SelectStmt) || /* SELECT INTO, CREATE AS */
+ IsA(parsetree, SelectStmt) || /* SELECT INTO, CREATE AS */
strncmp(commandTag, "ALTER ", strlen("ALTER ")) == 0 ||
strncmp(commandTag, "DROP ", strlen("DROP ")) == 0 ||
- IsA(parsetree, GrantStmt) || /* GRANT or REVOKE */
+ IsA(parsetree, GrantStmt) || /* GRANT or REVOKE */
IsA(parsetree, CommentStmt)))
log_this_statement = true;
/*
- * For the first EXECUTE we find, record the client statement
- * used by the PREPARE.
+ * For the first EXECUTE we find, record the client statement used by
+ * the PREPARE.
*/
if (IsA(parsetree, ExecuteStmt))
{
@@ -589,13 +586,13 @@ log_after_parse(List *raw_parsetree_list, const char *query_string,
entry->query_string)
{
*prepare_string = palloc(strlen(entry->query_string) +
- strlen(" [client PREPARE: %s]") - 1);
+ strlen(" [client PREPARE: %s]") - 1);
sprintf(*prepare_string, " [client PREPARE: %s]",
- entry->query_string);
+ entry->query_string);
}
}
}
-
+
if (log_this_statement)
{
ereport(LOG,
@@ -657,8 +654,8 @@ pg_rewrite_queries(List *querytree_list)
ResetUsage();
/*
- * rewritten queries are collected in new_list. Note there may be
- * more or fewer than in the original list.
+ * rewritten queries are collected in new_list. Note there may be more or
+ * fewer than in the original list.
*/
foreach(list_item, querytree_list)
{
@@ -690,8 +687,7 @@ pg_rewrite_queries(List *querytree_list)
#ifdef COPY_PARSE_PLAN_TREES
/*
- * Optional debugging check: pass querytree output through
- * copyObject()
+ * Optional debugging check: pass querytree output through copyObject()
*/
new_list = (List *) copyObject(querytree_list);
/* This checks both copyObject() and the equal() routines... */
@@ -734,8 +730,8 @@ pg_plan_query(Query *querytree, ParamListInfo boundParams)
Plan *new_plan = (Plan *) copyObject(plan);
/*
- * equal() currently does not have routines to compare Plan nodes,
- * so don't try to test equality here. Perhaps fix someday?
+ * equal() currently does not have routines to compare Plan nodes, so
+ * don't try to test equality here. Perhaps fix someday?
*/
#ifdef NOT_USED
/* This checks both copyObject() and the equal() routines... */
@@ -813,13 +809,14 @@ exec_simple_query(const char *query_string)
MemoryContext oldcontext;
List *parsetree_list;
ListCell *parsetree_item;
- struct timeval start_t, stop_t;
+ struct timeval start_t,
+ stop_t;
bool save_log_duration = log_duration;
int save_log_min_duration_statement = log_min_duration_statement;
bool save_log_statement_stats = log_statement_stats;
- char *prepare_string = NULL;
+ char *prepare_string = NULL;
bool was_logged = false;
-
+
/*
* Report query to various monitoring facilities.
*/
@@ -829,9 +826,9 @@ exec_simple_query(const char *query_string)
/*
* We use save_log_* so "SET log_duration = true" and "SET
- * log_min_duration_statement = true" don't report incorrect time
- * because gettimeofday() wasn't called. Similarly,
- * log_statement_stats has to be captured once.
+ * log_min_duration_statement = true" don't report incorrect time because
+ * gettimeofday() wasn't called. Similarly, log_statement_stats has to be
+ * captured once.
*/
if (save_log_duration || save_log_min_duration_statement != -1)
gettimeofday(&start_t, NULL);
@@ -842,17 +839,17 @@ exec_simple_query(const char *query_string)
/*
* Start up a transaction command. All queries generated by the
* query_string will be in this same command block, *unless* we find a
- * BEGIN/COMMIT/ABORT statement; we have to force a new xact command
- * after one of those, else bad things will happen in xact.c. (Note
- * that this will normally change current memory context.)
+ * BEGIN/COMMIT/ABORT statement; we have to force a new xact command after
+ * one of those, else bad things will happen in xact.c. (Note that this
+ * will normally change current memory context.)
*/
start_xact_command();
/*
- * Zap any pre-existing unnamed statement. (While not strictly
- * necessary, it seems best to define simple-Query mode as if it used
- * the unnamed statement and portal; this ensures we recover any
- * storage used by prior unnamed operations.)
+ * Zap any pre-existing unnamed statement. (While not strictly necessary,
+ * it seems best to define simple-Query mode as if it used the unnamed
+ * statement and portal; this ensures we recover any storage used by prior
+ * unnamed operations.)
*/
unnamed_stmt_pstmt = NULL;
if (unnamed_stmt_context)
@@ -870,14 +867,14 @@ exec_simple_query(const char *query_string)
QueryContext = CurrentMemoryContext;
/*
- * Do basic parsing of the query or queries (this should be safe even
- * if we are in aborted transaction state!)
+ * Do basic parsing of the query or queries (this should be safe even if
+ * we are in aborted transaction state!)
*/
parsetree_list = pg_parse_query(query_string);
if (log_statement != LOGSTMT_NONE || save_log_min_duration_statement != -1)
was_logged = log_after_parse(parsetree_list, query_string,
- &prepare_string);
+ &prepare_string);
/*
* Switch back to transaction context to enter the loop.
@@ -899,10 +896,10 @@ exec_simple_query(const char *query_string)
int16 format;
/*
- * Get the command name for use in status display (it also becomes
- * the default completion tag, down inside PortalRun). Set
- * ps_status and do any special start-of-SQL-command processing
- * needed by the destination.
+ * Get the command name for use in status display (it also becomes the
+ * default completion tag, down inside PortalRun). Set ps_status and
+ * do any special start-of-SQL-command processing needed by the
+ * destination.
*/
commandTag = CreateCommandTag(parsetree);
@@ -912,11 +909,11 @@ exec_simple_query(const char *query_string)
/*
* If we are in an aborted transaction, reject all commands except
- * COMMIT/ABORT. It is important that this test occur before we
- * try to do parse analysis, rewrite, or planning, since all those
- * phases try to do database accesses, which may fail in abort
- * state. (It might be safe to allow some additional utility
- * commands in this state, but not many...)
+ * COMMIT/ABORT. It is important that this test occur before we try
+ * to do parse analysis, rewrite, or planning, since all those phases
+ * try to do database accesses, which may fail in abort state. (It
+ * might be safe to allow some additional utility commands in this
+ * state, but not many...)
*/
if (IsAbortedTransactionBlockState())
{
@@ -937,7 +934,7 @@ exec_simple_query(const char *query_string)
ereport(ERROR,
(errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
errmsg("current transaction is aborted, "
- "commands ignored until end of transaction block")));
+ "commands ignored until end of transaction block")));
}
/* Make sure we are in a transaction command */
@@ -980,10 +977,10 @@ exec_simple_query(const char *query_string)
PortalStart(portal, NULL, InvalidSnapshot);
/*
- * Select the appropriate output format: text unless we are doing
- * a FETCH from a binary cursor. (Pretty grotty to have to do
- * this here --- but it avoids grottiness in other places. Ah,
- * the joys of backward compatibility...)
+ * Select the appropriate output format: text unless we are doing a
+ * FETCH from a binary cursor. (Pretty grotty to have to do this here
+ * --- but it avoids grottiness in other places. Ah, the joys of
+ * backward compatibility...)
*/
format = 0; /* TEXT is default */
if (IsA(parsetree, FetchStmt))
@@ -1012,8 +1009,7 @@ exec_simple_query(const char *query_string)
MemoryContextSwitchTo(oldcontext);
/*
- * Run the portal to completion, and then drop it (and the
- * receiver).
+ * Run the portal to completion, and then drop it (and the receiver).
*/
(void) PortalRun(portal,
FETCH_ALL,
@@ -1028,24 +1024,22 @@ exec_simple_query(const char *query_string)
if (IsA(parsetree, TransactionStmt))
{
/*
- * If this was a transaction control statement, commit it. We
- * will start a new xact command for the next command (if
- * any).
+ * If this was a transaction control statement, commit it. We will
+ * start a new xact command for the next command (if any).
*/
finish_xact_command();
}
else if (lnext(parsetree_item) == NULL)
{
/*
- * 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 historical Postgres
- * behavior, we do not force a transaction boundary between
- * queries appearing in a single query string.
+ * 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
+ * historical Postgres behavior, we do not force a transaction
+ * boundary between queries appearing in a single query string.
*/
finish_xact_command();
}
@@ -1059,11 +1053,10 @@ exec_simple_query(const char *query_string)
}
/*
- * 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.)
+ * 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.)
*/
EndCommand(completionTag, dest);
} /* end loop over parsetrees */
@@ -1082,8 +1075,8 @@ exec_simple_query(const char *query_string)
QueryContext = NULL;
/*
- * Combine processing here as we need to calculate the query duration
- * in both instances.
+ * Combine processing here as we need to calculate the query duration in
+ * both instances.
*/
if (save_log_duration || save_log_min_duration_statement != -1)
{
@@ -1096,28 +1089,28 @@ exec_simple_query(const char *query_string)
stop_t.tv_usec += 1000000;
}
usecs = (long) (stop_t.tv_sec - start_t.tv_sec) * 1000000 +
- (long) (stop_t.tv_usec - start_t.tv_usec);
+ (long) (stop_t.tv_usec - start_t.tv_usec);
/* Only print duration if we previously printed the statement. */
if (was_logged && save_log_duration)
ereport(LOG,
(errmsg("duration: %ld.%03ld ms",
- (long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 +
- (stop_t.tv_usec - start_t.tv_usec) / 1000),
- (long) (stop_t.tv_usec - start_t.tv_usec) % 1000)));
+ (long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 +
+ (stop_t.tv_usec - start_t.tv_usec) / 1000),
+ (long) (stop_t.tv_usec - start_t.tv_usec) % 1000)));
/*
- * Output a duration_statement to the log if the query has
- * exceeded the min duration, or if we are to print all durations.
+ * Output a duration_statement to the log if the query has exceeded
+ * the min duration, or if we are to print all durations.
*/
if (save_log_min_duration_statement == 0 ||
(save_log_min_duration_statement > 0 &&
usecs >= save_log_min_duration_statement * 1000))
ereport(LOG,
(errmsg("duration: %ld.%03ld ms statement: %s%s",
- (long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 +
- (stop_t.tv_usec - start_t.tv_usec) / 1000),
- (long) (stop_t.tv_usec - start_t.tv_usec) % 1000,
+ (long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 +
+ (stop_t.tv_usec - start_t.tv_usec) / 1000),
+ (long) (stop_t.tv_usec - start_t.tv_usec) % 1000,
query_string,
prepare_string ? prepare_string : "")));
}
@@ -1170,9 +1163,9 @@ exec_parse_message(const char *query_string, /* string to execute */
query_string)));
/*
- * Start up a transaction command so we can run parse analysis etc.
- * (Note that this will normally change current memory context.)
- * Nothing happens if we are already in one.
+ * Start up a transaction command so we can run parse analysis etc. (Note
+ * that this will normally change current memory context.) Nothing happens
+ * if we are already in one.
*/
start_xact_command();
@@ -1182,13 +1175,12 @@ exec_parse_message(const char *query_string, /* string to execute */
* We have two strategies depending on whether the prepared statement is
* named or not. For a named prepared statement, we do parsing in
* MessageContext and copy the finished trees into the prepared
- * statement's private context; then the reset of MessageContext
- * releases temporary space used by parsing and planning. For an
- * unnamed prepared statement, we assume the statement isn't going to
- * hang around long, so getting rid of temp space quickly is probably
- * not worth the costs of copying parse/plan trees. So in this case,
- * we set up a special context for the unnamed statement, and do all
- * the parsing/planning therein.
+ * statement's private context; then the reset of MessageContext releases
+ * temporary space used by parsing and planning. For an unnamed prepared
+ * statement, we assume the statement isn't going to hang around long, so
+ * getting rid of temp space quickly is probably not worth the costs of
+ * copying parse/plan trees. So in this case, we set up a special context
+ * for the unnamed statement, and do all the parsing/planning therein.
*/
is_named = (stmt_name[0] != '\0');
if (is_named)
@@ -1219,20 +1211,20 @@ exec_parse_message(const char *query_string, /* string to execute */
QueryContext = CurrentMemoryContext;
/*
- * Do basic parsing of the query or queries (this should be safe even
- * if we are in aborted transaction state!)
+ * Do basic parsing of the query or queries (this should be safe even if
+ * we are in aborted transaction state!)
*/
parsetree_list = pg_parse_query(query_string);
/*
- * We only allow a single user statement in a prepared statement. This
- * is mainly to keep the protocol simple --- otherwise we'd need to
- * worry about multiple result tupdescs and things like that.
+ * We only allow a single user statement in a prepared statement. This is
+ * mainly to keep the protocol simple --- otherwise we'd need to worry
+ * about multiple result tupdescs and things like that.
*/
if (list_length(parsetree_list) > 1)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("cannot insert multiple commands into a prepared statement")));
+ errmsg("cannot insert multiple commands into a prepared statement")));
if (parsetree_list != NIL)
{
@@ -1246,11 +1238,11 @@ exec_parse_message(const char *query_string, /* string to execute */
/*
* If we are in an aborted transaction, reject all commands except
- * COMMIT/ROLLBACK. It is important that this test occur before
- * we try to do parse analysis, rewrite, or planning, since all
- * those phases try to do database accesses, which may fail in
- * abort state. (It might be safe to allow some additional utility
- * commands in this state, but not many...)
+ * COMMIT/ROLLBACK. It is important that this test occur before we
+ * try to do parse analysis, rewrite, or planning, since all those
+ * phases try to do database accesses, which may fail in abort state.
+ * (It might be safe to allow some additional utility commands in this
+ * state, but not many...)
*/
if (IsAbortedTransactionBlockState())
{
@@ -1271,13 +1263,13 @@ exec_parse_message(const char *query_string, /* string to execute */
ereport(ERROR,
(errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
errmsg("current transaction is aborted, "
- "commands ignored until end of transaction block")));
+ "commands ignored until end of transaction block")));
}
/*
* OK to analyze, rewrite, and plan this query. Note that the
- * originally specified parameter set is not required to be
- * complete, so we have to use parse_analyze_varparams().
+ * originally specified parameter set is not required to be complete,
+ * so we have to use parse_analyze_varparams().
*/
if (log_parser_stats)
ResetUsage();
@@ -1298,8 +1290,8 @@ exec_parse_message(const char *query_string, /* string to execute */
if (ptype == InvalidOid || ptype == UNKNOWNOID)
ereport(ERROR,
(errcode(ERRCODE_INDETERMINATE_DATATYPE),
- errmsg("could not determine data type of parameter $%d",
- i + 1)));
+ errmsg("could not determine data type of parameter $%d",
+ i + 1)));
param_list = lappend_oid(param_list, ptype);
}
@@ -1309,8 +1301,8 @@ exec_parse_message(const char *query_string, /* string to execute */
querytree_list = pg_rewrite_queries(querytree_list);
/*
- * If this is the unnamed statement and it has parameters, defer
- * query planning until Bind. Otherwise do it now.
+ * If this is the unnamed statement and it has parameters, defer query
+ * planning until Bind. Otherwise do it now.
*/
if (!is_named && numParams > 0)
plantree_list = NIL;
@@ -1363,10 +1355,9 @@ exec_parse_message(const char *query_string, /* string to execute */
QueryContext = NULL;
/*
- * We do NOT close the open transaction command here; that only
- * happens when the client sends Sync. Instead, do
- * CommandCounterIncrement just in case something happened during
- * parse/plan.
+ * We do NOT close the open transaction command here; that only happens
+ * when the client sends Sync. Instead, do CommandCounterIncrement just
+ * in case something happened during parse/plan.
*/
CommandCounterIncrement();
@@ -1408,9 +1399,9 @@ exec_bind_message(StringInfo input_message)
set_ps_display("BIND");
/*
- * Start up a transaction command so we can call functions etc. (Note
- * that this will normally change current memory context.) Nothing
- * happens if we are already in one.
+ * Start up a transaction command so we can call functions etc. (Note that
+ * this will normally change current memory context.) Nothing happens if
+ * we are already in one.
*/
start_xact_command();
@@ -1436,8 +1427,8 @@ exec_bind_message(StringInfo input_message)
if (numPFormats > 1 && numPFormats != numParams)
ereport(ERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("bind message has %d parameter formats but %d parameters",
- numPFormats, numParams)));
+ errmsg("bind message has %d parameter formats but %d parameters",
+ numPFormats, numParams)));
/* Find prepared statement */
if (stmt_name[0] != '\0')
@@ -1449,18 +1440,18 @@ exec_bind_message(StringInfo input_message)
if (!pstmt)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_PSTATEMENT),
- errmsg("unnamed prepared statement does not exist")));
+ errmsg("unnamed prepared statement does not exist")));
}
if (numParams != list_length(pstmt->argtype_list))
ereport(ERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
errmsg("bind message supplies %d parameters, but prepared statement \"%s\" requires %d",
- numParams, stmt_name, list_length(pstmt->argtype_list))));
+ numParams, stmt_name, list_length(pstmt->argtype_list))));
/*
- * Create the portal. Allow silent replacement of an existing portal
- * only if the unnamed portal is specified.
+ * Create the portal. Allow silent replacement of an existing portal only
+ * if the unnamed portal is specified.
*/
if (portal_name[0] == '\0')
portal = CreatePortal(portal_name, true, true);
@@ -1475,9 +1466,9 @@ exec_bind_message(StringInfo input_message)
/*
* Fetch parameters, if any, and store in the portal's memory context.
*
- * In an aborted transaction, we can't risk calling user-defined
- * functions, but we can't fail to Bind either, so bind all parameters
- * to null values.
+ * In an aborted transaction, we can't risk calling user-defined functions,
+ * but we can't fail to Bind either, so bind all parameters to null
+ * values.
*/
if (numParams > 0)
{
@@ -1522,13 +1513,13 @@ exec_bind_message(StringInfo input_message)
pformat = 0; /* default = text */
/*
- * Rather than copying data around, we just set up a
- * phony StringInfo pointing to the correct portion of
- * the message buffer. We assume we can scribble on
- * the message buffer so as to maintain the convention
- * that StringInfos have a trailing null. This is
- * grotty but is a big win when dealing with very
- * large parameter strings.
+ * Rather than copying data around, we just set up a phony
+ * StringInfo pointing to the correct portion of the
+ * message buffer. We assume we can scribble on the
+ * message buffer so as to maintain the convention that
+ * StringInfos have a trailing null. This is grotty but
+ * is a big win when dealing with very large parameter
+ * strings.
*/
pbuf.data = (char *) pvalue;
pbuf.maxlen = plength + 1;
@@ -1547,8 +1538,8 @@ exec_bind_message(StringInfo input_message)
getTypeInputInfo(ptype, &typinput, &typioparam);
/*
- * We have to do encoding conversion before
- * calling the typinput routine.
+ * We have to do encoding conversion before calling
+ * the typinput routine.
*/
pstring = pg_client_to_server(pbuf.data, plength);
params[i].value =
@@ -1566,8 +1557,7 @@ exec_bind_message(StringInfo input_message)
Oid typioparam;
/*
- * Call the parameter type's binary input
- * converter
+ * Call the parameter type's binary input converter
*/
getTypeBinaryInputInfo(ptype, &typreceive, &typioparam);
@@ -1580,9 +1570,9 @@ exec_bind_message(StringInfo input_message)
/* Trouble if it didn't eat the whole buffer */
if (pbuf.cursor != pbuf.len)
ereport(ERROR,
- (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
- errmsg("incorrect binary data format in bind parameter %d",
- i + 1)));
+ (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
+ errmsg("incorrect binary data format in bind parameter %d",
+ i + 1)));
}
else
{
@@ -1624,8 +1614,8 @@ exec_bind_message(StringInfo input_message)
pq_getmsgend(input_message);
/*
- * If we didn't plan the query before, do it now. This allows the
- * planner to make use of the concrete parameter values we now have.
+ * If we didn't plan the query before, do it now. This allows the planner
+ * to make use of the concrete parameter values we now have.
*
* This happens only for unnamed statements, and so switching into the
* statement context for planning is correct (see notes in
@@ -1679,7 +1669,8 @@ exec_execute_message(const char *portal_name, long max_rows)
bool is_trans_exit = false;
bool completed;
char completionTag[COMPLETION_TAG_BUFSIZE];
- struct timeval start_t, stop_t;
+ struct timeval start_t,
+ stop_t;
bool save_log_duration = log_duration;
int save_log_min_duration_statement = log_min_duration_statement;
bool save_log_statement_stats = log_statement_stats;
@@ -1697,10 +1688,10 @@ exec_execute_message(const char *portal_name, long max_rows)
errmsg("portal \"%s\" does not exist", portal_name)));
/*
- * If we re-issue an Execute protocol request against an existing
- * portal, then we are only fetching more rows rather than
- * completely re-executing the query from the start. atStart is never
- * reset for a v3 portal, so we are safe to use this check.
+ * If we re-issue an Execute protocol request against an existing portal,
+ * then we are only fetching more rows rather than completely re-executing
+ * the query from the start. atStart is never reset for a v3 portal, so we
+ * are safe to use this check.
*/
if (!portal->atStart)
execute_is_fetch = true;
@@ -1737,9 +1728,9 @@ exec_execute_message(const char *portal_name, long max_rows)
/*
* We use save_log_* so "SET log_duration = true" and "SET
- * log_min_duration_statement = true" don't report incorrect time
- * because gettimeofday() wasn't called. Similarly,
- * log_statement_stats has to be captured once.
+ * log_min_duration_statement = true" don't report incorrect time because
+ * gettimeofday() wasn't called. Similarly, log_statement_stats has to be
+ * captured once.
*/
if (save_log_duration || save_log_min_duration_statement != -1)
gettimeofday(&start_t, NULL);
@@ -1778,9 +1769,8 @@ exec_execute_message(const char *portal_name, long max_rows)
}
/*
- * Create dest receiver in MessageContext (we don't want it in
- * transaction context, because that may get deleted if portal
- * contains VACUUM).
+ * Create dest receiver in MessageContext (we don't want it in transaction
+ * context, because that may get deleted if portal contains VACUUM).
*/
receiver = CreateDestReceiver(dest, portal);
@@ -1800,7 +1790,7 @@ exec_execute_message(const char *portal_name, long max_rows)
ereport(ERROR,
(errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
errmsg("current transaction is aborted, "
- "commands ignored until end of transaction block")));
+ "commands ignored until end of transaction block")));
}
/* Check for cancel signal before we start execution */
@@ -1826,8 +1816,7 @@ exec_execute_message(const char *portal_name, long max_rows)
{
/*
* If this was a transaction control statement, commit it. We
- * will start a new xact command for the next command (if
- * any).
+ * will start a new xact command for the next command (if any).
*/
finish_xact_command();
}
@@ -1851,8 +1840,8 @@ exec_execute_message(const char *portal_name, long max_rows)
}
/*
- * Combine processing here as we need to calculate the query duration
- * in both instances.
+ * Combine processing here as we need to calculate the query duration in
+ * both instances.
*/
if (save_log_duration || save_log_min_duration_statement != -1)
{
@@ -1865,30 +1854,30 @@ exec_execute_message(const char *portal_name, long max_rows)
stop_t.tv_usec += 1000000;
}
usecs = (long) (stop_t.tv_sec - start_t.tv_sec) * 1000000 +
- (long) (stop_t.tv_usec - start_t.tv_usec);
+ (long) (stop_t.tv_usec - start_t.tv_usec);
/* Only print duration if we previously printed the statement. */
if (log_statement == LOGSTMT_ALL && save_log_duration)
ereport(LOG,
(errmsg("duration: %ld.%03ld ms",
- (long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 +
- (stop_t.tv_usec - start_t.tv_usec) / 1000),
- (long) (stop_t.tv_usec - start_t.tv_usec) % 1000)));
+ (long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 +
+ (stop_t.tv_usec - start_t.tv_usec) / 1000),
+ (long) (stop_t.tv_usec - start_t.tv_usec) % 1000)));
/*
- * Output a duration_statement to the log if the query has
- * exceeded the min duration, or if we are to print all durations.
+ * Output a duration_statement to the log if the query has exceeded
+ * the min duration, or if we are to print all durations.
*/
if (save_log_min_duration_statement == 0 ||
(save_log_min_duration_statement > 0 &&
usecs >= save_log_min_duration_statement * 1000))
ereport(LOG,
(errmsg("duration: %ld.%03ld ms statement: %sEXECUTE %s [PREPARE: %s]",
- (long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 +
- (stop_t.tv_usec - start_t.tv_usec) / 1000),
- (long) (stop_t.tv_usec - start_t.tv_usec) % 1000,
+ (long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 +
+ (stop_t.tv_usec - start_t.tv_usec) / 1000),
+ (long) (stop_t.tv_usec - start_t.tv_usec) % 1000,
(execute_is_fetch) ? "FETCH from " : "",
- (*portal_name != '\0') ? portal_name : "<unnamed>",
+ (*portal_name != '\0') ? portal_name : "<unnamed>",
portal->sourceText ? portal->sourceText : "")));
}
@@ -1921,7 +1910,7 @@ exec_describe_statement_message(const char *stmt_name)
if (!pstmt)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_PSTATEMENT),
- errmsg("unnamed prepared statement does not exist")));
+ errmsg("unnamed prepared statement does not exist")));
}
if (whereToSendOutput != Remote)
@@ -1999,7 +1988,7 @@ start_xact_command(void)
enable_sig_alarm(StatementTimeout, true);
else
cancel_from_timeout = false;
-
+
xact_started = true;
}
}
@@ -2052,28 +2041,28 @@ quickdie(SIGNAL_ARGS)
PG_SETMASK(&BlockSig);
/*
- * Ideally this should be ereport(FATAL), but then we'd not get
- * control back...
+ * Ideally this should be ereport(FATAL), but then we'd not get control
+ * back...
*/
ereport(WARNING,
(errcode(ERRCODE_CRASH_SHUTDOWN),
errmsg("terminating connection because of crash of another server process"),
- errdetail("The postmaster has commanded this server process to roll back"
- " the current transaction and exit, because another"
- " server process exited abnormally and possibly corrupted"
- " shared memory."),
+ errdetail("The postmaster has commanded this server process to roll back"
+ " the current transaction and exit, because another"
+ " server process exited abnormally and possibly corrupted"
+ " shared memory."),
errhint("In a moment you should be able to reconnect to the"
" database and repeat your command.")));
/*
* DO NOT proc_exit() -- we're here because shared memory may be
- * corrupted, so we don't want to try to clean up our transaction.
- * Just nail the windows shut and get out of town.
+ * corrupted, so we don't want to try to clean up our transaction. Just
+ * nail the windows shut and get out of town.
*
- * Note we do exit(1) not exit(0). This is to force the postmaster into
- * a system reset cycle if some idiot DBA sends a manual SIGQUIT to a
- * random backend. This is necessary precisely because we don't clean
- * up our shared memory state.
+ * Note we do exit(1) not exit(0). This is to force the postmaster into a
+ * system reset cycle if some idiot DBA sends a manual SIGQUIT to a random
+ * backend. This is necessary precisely because we don't clean up our
+ * shared memory state.
*/
exit(1);
}
@@ -2094,8 +2083,8 @@ die(SIGNAL_ARGS)
ProcDiePending = true;
/*
- * If it's safe to interrupt, and we're waiting for input or a
- * lock, service the interrupt immediately
+ * If it's safe to interrupt, and we're waiting for input or a lock,
+ * service the interrupt immediately
*/
if (ImmediateInterruptOK && InterruptHoldoffCount == 0 &&
CritSectionCount == 0)
@@ -2147,9 +2136,9 @@ StatementCancelHandler(SIGNAL_ARGS)
QueryCancelPending = true;
/*
- * If it's safe to interrupt, and we're waiting for a lock,
- * service the interrupt immediately. No point in interrupting if
- * we're waiting for input, however.
+ * If it's safe to interrupt, and we're waiting for a lock, service
+ * the interrupt immediately. No point in interrupting if we're
+ * waiting for input, however.
*/
if (ImmediateInterruptOK && InterruptHoldoffCount == 0 &&
CritSectionCount == 0)
@@ -2179,9 +2168,9 @@ FloatExceptionHandler(SIGNAL_ARGS)
ereport(ERROR,
(errcode(ERRCODE_FLOATING_POINT_EXCEPTION),
errmsg("floating-point exception"),
- errdetail("An invalid floating-point operation was signaled. "
- "This probably means an out-of-range result or an "
- "invalid operation, such as division by zero.")));
+ errdetail("An invalid floating-point operation was signaled. "
+ "This probably means an out-of-range result or an "
+ "invalid operation, such as division by zero.")));
}
/* SIGHUP: set flag to re-read config file at next convenient time */
@@ -2215,7 +2204,7 @@ ProcessInterrupts(void)
DisableCatchupInterrupt();
ereport(FATAL,
(errcode(ERRCODE_ADMIN_SHUTDOWN),
- errmsg("terminating connection due to administrator command")));
+ errmsg("terminating connection due to administrator command")));
}
if (QueryCancelPending)
{
@@ -2255,15 +2244,14 @@ check_stack_depth(void)
/*
* Compute distance from PostgresMain's local variables to my own
*
- * Note: in theory stack_depth should be ptrdiff_t or some such, but
- * since the whole point of this code is to bound the value to
- * something much less than integer-sized, int should work fine.
+ * Note: in theory stack_depth should be ptrdiff_t or some such, but since
+ * the whole point of this code is to bound the value to something much
+ * less than integer-sized, int should work fine.
*/
stack_depth = (int) (stack_base_ptr - &stack_top_loc);
/*
- * Take abs value, since stacks grow up on some machines, down on
- * others
+ * Take abs value, since stacks grow up on some machines, down on others
*/
if (stack_depth < 0)
stack_depth = -stack_depth;
@@ -2271,10 +2259,9 @@ check_stack_depth(void)
/*
* Trouble?
*
- * The test on stack_base_ptr prevents us from erroring out if called
- * during process setup or in a non-backend process. Logically it
- * should be done first, but putting it here avoids wasting cycles
- * during normal cases.
+ * The test on stack_base_ptr prevents us from erroring out if called during
+ * process setup or in a non-backend process. Logically it should be done
+ * first, but putting it here avoids wasting cycles during normal cases.
*/
if (stack_depth > max_stack_depth_bytes &&
stack_base_ptr != NULL)
@@ -2385,8 +2372,8 @@ PostgresMain(int argc, char *argv[], const char *username)
char *userDoption = NULL;
bool secure;
int errs = 0;
- int debug_flag = -1; /* -1 means not given */
- List *guc_names = NIL; /* for SUSET options */
+ int debug_flag = -1; /* -1 means not given */
+ List *guc_names = NIL; /* for SUSET options */
List *guc_values = NIL;
GucContext ctx;
GucSource gucsource;
@@ -2595,9 +2582,9 @@ PostgresMain(int argc, char *argv[], const char *username)
/*
* ignore system indexes
*
- * As of PG 7.4 this is safe to allow from the client, since
- * it only disables reading the system indexes, not
- * writing them. Worst case consequence is slowness.
+ * As of PG 7.4 this is safe to allow from the client, since it
+ * only disables reading the system indexes, not writing them.
+ * Worst case consequence is slowness.
*/
IgnoreSystemIndexes(true);
break;
@@ -2621,8 +2608,7 @@ PostgresMain(int argc, char *argv[], const char *username)
{
dbname = strdup(optarg);
- secure = false; /* subsequent switches are NOT
- * secure */
+ secure = false; /* subsequent switches are NOT secure */
ctx = PGC_BACKEND;
gucsource = PGC_S_CLIENT;
}
@@ -2641,8 +2627,8 @@ PostgresMain(int argc, char *argv[], const char *username)
/*
* s - report usage statistics (timings) after each query
*
- * Since log options are SUSET, we need to postpone unless
- * still in secure context
+ * Since log options are SUSET, we need to postpone unless still
+ * in secure context
*/
if (ctx == PGC_BACKEND)
PendingConfigOption("log_statement_stats", "true");
@@ -2724,8 +2710,8 @@ PostgresMain(int argc, char *argv[], const char *username)
}
/*
- * If a SUSET option, must postpone evaluation, unless
- * we are still reading secure switches.
+ * If a SUSET option, must postpone evaluation, unless we
+ * are still reading secure switches.
*/
if (ctx == PGC_BACKEND && IsSuperuserConfigOption(name))
PendingConfigOption(name, value);
@@ -2744,8 +2730,8 @@ PostgresMain(int argc, char *argv[], const char *username)
}
/*
- * Process any additional GUC variable settings passed in startup
- * packet. These are handled exactly like command-line variables.
+ * Process any additional GUC variable settings passed in startup packet.
+ * These are handled exactly like command-line variables.
*/
if (MyProcPort != NULL)
{
@@ -2779,16 +2765,16 @@ PostgresMain(int argc, char *argv[], const char *username)
/*
* Set up signal handlers and masks.
*
- * Note that postmaster blocked all signals before forking child process,
- * so there is no race condition whereby we might receive a signal
- * before we have set up the handler.
+ * Note that postmaster blocked all signals before forking child process, so
+ * there is no race condition whereby we might receive a signal before we
+ * have set up the handler.
*
- * 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,
- * such as SIGALRM and SIGPIPE.)
+ * 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, such as SIGALRM and
+ * SIGPIPE.)
*/
pqsignal(SIGHUP, SigHupHandler); /* set flag to read config file */
pqsignal(SIGINT, StatementCancelHandler); /* cancel current query */
@@ -2799,8 +2785,8 @@ PostgresMain(int argc, char *argv[], const char *username)
/*
* Ignore failure to write to frontend. Note: if frontend closes
* connection, we will notice it and exit cleanly when control next
- * returns to outer loop. This seems safer than forcing exit in the
- * midst of output during who-knows-what operation...
+ * returns to outer loop. This seems safer than forcing exit in the midst
+ * of output during who-knows-what operation...
*/
pqsignal(SIGPIPE, SIG_IGN);
pqsignal(SIGUSR1, CatchupInterruptHandler);
@@ -2808,11 +2794,9 @@ PostgresMain(int argc, char *argv[], const char *username)
pqsignal(SIGFPE, FloatExceptionHandler);
/*
- * Reset some signals that are accepted by postmaster but not by
- * backend
+ * Reset some signals that are accepted by postmaster but not by backend
*/
- pqsignal(SIGCHLD, SIG_DFL); /* system() requires this on some
- * platforms */
+ pqsignal(SIGCHLD, SIG_DFL); /* system() requires this on some platforms */
pqinitmask();
@@ -2833,8 +2817,8 @@ PostgresMain(int argc, char *argv[], const char *username)
{
ereport(FATAL,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("invalid command-line arguments for server process"),
- errhint("Try \"%s --help\" for more information.", argv[0])));
+ errmsg("invalid command-line arguments for server process"),
+ errhint("Try \"%s --help\" for more information.", argv[0])));
}
BaseInit();
@@ -2848,7 +2832,7 @@ PostgresMain(int argc, char *argv[], const char *username)
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("%s: invalid command-line arguments",
argv[0]),
- errhint("Try \"%s --help\" for more information.", argv[0])));
+ errhint("Try \"%s --help\" for more information.", argv[0])));
}
else if (argc - optind == 1)
dbname = argv[optind];
@@ -2861,8 +2845,8 @@ PostgresMain(int argc, char *argv[], const char *username)
}
/*
- * Validate we have been given a reasonable-looking DataDir (if
- * under postmaster, assume postmaster did this already).
+ * Validate we have been given a reasonable-looking DataDir (if under
+ * postmaster, assume postmaster did this already).
*/
Assert(DataDir);
ValidatePgVersion(DataDir);
@@ -2885,15 +2869,15 @@ PostgresMain(int argc, char *argv[], const char *username)
on_shmem_exit(ShutdownXLOG, 0);
/*
- * Read any existing FSM cache file, and register to write one out
- * at exit.
+ * Read any existing FSM cache file, and register to write one out at
+ * exit.
*/
LoadFreeSpaceMap();
on_shmem_exit(DumpFreeSpaceMap, 0);
/*
- * We have to build the flat file for pg_database, but not for
- * the user and group tables, since we won't try to do authentication.
+ * We have to build the flat file for pg_database, but not for the
+ * user and group tables, since we won't try to do authentication.
*/
BuildFlatFiles(true);
}
@@ -2901,9 +2885,9 @@ PostgresMain(int argc, char *argv[], const char *username)
/*
* General initialization.
*
- * NOTE: if you are tempted to add code in this vicinity, consider
- * putting it inside InitPostgres() instead. In particular, anything
- * that involves database access should be there, not here.
+ * NOTE: if you are tempted to add code in this vicinity, consider putting it
+ * inside InitPostgres() instead. In particular, anything that involves
+ * database access should be there, not here.
*/
ereport(DEBUG3,
(errmsg_internal("InitPostgres")));
@@ -2943,8 +2927,8 @@ PostgresMain(int argc, char *argv[], const char *username)
BeginReportingGUCOptions();
/*
- * Also set up handler to log session end; we have to wait till now
- * to be sure Log_disconnections has its final value.
+ * Also set up handler to log session end; we have to wait till now to be
+ * sure Log_disconnections has its final value.
*/
if (IsUnderPostmaster && Log_disconnections)
on_proc_exit(log_disconnections, 0);
@@ -2989,17 +2973,16 @@ PostgresMain(int argc, char *argv[], const char *username)
/*
* POSTGRES main processing loop begins here
*
- * If an exception is encountered, processing resumes here so we abort
- * the current transaction and start a new one.
+ * If an exception is encountered, processing resumes here so we abort the
+ * current transaction and start a new one.
*
- * You might wonder why this isn't coded as an infinite loop around a
- * PG_TRY construct. The reason is that this is the bottom of the
- * exception stack, and so with PG_TRY there would be no exception
- * handler in force at all during the CATCH part. By leaving the
- * outermost setjmp always active, we have at least some chance of
- * recovering from an error during error recovery. (If we get into an
- * infinite loop thereby, it will soon be stopped by overflow of
- * elog.c's internal state stack.)
+ * You might wonder why this isn't coded as an infinite loop around a PG_TRY
+ * construct. The reason is that this is the bottom of the exception
+ * stack, and so with PG_TRY there would be no exception handler in force
+ * at all during the CATCH part. By leaving the outermost setjmp always
+ * active, we have at least some chance of recovering from an error during
+ * error recovery. (If we get into an infinite loop thereby, it will soon
+ * be stopped by overflow of elog.c's internal state stack.)
*/
if (sigsetjmp(local_sigjmp_buf, 1) != 0)
@@ -3008,9 +2991,8 @@ PostgresMain(int argc, char *argv[], const char *username)
* NOTE: if you are tempted to add more code in this if-block,
* consider the high probability that it should be in
* AbortTransaction() instead. The only stuff done directly here
- * should be stuff that is guaranteed to apply *only* for
- * outer-level error recovery, such as adjusting the FE/BE
- * protocol status.
+ * should be stuff that is guaranteed to apply *only* for outer-level
+ * error recovery, such as adjusting the FE/BE protocol status.
*/
/* Since not using PG_TRY, must reset error stack by hand */
@@ -3020,18 +3002,17 @@ PostgresMain(int argc, char *argv[], const char *username)
HOLD_INTERRUPTS();
/*
- * Forget any pending QueryCancel request, since we're returning
- * to the idle loop anyway, and cancel the statement timer if
- * running.
+ * Forget any pending QueryCancel request, since we're returning to
+ * the idle loop anyway, and cancel the statement timer if running.
*/
QueryCancelPending = false;
disable_sig_alarm(true);
QueryCancelPending = false; /* again in case timeout occurred */
/*
- * Turn off these interrupts too. This is only needed here and
- * not in other exception-catching places since these interrupts
- * are only enabled while we wait for client input.
+ * Turn off these interrupts too. This is only needed here and not in
+ * other exception-catching places since these interrupts are only
+ * enabled while we wait for client input.
*/
DoingCommandRead = false;
DisableNotifyInterrupt();
@@ -3044,8 +3025,8 @@ PostgresMain(int argc, char *argv[], const char *username)
EmitErrorReport();
/*
- * Make sure debug_query_string gets reset before we possibly
- * clobber the storage it points at.
+ * Make sure debug_query_string gets reset before we possibly clobber
+ * the storage it points at.
*/
debug_query_string = NULL;
@@ -3055,16 +3036,16 @@ PostgresMain(int argc, char *argv[], const char *username)
AbortCurrentTransaction();
/*
- * Now return to normal top-level context and clear ErrorContext
- * for next time.
+ * Now return to normal top-level context and clear ErrorContext for
+ * next time.
*/
MemoryContextSwitchTo(TopMemoryContext);
FlushErrorState();
QueryContext = NULL;
/*
- * If we were handling an extended-query-protocol message,
- * initiate skip till next Sync. This also causes us not to issue
+ * If we were handling an extended-query-protocol message, initiate
+ * skip till next Sync. This also causes us not to issue
* ReadyForQuery (until we get Sync).
*/
if (doing_extended_query_message)
@@ -3098,8 +3079,8 @@ PostgresMain(int argc, char *argv[], const char *username)
doing_extended_query_message = false;
/*
- * Release storage left over from prior query cycle, and create a
- * new query input buffer in the cleared MessageContext.
+ * Release storage left over from prior query cycle, and create a new
+ * query input buffer in the cleared MessageContext.
*/
MemoryContextSwitchTo(MessageContext);
MemoryContextResetAndDeleteChildren(MessageContext);
@@ -3107,16 +3088,16 @@ PostgresMain(int argc, char *argv[], const char *username)
initStringInfo(&input_message);
/*
- * (1) If we've reached idle state, tell the frontend we're ready
- * for a new query.
+ * (1) If we've reached idle state, tell the frontend we're ready for
+ * a new query.
*
* Note: this includes fflush()'ing the last of the prior output.
*
* This is also a good time to send collected statistics to the
* collector, and to update the PS stats display. We avoid doing
- * those every time through the message loop because it'd slow
- * down processing of batched messages, and because we don't want
- * to report uncommitted updates (that confuses autovacuum).
+ * those every time through the message loop because it'd slow down
+ * processing of batched messages, and because we don't want to report
+ * uncommitted updates (that confuses autovacuum).
*/
if (send_rfq)
{
@@ -3138,10 +3119,10 @@ PostgresMain(int argc, char *argv[], const char *username)
}
/*
- * (2) Allow asynchronous signals to be executed immediately
- * if they come in while we are waiting for client input.
- * (This must be conditional since we don't want, say, reads on
- * behalf of COPY FROM STDIN doing the same thing.)
+ * (2) Allow asynchronous signals to be executed immediately if they
+ * come in while we are waiting for client input. (This must be
+ * conditional since we don't want, say, reads on behalf of COPY FROM
+ * STDIN doing the same thing.)
*/
QueryCancelPending = false; /* forget any earlier CANCEL signal */
DoingCommandRead = true;
@@ -3157,8 +3138,8 @@ PostgresMain(int argc, char *argv[], const char *username)
DoingCommandRead = false;
/*
- * (5) check for any other interesting events that happened while
- * we slept.
+ * (5) check for any other interesting events that happened while we
+ * slept.
*/
if (got_SIGHUP)
{
@@ -3216,8 +3197,8 @@ PostgresMain(int argc, char *argv[], const char *username)
case 'B': /* bind */
/*
- * this message is complex enough that it seems best to
- * put the field extraction out-of-line
+ * this message is complex enough that it seems best to put
+ * the field extraction out-of-line
*/
exec_bind_message(&input_message);
break;
@@ -3306,8 +3287,8 @@ PostgresMain(int argc, char *argv[], const char *username)
default:
ereport(ERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("invalid CLOSE message subtype %d",
- close_type)));
+ errmsg("invalid CLOSE message subtype %d",
+ close_type)));
break;
}
@@ -3336,8 +3317,8 @@ PostgresMain(int argc, char *argv[], const char *username)
default:
ereport(ERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("invalid DESCRIBE message subtype %d",
- describe_type)));
+ errmsg("invalid DESCRIBE message subtype %d",
+ describe_type)));
break;
}
}
@@ -3356,16 +3337,16 @@ 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 ereport from
- * attempting to send any more messages to client.
+ * Reset whereToSendOutput to prevent ereport from attempting
+ * to send any more messages to client.
*/
if (whereToSendOutput == Remote)
whereToSendOutput = None;
@@ -3373,9 +3354,9 @@ PostgresMain(int argc, char *argv[], const char *username)
/*
* NOTE: if you are tempted to add more code here, DON'T!
* Whatever you had in mind to do should be set up as an
- * on_proc_exit or on_shmem_exit callback, instead.
- * Otherwise it will fail to be called during other
- * backend-shutdown scenarios.
+ * on_proc_exit or on_shmem_exit callback, instead. Otherwise
+ * it will fail to be called during other backend-shutdown
+ * scenarios.
*/
proc_exit(0);
@@ -3385,8 +3366,8 @@ PostgresMain(int argc, char *argv[], const char *username)
/*
* Accept but ignore these messages, per protocol spec; we
- * probably got here because a COPY failed, and the
- * frontend is still sending data.
+ * probably got here because a COPY failed, and the frontend
+ * is still sending data.
*/
break;
@@ -3454,23 +3435,22 @@ ShowUsage(const char *title)
/*
* the only stats we don't show here are for memory usage -- i can't
- * figure out how to interpret the relevant fields in the rusage
- * struct, and they change names across o/s platforms, anyway. if you
- * can figure out what the entries mean, you can somehow extract
- * resident set size, shared text size, and unshared data and stack
- * sizes.
+ * figure out how to interpret the relevant fields in the rusage struct,
+ * and they change names across o/s platforms, anyway. if you can figure
+ * out what the entries mean, you can somehow extract resident set size,
+ * shared text size, and unshared data and stack sizes.
*/
initStringInfo(&str);
appendStringInfo(&str, "! system usage stats:\n");
appendStringInfo(&str,
- "!\t%ld.%06ld elapsed %ld.%06ld user %ld.%06ld system sec\n",
+ "!\t%ld.%06ld elapsed %ld.%06ld user %ld.%06ld system sec\n",
(long) (elapse_t.tv_sec - Save_t.tv_sec),
(long) (elapse_t.tv_usec - Save_t.tv_usec),
(long) (r.ru_utime.tv_sec - Save_r.ru_utime.tv_sec),
- (long) (r.ru_utime.tv_usec - Save_r.ru_utime.tv_usec),
+ (long) (r.ru_utime.tv_usec - Save_r.ru_utime.tv_usec),
(long) (r.ru_stime.tv_sec - Save_r.ru_stime.tv_sec),
- (long) (r.ru_stime.tv_usec - Save_r.ru_stime.tv_usec));
+ (long) (r.ru_stime.tv_usec - Save_r.ru_stime.tv_usec));
appendStringInfo(&str,
"!\t[%ld.%06ld user %ld.%06ld sys total]\n",
(long) user.tv_sec,
@@ -3486,21 +3466,21 @@ ShowUsage(const char *title)
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",
+ "!\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);
appendStringInfo(&str,
- "!\t%ld [%ld] signals rcvd, %ld/%ld [%ld/%ld] messages rcvd/sent\n",
+ "!\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);
appendStringInfo(&str,
- "!\t%ld/%ld [%ld/%ld] voluntary/involuntary context switches\n",
+ "!\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);
@@ -3527,11 +3507,11 @@ ShowUsage(const char *title)
static void
log_disconnections(int code, Datum arg)
{
- Port *port = MyProcPort;
- struct timeval end;
- int hours,
- minutes,
- seconds;
+ Port *port = MyProcPort;
+ struct timeval end;
+ int hours,
+ minutes,
+ seconds;
gettimeofday(&end, NULL);
if (end.tv_usec < port->session_start.tv_usec)
@@ -3553,5 +3533,5 @@ log_disconnections(int code, Datum arg)
"user=%s database=%s host=%s%s%s",
hours, minutes, seconds, (int) (end.tv_usec / 10000),
port->user_name, port->database_name, port->remote_host,
- port->remote_port[0] ? " port=" : "", port->remote_port)));
+ port->remote_port[0] ? " port=" : "", port->remote_port)));
}
diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c
index 75eb75f6de7..edf2ba44aeb 100644
--- a/src/backend/tcop/pquery.c
+++ b/src/backend/tcop/pquery.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/pquery.c,v 1.94 2005/06/22 17:45:46 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/pquery.c,v 1.95 2005/10/15 02:49:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -72,7 +72,7 @@ CreateQueryDesc(Query *parsetree,
qd->parsetree = parsetree; /* parse tree */
qd->plantree = plantree; /* plan */
qd->snapshot = snapshot; /* snapshot */
- qd->crosscheck_snapshot = crosscheck_snapshot; /* RI check snapshot */
+ qd->crosscheck_snapshot = crosscheck_snapshot; /* RI check snapshot */
qd->dest = dest; /* output dest */
qd->params = params; /* parameter values passed into query */
qd->doInstrument = doInstrument; /* instrumentation wanted? */
@@ -138,16 +138,16 @@ ProcessQuery(Query *parsetree,
* SELECT INTO table (a/k/a CREATE AS ... SELECT).
*
* Override the normal communication destination; execMain.c
- * special-cases this case. (Perhaps would be cleaner to have
- * an additional destination type?)
+ * special-cases this case. (Perhaps would be cleaner to have an
+ * additional destination type?)
*/
dest = None_Receiver;
}
}
/*
- * Must always set snapshot for plannable queries. Note we assume
- * that caller will take care of restoring ActiveSnapshot on exit/error.
+ * Must always set snapshot for plannable queries. Note we assume that
+ * caller will take care of restoring ActiveSnapshot on exit/error.
*/
ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
@@ -191,7 +191,7 @@ ProcessQuery(Query *parsetree,
else
lastOid = InvalidOid;
snprintf(completionTag, COMPLETION_TAG_BUFSIZE,
- "INSERT %u %u", lastOid, queryDesc->estate->es_processed);
+ "INSERT %u %u", lastOid, queryDesc->estate->es_processed);
break;
case CMD_UPDATE:
snprintf(completionTag, COMPLETION_TAG_BUFSIZE,
@@ -270,31 +270,31 @@ FetchPortalTargetList(Portal portal)
return ((Query *) linitial(portal->parseTrees))->targetList;
if (portal->strategy == PORTAL_UTIL_SELECT)
{
- Node *utilityStmt;
+ Node *utilityStmt;
utilityStmt = ((Query *) linitial(portal->parseTrees))->utilityStmt;
switch (nodeTag(utilityStmt))
{
case T_FetchStmt:
- {
- FetchStmt *substmt = (FetchStmt *) utilityStmt;
- Portal subportal;
+ {
+ FetchStmt *substmt = (FetchStmt *) utilityStmt;
+ Portal subportal;
- Assert(!substmt->ismove);
- subportal = GetPortalByName(substmt->portalname);
- Assert(PortalIsValid(subportal));
- return FetchPortalTargetList(subportal);
- }
+ Assert(!substmt->ismove);
+ subportal = GetPortalByName(substmt->portalname);
+ Assert(PortalIsValid(subportal));
+ return FetchPortalTargetList(subportal);
+ }
case T_ExecuteStmt:
- {
- ExecuteStmt *substmt = (ExecuteStmt *) utilityStmt;
- PreparedStatement *entry;
+ {
+ ExecuteStmt *substmt = (ExecuteStmt *) utilityStmt;
+ PreparedStatement *entry;
- Assert(!substmt->into);
- entry = FetchPreparedStatement(substmt->name, true);
- return FetchPreparedStatementTargetList(entry);
- }
+ Assert(!substmt->into);
+ entry = FetchPreparedStatement(substmt->name, true);
+ return FetchPreparedStatementTargetList(entry);
+ }
default:
break;
@@ -335,8 +335,7 @@ PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot)
AssertState(portal->status == PORTAL_NEW); /* else extra PortalStart */
/*
- * Set up global portal context pointers. (Should we set
- * QueryContext?)
+ * Set up global portal context pointers. (Should we set QueryContext?)
*/
saveActivePortal = ActivePortal;
saveActiveSnapshot = ActiveSnapshot;
@@ -345,7 +344,7 @@ PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot)
PG_TRY();
{
ActivePortal = portal;
- ActiveSnapshot = NULL; /* will be set later */
+ ActiveSnapshot = NULL; /* will be set later */
CurrentResourceOwner = portal->resowner;
PortalContext = PortalGetHeapMemory(portal);
@@ -367,7 +366,7 @@ PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot)
case PORTAL_ONE_SELECT:
/*
- * Must set snapshot before starting executor. Be sure to
+ * Must set snapshot before starting executor. Be sure to
* copy it into the portal's context.
*/
if (snapshot)
@@ -376,11 +375,11 @@ PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot)
ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
/*
- * Create QueryDesc in portal's context; for the moment,
- * set the destination to None.
+ * Create QueryDesc in portal's context; for the moment, set
+ * the destination to None.
*/
queryDesc = CreateQueryDesc((Query *) linitial(portal->parseTrees),
- (Plan *) linitial(portal->planTrees),
+ (Plan *) linitial(portal->planTrees),
ActiveSnapshot,
InvalidSnapshot,
None_Receiver,
@@ -388,10 +387,10 @@ PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot)
false);
/*
- * We do *not* call AfterTriggerBeginQuery() here. We
- * assume that a SELECT cannot queue any triggers. It
- * would be messy to support triggers since the execution
- * of the portal may be interleaved with other queries.
+ * We do *not* call AfterTriggerBeginQuery() here. We assume
+ * that a SELECT cannot queue any triggers. It would be messy
+ * to support triggers since the execution of the portal may
+ * be interleaved with other queries.
*/
/*
@@ -421,8 +420,8 @@ PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot)
case PORTAL_UTIL_SELECT:
/*
- * We don't set snapshot here, because
- * PortalRunUtility will take care of it if needed.
+ * We don't set snapshot here, because PortalRunUtility will
+ * take care of it if needed.
*/
portal->tupDesc =
UtilityTupleDescriptor(((Query *) linitial(portal->parseTrees))->utilityStmt);
@@ -579,14 +578,14 @@ PortalRun(Portal portal, long count,
*
* We have to play a special game here to support utility commands like
* VACUUM and CLUSTER, which internally start and commit transactions.
- * When we are called to execute such a command, CurrentResourceOwner
- * will be pointing to the TopTransactionResourceOwner --- which will
- * be destroyed and replaced in the course of the internal commit and
- * restart. So we need to be prepared to restore it as pointing to
- * the exit-time TopTransactionResourceOwner. (Ain't that ugly? This
- * idea of internally starting whole new transactions is not good.)
- * CurrentMemoryContext has a similar problem, but the other pointers
- * we save here will be NULL or pointing to longer-lived objects.
+ * When we are called to execute such a command, CurrentResourceOwner will
+ * be pointing to the TopTransactionResourceOwner --- which will be
+ * destroyed and replaced in the course of the internal commit and
+ * restart. So we need to be prepared to restore it as pointing to the
+ * exit-time TopTransactionResourceOwner. (Ain't that ugly? This idea of
+ * internally starting whole new transactions is not good.)
+ * CurrentMemoryContext has a similar problem, but the other pointers we
+ * save here will be NULL or pointing to longer-lived objects.
*/
saveTopTransactionResourceOwner = TopTransactionResourceOwner;
saveTopTransactionContext = TopTransactionContext;
@@ -599,7 +598,7 @@ PortalRun(Portal portal, long count,
PG_TRY();
{
ActivePortal = portal;
- ActiveSnapshot = NULL; /* will be set later */
+ ActiveSnapshot = NULL; /* will be set later */
CurrentResourceOwner = portal->resowner;
PortalContext = PortalGetHeapMemory(portal);
QueryContext = portal->queryContext;
@@ -618,8 +617,7 @@ PortalRun(Portal portal, long count,
portal->status = PORTAL_READY;
/*
- * Since it's a forward fetch, say DONE iff atEnd is now
- * true.
+ * Since it's a forward fetch, say DONE iff atEnd is now true.
*/
result = portal->atEnd;
break;
@@ -658,8 +656,7 @@ PortalRun(Portal portal, long count,
portal->status = PORTAL_READY;
/*
- * Since it's a forward fetch, say DONE iff atEnd is now
- * true.
+ * Since it's a forward fetch, say DONE iff atEnd is now true.
*/
result = portal->atEnd;
break;
@@ -750,8 +747,8 @@ PortalRunSelect(Portal portal,
uint32 nprocessed;
/*
- * NB: queryDesc will be NULL if we are fetching from a held cursor or
- * a completed utility query; can't use it in that path.
+ * NB: queryDesc will be NULL if we are fetching from a held cursor or a
+ * completed utility query; can't use it in that path.
*/
queryDesc = PortalGetQueryDesc(portal);
@@ -768,15 +765,15 @@ PortalRunSelect(Portal portal,
queryDesc->dest = dest;
/*
- * Determine which direction to go in, and check to see if we're
- * already at the end of the available tuples in that direction. If
- * so, set the direction to NoMovement to avoid trying to fetch any
- * tuples. (This check exists because not all plan node types are
- * robust about being called again if they've already returned NULL
- * once.) Then call the executor (we must not skip this, because the
- * destination needs to see a setup and shutdown even if no tuples are
- * available). Finally, update the portal position state depending on
- * the number of tuples that were retrieved.
+ * Determine which direction to go in, and check to see if we're already
+ * at the end of the available tuples in that direction. If so, set the
+ * direction to NoMovement to avoid trying to fetch any tuples. (This
+ * check exists because not all plan node types are robust about being
+ * called again if they've already returned NULL once.) Then call the
+ * executor (we must not skip this, because the destination needs to see a
+ * setup and shutdown even if no tuples are available). Finally, update
+ * the portal position state depending on the number of tuples that were
+ * retrieved.
*/
if (forward)
{
@@ -924,9 +921,9 @@ RunFromStore(Portal portal, ScanDirection direction, long count,
ExecClearTuple(slot);
/*
- * check our tuple count.. if we've processed the proper
- * number then quit, else loop again and process more tuples.
- * Zero count means no limit.
+ * check our tuple count.. if we've processed the proper number
+ * then quit, else loop again and process more tuples. Zero count
+ * means no limit.
*/
current_tuple_count++;
if (count && count == current_tuple_count)
@@ -955,19 +952,18 @@ PortalRunUtility(Portal portal, Query *query,
(errmsg_internal("ProcessUtility")));
/*
- * Set snapshot if utility stmt needs one. Most reliable way to do
- * this seems to be to enumerate those that do not need one; this is a
- * short list. Transaction control, LOCK, and SET must *not* set a
- * snapshot since they need to be executable at the start of a
- * serializable transaction without freezing a snapshot. By extension
- * we allow SHOW not to set a snapshot. The other stmts listed are
- * just efficiency hacks. Beware of listing anything that can modify
- * the database --- if, say, it has to update an index with
- * expressions that invoke user-defined functions, then it had better
- * have a snapshot.
+ * Set snapshot if utility stmt needs one. Most reliable way to do this
+ * seems to be to enumerate those that do not need one; this is a short
+ * list. Transaction control, LOCK, and SET must *not* set a snapshot
+ * since they need to be executable at the start of a serializable
+ * transaction without freezing a snapshot. By extension we allow SHOW
+ * not to set a snapshot. The other stmts listed are just efficiency
+ * hacks. Beware of listing anything that can modify the database --- if,
+ * say, it has to update an index with expressions that invoke
+ * user-defined functions, then it had better have a snapshot.
*
- * Note we assume that caller will take care of restoring ActiveSnapshot
- * on exit/error.
+ * Note we assume that caller will take care of restoring ActiveSnapshot on
+ * exit/error.
*/
if (!(IsA(utilityStmt, TransactionStmt) ||
IsA(utilityStmt, LockStmt) ||
@@ -1020,13 +1016,13 @@ PortalRunMulti(Portal portal,
/*
* If the destination is RemoteExecute, change to None. The reason is
- * that the client won't be expecting any tuples, and indeed has no
- * way to know what they are, since there is no provision for Describe
- * to send a RowDescription message when this portal execution
- * strategy is in effect. This presently will only affect SELECT
- * commands added to non-SELECT queries by rewrite rules: such
- * commands will be executed, but the results will be discarded unless
- * you use "simple Query" protocol.
+ * that the client won't be expecting any tuples, and indeed has no way to
+ * know what they are, since there is no provision for Describe to send a
+ * RowDescription message when this portal execution strategy is in
+ * effect. This presently will only affect SELECT commands added to
+ * non-SELECT queries by rewrite rules: such commands will be executed,
+ * but the results will be discarded unless you use "simple Query"
+ * protocol.
*/
if (dest->mydest == RemoteExecute)
dest = None_Receiver;
@@ -1034,8 +1030,8 @@ PortalRunMulti(Portal portal,
altdest = None_Receiver;
/*
- * Loop to handle the individual queries generated from a single
- * parsetree by analysis and rewrite.
+ * Loop to handle the individual queries generated from a single parsetree
+ * by analysis and rewrite.
*/
forboth(querylist_item, portal->parseTrees,
planlist_item, portal->planTrees)
@@ -1087,8 +1083,8 @@ PortalRunMulti(Portal portal,
}
/*
- * Increment command counter between queries, but not after the
- * last one.
+ * Increment command counter between queries, but not after the last
+ * one.
*/
if (lnext(planlist_item) != NULL)
CommandCounterIncrement();
@@ -1102,12 +1098,12 @@ PortalRunMulti(Portal portal,
}
/*
- * If a command completion tag was supplied, use it. Otherwise use
- * the portal's commandTag as the default completion tag.
+ * If a command completion tag was supplied, use it. Otherwise use the
+ * portal's commandTag as the default completion tag.
*
- * Exception: clients will expect INSERT/UPDATE/DELETE tags to have
- * counts, so fake something up if necessary. (This could happen if
- * the original query was replaced by a DO INSTEAD rule.)
+ * Exception: clients will expect INSERT/UPDATE/DELETE tags to have counts,
+ * so fake something up if necessary. (This could happen if the original
+ * query was replaced by a DO INSTEAD rule.)
*/
if (completionTag && completionTag[0] == '\0')
{
@@ -1164,7 +1160,7 @@ PortalRunFetch(Portal portal,
PG_TRY();
{
ActivePortal = portal;
- ActiveSnapshot = NULL; /* will be set later */
+ ActiveSnapshot = NULL; /* will be set later */
CurrentResourceOwner = portal->resowner;
PortalContext = PortalGetHeapMemory(portal);
QueryContext = portal->queryContext;
@@ -1276,11 +1272,11 @@ DoPortalRunFetch(Portal portal,
if (count > 0)
{
/*
- * Definition: Rewind to start, advance count-1 rows,
- * return next row (if any). In practice, if the goal is
- * less than halfway back to the start, it's better to
- * scan from where we are. In any case, we arrange to
- * fetch the target row going forwards.
+ * Definition: Rewind to start, advance count-1 rows, return
+ * next row (if any). In practice, if the goal is less than
+ * halfway back to the start, it's better to scan from where
+ * we are. In any case, we arrange to fetch the target row
+ * going forwards.
*/
if (portal->posOverflow || portal->portalPos == LONG_MAX ||
count - 1 <= portal->portalPos / 2)
@@ -1309,11 +1305,10 @@ DoPortalRunFetch(Portal portal,
{
/*
* Definition: Advance to end, back up abs(count)-1 rows,
- * return prior row (if any). We could optimize this if
- * we knew in advance where the end was, but typically we
- * won't. (Is it worth considering case where count > half
- * of size of query? We could rewind once we know the
- * size ...)
+ * return prior row (if any). We could optimize this if we
+ * knew in advance where the end was, but typically we won't.
+ * (Is it worth considering case where count > half of size of
+ * query? We could rewind once we know the size ...)
*/
PortalRunSelect(portal, true, FETCH_ALL, None_Receiver);
if (count < -1)
@@ -1332,8 +1327,7 @@ DoPortalRunFetch(Portal portal,
if (count > 0)
{
/*
- * Definition: advance count-1 rows, return next row (if
- * any).
+ * Definition: advance count-1 rows, return next row (if any).
*/
if (count > 1)
PortalRunSelect(portal, true, count - 1, None_Receiver);
@@ -1342,8 +1336,8 @@ DoPortalRunFetch(Portal portal,
else if (count < 0)
{
/*
- * Definition: back up abs(count)-1 rows, return prior row
- * (if any).
+ * Definition: back up abs(count)-1 rows, return prior row (if
+ * any).
*/
if (count < -1)
PortalRunSelect(portal, false, -count - 1, None_Receiver);
@@ -1362,8 +1356,8 @@ DoPortalRunFetch(Portal portal,
}
/*
- * Get here with fdirection == FETCH_FORWARD or FETCH_BACKWARD, and
- * count >= 0.
+ * Get here with fdirection == FETCH_FORWARD or FETCH_BACKWARD, and count
+ * >= 0.
*/
forward = (fdirection == FETCH_FORWARD);
@@ -1385,11 +1379,11 @@ DoPortalRunFetch(Portal portal,
else
{
/*
- * If we are sitting on a row, back up one so we can re-fetch
- * it. If we are not sitting on a row, we still have to start
- * up and shut down the executor so that the destination is
- * initialized and shut down correctly; so keep going. To
- * PortalRunSelect, count == 0 means we will retrieve no row.
+ * If we are sitting on a row, back up one so we can re-fetch it.
+ * If we are not sitting on a row, we still have to start up and
+ * shut down the executor so that the destination is initialized
+ * and shut down correctly; so keep going. To PortalRunSelect,
+ * count == 0 means we will retrieve no row.
*/
if (on_row)
{
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index dd89832da89..8e3c900053c 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.244 2005/10/06 21:30:36 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.245 2005/10/15 02:49:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -214,8 +214,8 @@ CheckRelationOwnership(RangeVar *rel, bool noCatalogs)
IsSystemClass((Form_pg_class) GETSTRUCT(tuple)))
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("permission denied: \"%s\" is a system catalog",
- rel->relname)));
+ errmsg("permission denied: \"%s\" is a system catalog",
+ rel->relname)));
}
ReleaseSysCache(tuple);
@@ -236,9 +236,9 @@ QueryIsReadOnly(Query *parsetree)
{
case CMD_SELECT:
if (parsetree->into != NULL)
- return false; /* SELECT INTO */
+ return false; /* SELECT INTO */
else if (parsetree->rowMarks != NIL)
- return false; /* SELECT FOR UPDATE/SHARE */
+ return false; /* SELECT FOR UPDATE/SHARE */
else
return true;
case CMD_UPDATE:
@@ -269,8 +269,8 @@ check_xact_readonly(Node *parsetree)
return;
/*
- * Note: Commands that need to do more complicated checking are
- * handled elsewhere.
+ * Note: Commands that need to do more complicated checking are handled
+ * elsewhere.
*/
switch (nodeTag(parsetree))
@@ -367,8 +367,8 @@ ProcessUtility(Node *parsetree,
switch (stmt->kind)
{
/*
- * START TRANSACTION, as defined by SQL99:
- * Identical to BEGIN. Same code for both.
+ * START TRANSACTION, as defined by SQL99: Identical
+ * to BEGIN. Same code for both.
*/
case TRANS_STMT_BEGIN:
case TRANS_STMT_START:
@@ -498,8 +498,8 @@ ProcessUtility(Node *parsetree,
RELKIND_RELATION);
/*
- * Let AlterTableCreateToastTable decide if this one needs
- * a secondary relation too.
+ * Let AlterTableCreateToastTable decide if this one needs a
+ * secondary relation too.
*/
CommandCounterIncrement();
AlterTableCreateToastTable(relOid, true);
@@ -558,8 +558,7 @@ ProcessUtility(Node *parsetree,
case OBJECT_DOMAIN:
/*
- * RemoveDomain does its own permissions
- * checks
+ * RemoveDomain does its own permissions checks
*/
RemoveDomain(names, stmt->behavior);
break;
@@ -571,8 +570,7 @@ ProcessUtility(Node *parsetree,
case OBJECT_SCHEMA:
/*
- * RemoveSchema does its own permissions
- * checks
+ * RemoveSchema does its own permissions checks
*/
RemoveSchema(names, stmt->behavior);
break;
@@ -584,8 +582,8 @@ ProcessUtility(Node *parsetree,
}
/*
- * We used to need to do CommandCounterIncrement()
- * here, but now it's done inside performDeletion().
+ * We used to need to do CommandCounterIncrement() here,
+ * but now it's done inside performDeletion().
*/
}
}
@@ -651,8 +649,8 @@ ProcessUtility(Node *parsetree,
case 'T': /* ALTER DOMAIN DEFAULT */
/*
- * Recursively alter column default for table and,
- * if requested, for descendants
+ * Recursively alter column default for table and, if
+ * requested, for descendants
*/
AlterDomainDefault(stmt->typename,
stmt->def);
@@ -691,8 +689,7 @@ ProcessUtility(Node *parsetree,
break;
/*
- * ******************************** object creation /
- * destruction ********************************
+ * ******************************** object creation / destruction ********************************
*
*/
case T_DefineStmt:
@@ -738,7 +735,7 @@ ProcessUtility(Node *parsetree,
CreateFunction((CreateFunctionStmt *) parsetree);
break;
- case T_AlterFunctionStmt: /* ALTER FUNCTION */
+ case T_AlterFunctionStmt: /* ALTER FUNCTION */
AlterFunction((AlterFunctionStmt *) parsetree);
break;
@@ -750,7 +747,7 @@ ProcessUtility(Node *parsetree,
DefineIndex(stmt->relation, /* relation */
stmt->idxname, /* index name */
- InvalidOid, /* no predefined OID */
+ InvalidOid, /* no predefined OID */
stmt->accessMethod, /* am name */
stmt->tableSpace,
stmt->indexParams, /* parameters */
@@ -865,8 +862,8 @@ ProcessUtility(Node *parsetree,
VariableSetStmt *n = (VariableSetStmt *) parsetree;
/*
- * Special cases for special SQL syntax that effectively
- * sets more than one variable per statement.
+ * Special cases for special SQL syntax that effectively sets
+ * more than one variable per statement.
*/
if (strcmp(n->name, "TRANSACTION") == 0)
{
@@ -878,10 +875,10 @@ ProcessUtility(Node *parsetree,
if (strcmp(item->defname, "transaction_isolation") == 0)
SetPGVariable("transaction_isolation",
- list_make1(item->arg), n->is_local);
+ list_make1(item->arg), n->is_local);
else if (strcmp(item->defname, "transaction_read_only") == 0)
SetPGVariable("transaction_read_only",
- list_make1(item->arg), n->is_local);
+ list_make1(item->arg), n->is_local);
}
}
else if (strcmp(n->name, "SESSION CHARACTERISTICS") == 0)
@@ -894,10 +891,10 @@ ProcessUtility(Node *parsetree,
if (strcmp(item->defname, "transaction_isolation") == 0)
SetPGVariable("default_transaction_isolation",
- list_make1(item->arg), n->is_local);
+ list_make1(item->arg), n->is_local);
else if (strcmp(item->defname, "transaction_read_only") == 0)
SetPGVariable("default_transaction_read_only",
- list_make1(item->arg), n->is_local);
+ list_make1(item->arg), n->is_local);
}
}
else
@@ -1380,30 +1377,30 @@ CreateCommandTag(Node *parsetree)
break;
case T_AlterObjectSchemaStmt:
- switch (((AlterObjectSchemaStmt *) parsetree)->objectType)
- {
+ switch (((AlterObjectSchemaStmt *) parsetree)->objectType)
+ {
case OBJECT_AGGREGATE:
- tag = "ALTER AGGREGATE";
- break;
+ tag = "ALTER AGGREGATE";
+ break;
case OBJECT_DOMAIN:
- tag = "ALTER DOMAIN";
- break;
+ tag = "ALTER DOMAIN";
+ break;
case OBJECT_FUNCTION:
- tag = "ALTER FUNCTION";
- break;
+ tag = "ALTER FUNCTION";
+ break;
case OBJECT_SEQUENCE:
- tag = "ALTER SEQUENCE";
- break;
+ tag = "ALTER SEQUENCE";
+ break;
case OBJECT_TABLE:
- tag = "ALTER TABLE";
- break;
+ tag = "ALTER TABLE";
+ break;
case OBJECT_TYPE:
- tag = "ALTER TYPE";
- break;
+ tag = "ALTER TYPE";
+ break;
default:
tag = "???";
break;
- }
+ }
break;
case T_AlterOwnerStmt:
@@ -1480,7 +1477,7 @@ CreateCommandTag(Node *parsetree)
case T_GrantRoleStmt:
{
- GrantRoleStmt *stmt = (GrantRoleStmt *) parsetree;
+ GrantRoleStmt *stmt = (GrantRoleStmt *) parsetree;
tag = (stmt->is_grant) ? "GRANT ROLE" : "REVOKE ROLE";
}
@@ -1717,9 +1714,10 @@ CreateQueryTag(Query *parsetree)
switch (parsetree->commandType)
{
case CMD_SELECT:
+
/*
- * We take a little extra care here so that the result will
- * be useful for complaints about read-only statements
+ * We take a little extra care here so that the result will be
+ * useful for complaints about read-only statements
*/
if (parsetree->into != NULL)
tag = "SELECT INTO";