mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
pgindent run. Make it all clean.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.212 2001/03/14 18:24:34 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.213 2001/03/22 03:59:47 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* this is the "main" module of the postgres backend and
|
||||
@ -71,20 +71,20 @@
|
||||
* ----------------
|
||||
*/
|
||||
|
||||
extern int optind;
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
/*
|
||||
* for ps display
|
||||
*/
|
||||
bool HostnameLookup;
|
||||
bool ShowPortNumber;
|
||||
bool HostnameLookup;
|
||||
bool ShowPortNumber;
|
||||
|
||||
bool Log_connections = false;
|
||||
bool Log_connections = false;
|
||||
|
||||
CommandDest whereToSendOutput = Debug;
|
||||
|
||||
static bool dontExecute = false;
|
||||
static bool dontExecute = false;
|
||||
|
||||
/* note: these declarations had better match tcopprot.h */
|
||||
DLLIMPORT sigjmp_buf Warn_restart;
|
||||
@ -342,9 +342,9 @@ ReadCommand(StringInfo inBuf)
|
||||
* but it is still needed for parsing of SQL function bodies.
|
||||
*/
|
||||
List *
|
||||
pg_parse_and_rewrite(char *query_string, /* string to execute */
|
||||
Oid *typev, /* parameter types */
|
||||
int nargs) /* number of parameters */
|
||||
pg_parse_and_rewrite(char *query_string, /* string to execute */
|
||||
Oid *typev,/* parameter types */
|
||||
int nargs) /* number of parameters */
|
||||
{
|
||||
List *raw_parsetree_list;
|
||||
List *querytree_list;
|
||||
@ -363,7 +363,7 @@ pg_parse_and_rewrite(char *query_string, /* string to execute */
|
||||
querytree_list = NIL;
|
||||
foreach(list_item, raw_parsetree_list)
|
||||
{
|
||||
Node *parsetree = (Node *) lfirst(list_item);
|
||||
Node *parsetree = (Node *) lfirst(list_item);
|
||||
|
||||
querytree_list = nconc(querytree_list,
|
||||
pg_analyze_and_rewrite(parsetree));
|
||||
@ -486,10 +486,14 @@ pg_analyze_and_rewrite(Node *parsetree)
|
||||
}
|
||||
|
||||
#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... */
|
||||
if (! equal(new_list, querytree_list))
|
||||
if (!equal(new_list, querytree_list))
|
||||
elog(NOTICE, "pg_analyze_and_rewrite: copyObject failed on parse tree");
|
||||
else
|
||||
querytree_list = new_list;
|
||||
@ -547,14 +551,15 @@ pg_plan_query(Query *querytree)
|
||||
#ifdef COPY_PARSE_PLAN_TREES
|
||||
/* Optional debugging check: pass plan output through copyObject() */
|
||||
{
|
||||
Plan *new_plan = (Plan *) copyObject(plan);
|
||||
Plan *new_plan = (Plan *) copyObject(plan);
|
||||
|
||||
/* equal() currently does not have routines to compare Plan nodes,
|
||||
/*
|
||||
* 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... */
|
||||
if (! equal(new_plan, plan))
|
||||
if (!equal(new_plan, plan))
|
||||
elog(NOTICE, "pg_plan_query: copyObject failed on plan tree");
|
||||
else
|
||||
#endif
|
||||
@ -593,7 +598,7 @@ pg_plan_query(Query *querytree)
|
||||
*
|
||||
* The CurrentMemoryContext after starting a transaction command must be
|
||||
* appropriate for execution of individual queries (typically this will be
|
||||
* TransactionCommandContext). Note that this routine resets that context
|
||||
* TransactionCommandContext). Note that this routine resets that context
|
||||
* after each individual query, so don't store anything there that
|
||||
* must outlive the call!
|
||||
*
|
||||
@ -612,9 +617,10 @@ pg_plan_query(Query *querytree)
|
||||
*/
|
||||
|
||||
void
|
||||
pg_exec_query_string(char *query_string, /* string to execute */
|
||||
CommandDest dest, /* where results should go */
|
||||
MemoryContext parse_context) /* context for parsetrees */
|
||||
pg_exec_query_string(char *query_string, /* string to execute */
|
||||
CommandDest dest, /* where results should go */
|
||||
MemoryContext parse_context) /* context for
|
||||
* parsetrees */
|
||||
{
|
||||
bool xact_started;
|
||||
MemoryContext oldcontext;
|
||||
@ -622,21 +628,21 @@ pg_exec_query_string(char *query_string, /* string to execute */
|
||||
*parsetree_item;
|
||||
|
||||
/*
|
||||
* 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 possibly change current memory context.)
|
||||
* 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 possibly change current memory context.)
|
||||
*/
|
||||
start_xact_command();
|
||||
xact_started = true;
|
||||
|
||||
/*
|
||||
* parse_context *must* be different from the execution memory context,
|
||||
* else the context reset at the bottom of the loop will destroy the
|
||||
* parsetree list. (We really ought to check that parse_context isn't a
|
||||
* child of CurrentMemoryContext either, but that would take more cycles
|
||||
* than it's likely to be worth.)
|
||||
* parse_context *must* be different from the execution memory
|
||||
* context, else the context reset at the bottom of the loop will
|
||||
* destroy the parsetree list. (We really ought to check that
|
||||
* parse_context isn't a child of CurrentMemoryContext either, but
|
||||
* that would take more cycles than it's likely to be worth.)
|
||||
*/
|
||||
Assert(parse_context != CurrentMemoryContext);
|
||||
|
||||
@ -646,8 +652,8 @@ pg_exec_query_string(char *query_string, /* string to execute */
|
||||
oldcontext = MemoryContextSwitchTo(parse_context);
|
||||
|
||||
/*
|
||||
* 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, NULL, 0);
|
||||
|
||||
@ -661,10 +667,10 @@ pg_exec_query_string(char *query_string, /* string to execute */
|
||||
*/
|
||||
foreach(parsetree_item, parsetree_list)
|
||||
{
|
||||
Node *parsetree = (Node *) lfirst(parsetree_item);
|
||||
bool isTransactionStmt;
|
||||
List *querytree_list,
|
||||
*querytree_item;
|
||||
Node *parsetree = (Node *) lfirst(parsetree_item);
|
||||
bool isTransactionStmt;
|
||||
List *querytree_list,
|
||||
*querytree_item;
|
||||
|
||||
/* Transaction control statements need some special handling */
|
||||
isTransactionStmt = IsA(parsetree, TransactionStmt);
|
||||
@ -673,13 +679,13 @@ pg_exec_query_string(char *query_string, /* string to execute */
|
||||
* If we are in an aborted transaction, ignore 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...)
|
||||
* 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())
|
||||
{
|
||||
bool allowit = false;
|
||||
bool allowit = false;
|
||||
|
||||
if (isTransactionStmt)
|
||||
{
|
||||
@ -696,7 +702,7 @@ pg_exec_query_string(char *query_string, /* string to execute */
|
||||
}
|
||||
}
|
||||
|
||||
if (! allowit)
|
||||
if (!allowit)
|
||||
{
|
||||
/* ----------------
|
||||
* the EndCommand() stuff is to tell the frontend
|
||||
@ -720,7 +726,7 @@ pg_exec_query_string(char *query_string, /* string to execute */
|
||||
}
|
||||
|
||||
/* Make sure we are in a transaction command */
|
||||
if (! xact_started)
|
||||
if (!xact_started)
|
||||
{
|
||||
start_xact_command();
|
||||
xact_started = true;
|
||||
@ -732,8 +738,8 @@ pg_exec_query_string(char *query_string, /* string to execute */
|
||||
/*
|
||||
* OK to analyze and rewrite this query.
|
||||
*
|
||||
* Switch to appropriate context for constructing querytrees
|
||||
* (again, these must outlive the execution context).
|
||||
* Switch to appropriate context for constructing querytrees (again,
|
||||
* these must outlive the execution context).
|
||||
*/
|
||||
oldcontext = MemoryContextSwitchTo(parse_context);
|
||||
|
||||
@ -753,13 +759,16 @@ pg_exec_query_string(char *query_string, /* string to execute */
|
||||
Query *querytree = (Query *) lfirst(querytree_item);
|
||||
|
||||
/* Make sure we are in a transaction command */
|
||||
if (! xact_started)
|
||||
if (!xact_started)
|
||||
{
|
||||
start_xact_command();
|
||||
xact_started = true;
|
||||
}
|
||||
|
||||
/* If we got a cancel signal in analysis or prior command, quit */
|
||||
/*
|
||||
* If we got a cancel signal in analysis or prior command,
|
||||
* quit
|
||||
*/
|
||||
CHECK_FOR_INTERRUPTS();
|
||||
|
||||
if (querytree->commandType == CMD_UTILITY)
|
||||
@ -819,27 +828,27 @@ pg_exec_query_string(char *query_string, /* string to execute */
|
||||
/*
|
||||
* In a query block, we want to increment the command counter
|
||||
* between queries so that the effects of early queries are
|
||||
* visible to subsequent ones. In particular we'd better
|
||||
* do so before checking constraints.
|
||||
* visible to subsequent ones. In particular we'd better do
|
||||
* so before checking constraints.
|
||||
*/
|
||||
if (!isTransactionStmt)
|
||||
CommandCounterIncrement();
|
||||
|
||||
/*
|
||||
* Clear the execution context to recover temporary
|
||||
* memory used by the query. NOTE: if query string contains
|
||||
* Clear the execution context to recover temporary memory
|
||||
* used by the query. NOTE: if query string contains
|
||||
* BEGIN/COMMIT transaction commands, execution context may
|
||||
* now be different from what we were originally passed;
|
||||
* so be careful to clear current context not "oldcontext".
|
||||
* now be different from what we were originally passed; so be
|
||||
* careful to clear current context not "oldcontext".
|
||||
*/
|
||||
Assert(parse_context != CurrentMemoryContext);
|
||||
|
||||
MemoryContextResetAndDeleteChildren(CurrentMemoryContext);
|
||||
|
||||
/*
|
||||
* If this was a transaction control statement, commit it
|
||||
* and arrange to start a new xact command for the next
|
||||
* command (if any).
|
||||
* If this was a transaction control statement, commit it and
|
||||
* arrange to start a new xact command for the next command
|
||||
* (if any).
|
||||
*/
|
||||
if (isTransactionStmt)
|
||||
{
|
||||
@ -847,8 +856,9 @@ pg_exec_query_string(char *query_string, /* string to execute */
|
||||
xact_started = false;
|
||||
}
|
||||
|
||||
} /* end loop over queries generated from a parsetree */
|
||||
} /* end loop over parsetrees */
|
||||
} /* end loop over queries generated from a
|
||||
* parsetree */
|
||||
} /* end loop over parsetrees */
|
||||
|
||||
/*
|
||||
* Close down transaction statement, if one is open.
|
||||
@ -915,10 +925,10 @@ quickdie(SIGNAL_ARGS)
|
||||
* 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);
|
||||
@ -934,13 +944,14 @@ die(SIGNAL_ARGS)
|
||||
int save_errno = errno;
|
||||
|
||||
/* Don't joggle the elbow of proc_exit */
|
||||
if (! proc_exit_inprogress)
|
||||
if (!proc_exit_inprogress)
|
||||
{
|
||||
InterruptPending = true;
|
||||
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)
|
||||
@ -968,15 +979,19 @@ QueryCancelHandler(SIGNAL_ARGS)
|
||||
{
|
||||
int save_errno = errno;
|
||||
|
||||
/* Don't joggle the elbow of proc_exit, nor an already-in-progress abort */
|
||||
/*
|
||||
* Don't joggle the elbow of proc_exit, nor an already-in-progress
|
||||
* abort
|
||||
*/
|
||||
if (!proc_exit_inprogress && !InError)
|
||||
{
|
||||
InterruptPending = true;
|
||||
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.
|
||||
* service the interrupt immediately. No point in interrupting if
|
||||
* we're waiting for input, however.
|
||||
*/
|
||||
if (ImmediateInterruptOK && InterruptHoldoffCount == 0 &&
|
||||
CritSectionCount == 0)
|
||||
@ -1032,14 +1047,14 @@ ProcessInterrupts(void)
|
||||
if (ProcDiePending)
|
||||
{
|
||||
ProcDiePending = false;
|
||||
QueryCancelPending = false; /* ProcDie trumps QueryCancel */
|
||||
ImmediateInterruptOK = false; /* not idle anymore */
|
||||
QueryCancelPending = false; /* ProcDie trumps QueryCancel */
|
||||
ImmediateInterruptOK = false; /* not idle anymore */
|
||||
elog(FATAL, "This connection has been terminated by an administrator");
|
||||
}
|
||||
if (QueryCancelPending)
|
||||
{
|
||||
QueryCancelPending = false;
|
||||
ImmediateInterruptOK = false; /* not idle anymore */
|
||||
ImmediateInterruptOK = false; /* not idle anymore */
|
||||
elog(ERROR, "Query was cancelled.");
|
||||
}
|
||||
/* If we get here, do nothing (probably, QueryCancelPending was reset) */
|
||||
@ -1065,7 +1080,7 @@ usage(char *progname)
|
||||
printf(" -F turn fsync off\n");
|
||||
printf(" -N do not use newline as interactive query delimiter\n");
|
||||
printf(" -o FILENAME send stdout and stderr to given file\n");
|
||||
printf(" -P disable system indexes\n");
|
||||
printf(" -P disable system indexes\n");
|
||||
printf(" -s show statistics after each query\n");
|
||||
printf(" -S SORT-MEM set amount of memory for sorts (in kbytes)\n");
|
||||
printf("Developer options:\n");
|
||||
@ -1082,7 +1097,7 @@ usage(char *progname)
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* PostgresMain
|
||||
* postgres main loop -- all backends, interactive or otherwise start here
|
||||
* postgres main loop -- all backends, interactive or otherwise start here
|
||||
*
|
||||
* argc/argv are the command line arguments to be used. When being forked
|
||||
* by the postmaster, these are not the original argv array of the process.
|
||||
@ -1092,11 +1107,11 @@ usage(char *progname)
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const char * username)
|
||||
PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const char *username)
|
||||
{
|
||||
int flag;
|
||||
|
||||
const char *DBName = NULL;
|
||||
const char *DBName = NULL;
|
||||
bool secure = true;
|
||||
int errs = 0;
|
||||
|
||||
@ -1106,25 +1121,25 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
|
||||
char *remote_host;
|
||||
unsigned short remote_port;
|
||||
|
||||
char *potential_DataDir = NULL;
|
||||
char *potential_DataDir = NULL;
|
||||
|
||||
/*
|
||||
* Catch standard options before doing much else. This even works
|
||||
* on systems without getopt_long.
|
||||
* Catch standard options before doing much else. This even works on
|
||||
* systems without getopt_long.
|
||||
*/
|
||||
if (!IsUnderPostmaster && argc > 1)
|
||||
{
|
||||
if (strcmp(argv[1], "--help")==0 || strcmp(argv[1], "-?")==0)
|
||||
if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
|
||||
{
|
||||
usage(argv[0]);
|
||||
exit(0);
|
||||
}
|
||||
if (strcmp(argv[1], "--version")==0 || strcmp(argv[1], "-V")==0)
|
||||
if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
|
||||
{
|
||||
puts("postgres (PostgreSQL) " PG_VERSION);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Fire up essential subsystems: error and memory management
|
||||
@ -1174,7 +1189,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
|
||||
|
||||
optind = 1; /* reset after postmaster's usage */
|
||||
|
||||
while ((flag = getopt(argc, argv, "A:B:c:CD:d:Eef:FiLNOPo:p:S:st:v:W:x:-:")) != EOF)
|
||||
while ((flag = getopt(argc, argv, "A:B:c:CD:d:Eef:FiLNOPo:p:S:st:v:W:x:-:")) != EOF)
|
||||
switch (flag)
|
||||
{
|
||||
case 'A':
|
||||
@ -1210,7 +1225,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
|
||||
case 'd': /* debug level */
|
||||
DebugLvl = atoi(optarg);
|
||||
if (DebugLvl >= 1);
|
||||
Log_connections = true;
|
||||
Log_connections = true;
|
||||
if (DebugLvl >= 2)
|
||||
Debug_print_query = true;
|
||||
if (DebugLvl >= 3)
|
||||
@ -1438,26 +1453,27 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
|
||||
|
||||
case 'c':
|
||||
case '-':
|
||||
{
|
||||
char *name, *value;
|
||||
|
||||
ParseLongOption(optarg, &name, &value);
|
||||
if (!value)
|
||||
{
|
||||
if (flag == '-')
|
||||
elog(ERROR, "--%s requires argument", optarg);
|
||||
else
|
||||
elog(ERROR, "-c %s requires argument", optarg);
|
||||
}
|
||||
char *name,
|
||||
*value;
|
||||
|
||||
/* all options are allowed if not under postmaster */
|
||||
SetConfigOption(name, value,
|
||||
(IsUnderPostmaster) ? PGC_BACKEND : PGC_POSTMASTER);
|
||||
free(name);
|
||||
if (value)
|
||||
free(value);
|
||||
break;
|
||||
}
|
||||
ParseLongOption(optarg, &name, &value);
|
||||
if (!value)
|
||||
{
|
||||
if (flag == '-')
|
||||
elog(ERROR, "--%s requires argument", optarg);
|
||||
else
|
||||
elog(ERROR, "-c %s requires argument", optarg);
|
||||
}
|
||||
|
||||
/* all options are allowed if not under postmaster */
|
||||
SetConfigOption(name, value,
|
||||
(IsUnderPostmaster) ? PGC_BACKEND : PGC_POSTMASTER);
|
||||
free(name);
|
||||
if (value)
|
||||
free(value);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
errs++;
|
||||
@ -1482,9 +1498,9 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
|
||||
if (!potential_DataDir)
|
||||
{
|
||||
fprintf(stderr, "%s does not know where to find the database system "
|
||||
"data. You must specify the directory that contains the "
|
||||
"database system either by specifying the -D invocation "
|
||||
"option or by setting the PGDATA environment variable.\n\n",
|
||||
"data. You must specify the directory that contains the "
|
||||
"database system either by specifying the -D invocation "
|
||||
"option or by setting the PGDATA environment variable.\n\n",
|
||||
argv[0]);
|
||||
proc_exit(1);
|
||||
}
|
||||
@ -1496,20 +1512,22 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
|
||||
* 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.
|
||||
* 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. If necessary, make a
|
||||
* dummy handler in the postmaster to reserve the signal.
|
||||
* the postmaster. If such a signal arrives before we are able to
|
||||
* change the handler to non-SIG_IGN, it'll get dropped. If
|
||||
* necessary, make a dummy handler in the postmaster to reserve the
|
||||
* signal.
|
||||
*/
|
||||
|
||||
pqsignal(SIGHUP, SigHupHandler); /* set flag to read config file */
|
||||
pqsignal(SIGINT, QueryCancelHandler); /* cancel current query */
|
||||
pqsignal(SIGINT, QueryCancelHandler); /* cancel current query */
|
||||
pqsignal(SIGTERM, die); /* cancel current query and exit */
|
||||
pqsignal(SIGQUIT, quickdie); /* hard crash time */
|
||||
pqsignal(SIGALRM, HandleDeadLock); /* check for deadlock after timeout */
|
||||
pqsignal(SIGQUIT, quickdie);/* hard crash time */
|
||||
pqsignal(SIGALRM, HandleDeadLock); /* check for deadlock after
|
||||
* timeout */
|
||||
|
||||
/*
|
||||
* Ignore failure to write to frontend. Note: if frontend closes
|
||||
@ -1518,13 +1536,15 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
|
||||
* midst of output during who-knows-what operation...
|
||||
*/
|
||||
pqsignal(SIGPIPE, SIG_IGN);
|
||||
pqsignal(SIGUSR1, SIG_IGN); /* this signal available for use */
|
||||
pqsignal(SIGUSR1, SIG_IGN); /* this signal available for use */
|
||||
pqsignal(SIGUSR2, Async_NotifyHandler); /* flush also sinval cache */
|
||||
pqsignal(SIGFPE, FloatExceptionHandler);
|
||||
pqsignal(SIGCHLD, SIG_IGN); /* ignored (may get this in system() calls) */
|
||||
pqsignal(SIGCHLD, SIG_IGN); /* ignored (may get this in system()
|
||||
* calls) */
|
||||
|
||||
/*
|
||||
* 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(SIGTTIN, SIG_DFL);
|
||||
pqsignal(SIGTTOU, SIG_DFL);
|
||||
@ -1549,7 +1569,8 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
|
||||
if (errs || argc != optind || DBName == NULL)
|
||||
{
|
||||
fprintf(stderr, "%s: invalid command line arguments\nTry -? for help.\n", argv[0]);
|
||||
proc_exit(0); /* not 1, that causes system-wide restart... */
|
||||
proc_exit(0); /* not 1, that causes system-wide
|
||||
* restart... */
|
||||
}
|
||||
pq_init(); /* initialize libpq at backend startup */
|
||||
whereToSendOutput = Remote;
|
||||
@ -1576,7 +1597,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
|
||||
/*
|
||||
* Create lockfile for data directory.
|
||||
*/
|
||||
if (! CreateDataDirLockFile(DataDir, false))
|
||||
if (!CreateDataDirLockFile(DataDir, false))
|
||||
proc_exit(1);
|
||||
|
||||
XLOGPathInit();
|
||||
@ -1613,7 +1634,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
|
||||
if (MyProcPort->raddr.sa.sa_family == AF_INET)
|
||||
{
|
||||
struct hostent *host_ent;
|
||||
char * host_addr;
|
||||
char *host_addr;
|
||||
|
||||
remote_port = ntohs(MyProcPort->raddr.in.sin_port);
|
||||
host_addr = inet_ntoa(MyProcPort->raddr.in.sin_addr);
|
||||
@ -1634,23 +1655,25 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
|
||||
|
||||
if (ShowPortNumber)
|
||||
{
|
||||
char * str = palloc(strlen(remote_host) + 7);
|
||||
char *str = palloc(strlen(remote_host) + 7);
|
||||
|
||||
sprintf(str, "%s:%hu", remote_host, remote_port);
|
||||
pfree(remote_host);
|
||||
remote_host = str;
|
||||
}
|
||||
}
|
||||
else /* not AF_INET */
|
||||
else
|
||||
/* not AF_INET */
|
||||
remote_host = "[local]";
|
||||
|
||||
|
||||
/*
|
||||
* Set process parameters for ps
|
||||
*
|
||||
* WARNING: On some platforms the environment will be moved
|
||||
* around to make room for the ps display string. So any
|
||||
* references to optarg or getenv() from above will be invalid
|
||||
* after this call. Better use strdup or something similar.
|
||||
* WARNING: On some platforms the environment will be moved around to
|
||||
* make room for the ps display string. So any references to
|
||||
* optarg or getenv() from above will be invalid after this call.
|
||||
* Better use strdup or something similar.
|
||||
*/
|
||||
init_ps_display(real_argc, real_argv, username, DBName, remote_host);
|
||||
set_ps_display("startup");
|
||||
@ -1692,16 +1715,16 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
|
||||
if (!IsUnderPostmaster)
|
||||
{
|
||||
puts("\nPOSTGRES backend interactive interface ");
|
||||
puts("$Revision: 1.212 $ $Date: 2001/03/14 18:24:34 $\n");
|
||||
puts("$Revision: 1.213 $ $Date: 2001/03/22 03:59:47 $\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the memory context we will use in the main loop.
|
||||
*
|
||||
* QueryContext is reset once per iteration of the main loop,
|
||||
* ie, upon completion of processing of each supplied query string.
|
||||
* It can therefore be used for any data that should live just as
|
||||
* long as the query string --- parse trees, for example.
|
||||
* QueryContext is reset once per iteration of the main loop, ie, upon
|
||||
* completion of processing of each supplied query string. It can
|
||||
* therefore be used for any data that should live just as long as the
|
||||
* query string --- parse trees, for example.
|
||||
*/
|
||||
QueryContext = AllocSetContextCreate(TopMemoryContext,
|
||||
"QueryContext",
|
||||
@ -1718,10 +1741,11 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
|
||||
|
||||
if (sigsetjmp(Warn_restart, 1) != 0)
|
||||
{
|
||||
|
||||
/*
|
||||
* NOTE: if you are tempted to add more code in this if-block,
|
||||
* consider the probability that it should be in AbortTransaction()
|
||||
* instead.
|
||||
* consider the probability that it should be in
|
||||
* AbortTransaction() instead.
|
||||
*
|
||||
* Make sure we're not interrupted while cleaning up. Also forget
|
||||
* any pending QueryCancel request, since we're aborting anyway.
|
||||
@ -1776,9 +1800,10 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
|
||||
|
||||
for (;;)
|
||||
{
|
||||
|
||||
/*
|
||||
* Release storage left over from prior query cycle, and
|
||||
* create a new query input buffer in the cleared QueryContext.
|
||||
* Release storage left over from prior query cycle, and create a
|
||||
* new query input buffer in the cleared QueryContext.
|
||||
*/
|
||||
MemoryContextSwitchTo(QueryContext);
|
||||
MemoryContextResetAndDeleteChildren(QueryContext);
|
||||
@ -1804,7 +1829,8 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
|
||||
* Then set up other stuff needed before blocking for input.
|
||||
* ----------------
|
||||
*/
|
||||
QueryCancelPending = false; /* forget any earlier CANCEL signal */
|
||||
QueryCancelPending = false; /* forget any earlier CANCEL
|
||||
* signal */
|
||||
|
||||
EnableNotifyInterrupt();
|
||||
|
||||
@ -1825,7 +1851,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
|
||||
* ----------------
|
||||
*/
|
||||
ImmediateInterruptOK = false;
|
||||
QueryCancelPending = false; /* forget any CANCEL signal */
|
||||
QueryCancelPending = false; /* forget any CANCEL signal */
|
||||
|
||||
DisableNotifyInterrupt();
|
||||
|
||||
@ -1912,10 +1938,11 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
|
||||
*/
|
||||
case 'X':
|
||||
case EOF:
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
@ -1926,11 +1953,12 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
|
||||
}
|
||||
|
||||
#ifdef MEMORY_CONTEXT_CHECKING
|
||||
|
||||
/*
|
||||
* Check all memory after each backend loop. This is a rather
|
||||
* weird place to do it, perhaps.
|
||||
*/
|
||||
MemoryContextCheck(TopMemoryContext);
|
||||
MemoryContextCheck(TopMemoryContext);
|
||||
#endif
|
||||
} /* end of input-reading loop */
|
||||
|
||||
|
Reference in New Issue
Block a user