MCPcopy Create free account
hub / github.com/apache/cloudberry / PostgresMain

Function PostgresMain

src/backend/tcop/postgres.c:4994–6200  ·  view source on GitHub ↗

---------------------------------------------------------------- * PostgresMain * 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.) * dbname is the name of the database to connect to, or NULL if the database * name

Source from the content-addressed store, hash-verified

4992 * ----------------------------------------------------------------
4993 */
4994void
4995PostgresMain(int argc, char *argv[],
4996 const char *dbname,
4997 const char *username)
4998{
4999 int firstchar;
5000 StringInfoData input_message;
5001 sigjmp_buf local_sigjmp_buf;
5002 volatile bool send_ready_for_query = true;
5003 bool idle_in_transaction_timeout_enabled = false;
5004 bool idle_session_timeout_enabled = false;
5005
5006 /*
5007 * CDB: Catch program error signals.
5008 *
5009 * Save our main thread-id for comparison during signals.
5010 */
5011 main_tid = pthread_self();
5012
5013 /* Initialize startup process environment if necessary. */
5014 if (!IsUnderPostmaster)
5015 InitStandaloneProcess(argv[0]);
5016
5017#ifndef WIN32
5018 PostmasterPriority = getpriority(PRIO_PROCESS, 0);
5019#endif
5020
5021 set_ps_display("startup");
5022
5023 SetProcessingMode(InitProcessing);
5024
5025 /*
5026 * Set default values for command-line options.
5027 */
5028 EchoQuery = false;
5029
5030 if (!IsUnderPostmaster)
5031 InitializeGUCOptions();
5032
5033 /*
5034 * Parse command-line options.
5035 */
5036 process_postgres_switches(argc, argv, PGC_POSTMASTER, &dbname);
5037
5038 /* Must have gotten a database name, or have a default (the username) */
5039 if (dbname == NULL)
5040 {
5041 dbname = username;
5042 if (dbname == NULL)
5043 ereport(FATAL,
5044 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5045 errmsg("%s: no database nor user name specified",
5046 progname)));
5047 }
5048
5049 /* Acquire configuration parameters, unless inherited from postmaster */
5050 if (!IsUnderPostmaster)
5051 {

Callers 2

mainFunction · 0.85
BackendRunFunction · 0.85

Calls 15

pthread_selfFunction · 0.85
InitStandaloneProcessFunction · 0.85
set_ps_displayFunction · 0.85
InitializeGUCOptionsFunction · 0.85
SelectConfigFilesFunction · 0.85
proc_exitFunction · 0.85
GetCurrentTimestampFunction · 0.85
WalSndSignalsFunction · 0.85
InitializeTimeoutsFunction · 0.85
checkDataDirFunction · 0.85
ChangeToDataDirFunction · 0.85

Tested by

no test coverage detected