29#if defined(__NetBSD__)
59 "array length mismatch");
62static void init_locale(
const char *categoryname,
int category,
const char *
locale);
71main(
int argc,
char *argv[])
73 bool do_check_root =
true;
166 if (strcmp(argv[1],
"--help") == 0 || strcmp(argv[1],
"-?") == 0)
171 if (strcmp(argv[1],
"--version") == 0 || strcmp(argv[1],
"-V") == 0)
187 if (strcmp(argv[1],
"--describe-config") == 0)
188 do_check_root =
false;
189 else if (argc > 2 && strcmp(argv[1],
"-C") == 0)
190 do_check_root =
false;
204 if (argc > 1 && argv[1][0] ==
'-' && argv[1][1] ==
'-')
207 switch (dispatch_option)
217 SubPostmasterMain(argc, argv);
294 setvbuf(
stdout, NULL, _IONBF, 0);
295 setvbuf(stderr, NULL, _IONBF, 0);
298 err = WSAStartup(MAKEWORD(2, 2), &wsaData);
316#if !defined(__MINGW32__) && !defined(__MINGW64__)
317 _set_abort_behavior(_CALL_REPORTFAULT | _WRITE_ABORT_MSG,
318 _CALL_REPORTFAULT | _WRITE_ABORT_MSG);
333 SetErrorMode(SEM_FAILCRITICALERRORS);
339 _set_error_mode(_OUT_TO_STDERR);
349 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
350 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
351 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
352 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
353 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
354 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
372 elog(
FATAL,
"could not adopt \"%s\" locale nor C locale for %s",
392 printf(
_(
" -B NBUFFERS number of shared buffers\n"));
393 printf(
_(
" -c NAME=VALUE set run-time parameter\n"));
394 printf(
_(
" -C NAME print value of run-time parameter, then exit\n"));
395 printf(
_(
" -d 1-5 debugging level\n"));
396 printf(
_(
" -D DATADIR database directory\n"));
397 printf(
_(
" -e use European date input format (DMY)\n"));
398 printf(
_(
" -F turn fsync off\n"));
399 printf(
_(
" -h HOSTNAME host name or IP address to listen on\n"));
400 printf(
_(
" -i enable TCP/IP connections (deprecated)\n"));
401 printf(
_(
" -k DIRECTORY Unix-domain socket location\n"));
403 printf(
_(
" -l enable SSL connections\n"));
405 printf(
_(
" -N MAX-CONNECT maximum number of allowed connections\n"));
406 printf(
_(
" -p PORT port number to listen on\n"));
407 printf(
_(
" -s show statistics after each query\n"));
408 printf(
_(
" -S WORK-MEM set amount of memory for sorts (in kB)\n"));
409 printf(
_(
" -V, --version output version information, then exit\n"));
410 printf(
_(
" --NAME=VALUE set run-time parameter\n"));
411 printf(
_(
" --describe-config describe configuration parameters, then exit\n"));
412 printf(
_(
" -?, --help show this help, then exit\n"));
414 printf(
_(
"\nDeveloper options:\n"));
415 printf(
_(
" -f s|i|o|b|t|n|m|h forbid use of some plan types\n"));
416 printf(
_(
" -O allow system table structure changes\n"));
417 printf(
_(
" -P disable system indexes\n"));
418 printf(
_(
" -t pa|pl|ex show timings after each query\n"));
419 printf(
_(
" -T send SIGABRT to all backend processes if one dies\n"));
420 printf(
_(
" -W NUM wait NUM seconds to allow attach from a debugger\n"));
422 printf(
_(
"\nOptions for single-user mode:\n"));
423 printf(
_(
" --single selects single-user mode (must be first argument)\n"));
424 printf(
_(
" DBNAME database name (defaults to user name)\n"));
425 printf(
_(
" -d 0-5 override debugging level\n"));
426 printf(
_(
" -E echo statement before execution\n"));
427 printf(
_(
" -j do not use newline as interactive query delimiter\n"));
428 printf(
_(
" -r FILENAME send stdout and stderr to given file\n"));
430 printf(
_(
"\nOptions for bootstrapping mode:\n"));
431 printf(
_(
" --boot selects bootstrapping mode (must be first argument)\n"));
432 printf(
_(
" --check selects check mode (must be first argument)\n"));
433 printf(
_(
" DBNAME database name (mandatory argument in bootstrapping mode)\n"));
434 printf(
_(
" -r FILENAME send stdout and stderr to given file\n"));
436 printf(
_(
"\nPlease read the documentation for the complete list of run-time\n"
437 "configuration settings and how to set them on the command line or in\n"
438 "the configuration file.\n\n"
439 "Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
440 printf(
_(
"%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
451 write_stderr(
"\"root\" execution of the PostgreSQL server is not permitted.\n"
452 "The server must be started under an unprivileged user ID to prevent\n"
453 "possible system security compromise. See the documentation for\n"
454 "more information on how to properly start the server.\n");
466 if (getuid() != geteuid())
468 write_stderr(
"%s: real and effective user IDs must match\n",
475 write_stderr(
"Execution of PostgreSQL by a user with administrative permissions is not\n"
477 "The server must be started under an unprivileged user ID to prevent\n"
478 "possible system security compromises. See the documentation for\n"
479 "more information on how to properly start the server.\n");
509 return getenv(
"UBSAN_OPTIONS");
#define write_stderr(str)
void BootstrapModeMain(int argc, char *argv[], bool check_only)
#define Assert(condition)
#define PG_TEXTDOMAIN(domain)
void set_pglocale_pgservice(const char *argv0, const char *app)
void pgwin32_install_crashdump_handler(void)
void err(int eval, const char *fmt,...)
static void init_locale(const char *categoryname, int category, const char *locale)
static void check_root(const char *progname)
int main(int argc, char *argv[])
const char * __ubsan_default_options(void)
static void help(const char *progname)
StaticAssertDecl(lengthof(DispatchOptionNames)==DISPATCH_POSTMASTER, "array length mismatch")
static void startup_hacks(const char *progname)
static const char *const DispatchOptionNames[]
DispatchOption parse_dispatch_option(const char *name)
void MemoryContextInit(void)
char * pg_perm_setlocale(int category, const char *locale)
#define PG_BACKEND_VERSIONSTR
const char * get_progname(const char *argv0)
void PostgresSingleUserMain(int argc, char *argv[], const char *username)
void PostmasterMain(int argc, char *argv[])
@ DISPATCH_DESCRIBE_CONFIG
char ** save_ps_display_args(int argc, char **argv)
pg_stack_base_t set_stack_base(void)
const char * get_user_name_or_exit(const char *progname)
int pgwin32_is_admin(void)