---------------------------------------------------------------- * 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
| 4992 | * ---------------------------------------------------------------- |
| 4993 | */ |
| 4994 | void |
| 4995 | PostgresMain(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 | { |
no test coverage detected