diff options
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r-- | src/backend/tcop/postgres.c | 644 |
1 files changed, 312 insertions, 332 deletions
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))); } |