29 #if defined(__NetBSD__)
49 static void init_locale(
const char *categoryname,
int category,
const char *
locale);
58 main(
int argc,
char *argv[])
60 bool do_check_root =
true;
145 if (strcmp(argv[1],
"--help") == 0 || strcmp(argv[1],
"-?") == 0)
150 if (strcmp(argv[1],
"--version") == 0 || strcmp(argv[1],
"-V") == 0)
166 if (strcmp(argv[1],
"--describe-config") == 0)
167 do_check_root =
false;
168 else if (argc > 2 && strcmp(argv[1],
"-C") == 0)
169 do_check_root =
false;
183 if (argc > 1 && strcmp(argv[1],
"--check") == 0)
185 else if (argc > 1 && strcmp(argv[1],
"--boot") == 0)
188 else if (argc > 1 && strncmp(argv[1],
"--fork", 6) == 0)
189 SubPostmasterMain(argc, argv);
191 else if (argc > 1 && strcmp(argv[1],
"--describe-config") == 0)
193 else if (argc > 1 && strcmp(argv[1],
"--single") == 0)
227 setvbuf(
stdout, NULL, _IONBF, 0);
228 setvbuf(stderr, NULL, _IONBF, 0);
231 err = WSAStartup(MAKEWORD(2, 2), &wsaData);
249 #if !defined(__MINGW32__) && !defined(__MINGW64__)
250 _set_abort_behavior(_CALL_REPORTFAULT | _WRITE_ABORT_MSG,
251 _CALL_REPORTFAULT | _WRITE_ABORT_MSG);
266 SetErrorMode(SEM_FAILCRITICALERRORS);
272 _set_error_mode(_OUT_TO_STDERR);
282 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
283 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
284 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
285 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
286 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
287 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
305 elog(
FATAL,
"could not adopt \"%s\" locale nor C locale for %s",
325 printf(
_(
" -B NBUFFERS number of shared buffers\n"));
326 printf(
_(
" -c NAME=VALUE set run-time parameter\n"));
327 printf(
_(
" -C NAME print value of run-time parameter, then exit\n"));
328 printf(
_(
" -d 1-5 debugging level\n"));
329 printf(
_(
" -D DATADIR database directory\n"));
330 printf(
_(
" -e use European date input format (DMY)\n"));
331 printf(
_(
" -F turn fsync off\n"));
332 printf(
_(
" -h HOSTNAME host name or IP address to listen on\n"));
333 printf(
_(
" -i enable TCP/IP connections (deprecated)\n"));
334 printf(
_(
" -k DIRECTORY Unix-domain socket location\n"));
336 printf(
_(
" -l enable SSL connections\n"));
338 printf(
_(
" -N MAX-CONNECT maximum number of allowed connections\n"));
339 printf(
_(
" -p PORT port number to listen on\n"));
340 printf(
_(
" -s show statistics after each query\n"));
341 printf(
_(
" -S WORK-MEM set amount of memory for sorts (in kB)\n"));
342 printf(
_(
" -V, --version output version information, then exit\n"));
343 printf(
_(
" --NAME=VALUE set run-time parameter\n"));
344 printf(
_(
" --describe-config describe configuration parameters, then exit\n"));
345 printf(
_(
" -?, --help show this help, then exit\n"));
347 printf(
_(
"\nDeveloper options:\n"));
348 printf(
_(
" -f s|i|o|b|t|n|m|h forbid use of some plan types\n"));
349 printf(
_(
" -O allow system table structure changes\n"));
350 printf(
_(
" -P disable system indexes\n"));
351 printf(
_(
" -t pa|pl|ex show timings after each query\n"));
352 printf(
_(
" -T send SIGABRT to all backend processes if one dies\n"));
353 printf(
_(
" -W NUM wait NUM seconds to allow attach from a debugger\n"));
355 printf(
_(
"\nOptions for single-user mode:\n"));
356 printf(
_(
" --single selects single-user mode (must be first argument)\n"));
357 printf(
_(
" DBNAME database name (defaults to user name)\n"));
358 printf(
_(
" -d 0-5 override debugging level\n"));
359 printf(
_(
" -E echo statement before execution\n"));
360 printf(
_(
" -j do not use newline as interactive query delimiter\n"));
361 printf(
_(
" -r FILENAME send stdout and stderr to given file\n"));
363 printf(
_(
"\nOptions for bootstrapping mode:\n"));
364 printf(
_(
" --boot selects bootstrapping mode (must be first argument)\n"));
365 printf(
_(
" --check selects check mode (must be first argument)\n"));
366 printf(
_(
" DBNAME database name (mandatory argument in bootstrapping mode)\n"));
367 printf(
_(
" -r FILENAME send stdout and stderr to given file\n"));
369 printf(
_(
"\nPlease read the documentation for the complete list of run-time\n"
370 "configuration settings and how to set them on the command line or in\n"
371 "the configuration file.\n\n"
372 "Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
373 printf(
_(
"%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
384 write_stderr(
"\"root\" execution of the PostgreSQL server is not permitted.\n"
385 "The server must be started under an unprivileged user ID to prevent\n"
386 "possible system security compromise. See the documentation for\n"
387 "more information on how to properly start the server.\n");
399 if (getuid() != geteuid())
401 write_stderr(
"%s: real and effective user IDs must match\n",
408 write_stderr(
"Execution of PostgreSQL by a user with administrative permissions is not\n"
410 "The server must be started under an unprivileged user ID to prevent\n"
411 "possible system security compromises. See the documentation for\n"
412 "more information on how to properly start the server.\n");
442 return getenv(
"UBSAN_OPTIONS");
#define write_stderr(str)
void BootstrapModeMain(int argc, char *argv[], bool check_only)
#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)
static void startup_hacks(const char *progname)
void MemoryContextInit(void)
char * pg_perm_setlocale(int category, const char *locale)
const char * get_progname(const char *argv0)
#define PG_BACKEND_VERSIONSTR
void PostgresSingleUserMain(int argc, char *argv[], const char *username)
void PostmasterMain(int argc, char *argv[])
char ** save_ps_display_args(int argc, char **argv)
const char * get_user_name_or_exit(const char *progname)
int pgwin32_is_admin(void)