mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Merge postmaster and postgres command into just postgres. postmaster
symlink is kept for now for compatibility. To call single-user mode, use postgres --single.
This commit is contained in:
@ -4,11 +4,11 @@
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.114 2006/01/05 01:56:29 momjian Exp $
|
||||
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.115 2006/06/18 15:38:36 petere Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
PGFILEDESC = "PostgreSQL Database Backend"
|
||||
PGFILEDESC = "PostgreSQL Server"
|
||||
subdir = src/backend
|
||||
top_builddir = ../..
|
||||
include $(top_builddir)/src/Makefile.global
|
||||
|
@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.216 2006/06/08 23:55:48 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.217 2006/06/18 15:38:36 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -53,7 +53,6 @@ extern char *optarg;
|
||||
|
||||
#define ALLOC(t, c) ((t *) calloc((unsigned)(c), sizeof(t)))
|
||||
|
||||
static void usage(void);
|
||||
static void bootstrap_signals(void);
|
||||
static void ShutdownDummyProcess(int code, Datum arg);
|
||||
static hashnode *AddStr(char *str, int strlength, int mderef);
|
||||
@ -247,8 +246,8 @@ BootstrapMain(int argc, char *argv[])
|
||||
if (!IsUnderPostmaster)
|
||||
InitializeGUCOptions();
|
||||
|
||||
/* Ignore the initial -boot argument, if present */
|
||||
if (argc > 1 && strcmp(argv[1], "-boot") == 0)
|
||||
/* Ignore the initial --boot argument, if present */
|
||||
if (argc > 1 && strcmp(argv[1], "--boot") == 0)
|
||||
{
|
||||
argv++;
|
||||
argc--;
|
||||
@ -317,7 +316,9 @@ BootstrapMain(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
default:
|
||||
usage();
|
||||
write_stderr("Try \"%s --help\" for more information.\n",
|
||||
progname);
|
||||
proc_exit(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -328,7 +329,10 @@ BootstrapMain(int argc, char *argv[])
|
||||
optind++;
|
||||
}
|
||||
if (!dbname || argc != optind)
|
||||
usage();
|
||||
{
|
||||
write_stderr("%s: invalid command-line arguments\n", progname);
|
||||
proc_exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Identify myself via ps
|
||||
@ -498,26 +502,6 @@ BootstrapMain(int argc, char *argv[])
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* usage:
|
||||
* usage help for the bootstrap backend
|
||||
*/
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, _("This is the PostgreSQL bootstrap process.\n\n"));
|
||||
fprintf(stderr, _("Usage:\n postgres -boot [OPTION]... DBNAME\n\n"));
|
||||
fprintf(stderr, _("Options:\n"));
|
||||
fprintf(stderr, _(" -B NBUFFERS number of shared buffers\n"));
|
||||
fprintf(stderr, _(" -c NAME=VALUE set run-time parameter\n"));
|
||||
fprintf(stderr, _(" -d 1-5 debugging level\n"));
|
||||
fprintf(stderr, _(" -D DATADIR database directory\n"));
|
||||
fprintf(stderr, _(" -F turn fsync off\n"));
|
||||
fprintf(stderr, _(" -r FILENAME send stdout and stderr to given file\n"));
|
||||
fprintf(stderr, _(" -x NUM internal use\n"));
|
||||
|
||||
proc_exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up signal handling for a bootstrap process
|
||||
*/
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.102 2006/06/12 16:17:20 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.103 2006/06/18 15:38:37 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -29,6 +29,7 @@
|
||||
#include <sys/proc.h>
|
||||
#undef ASSEMBLER
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
@ -45,88 +46,26 @@
|
||||
#include "libpq/pqsignal.h"
|
||||
#endif
|
||||
|
||||
|
||||
const char *progname;
|
||||
|
||||
|
||||
static void startup_hacks(const char *progname);
|
||||
static void help(const char *progname);
|
||||
static void check_root(const char *progname);
|
||||
static char *get_current_username(const char *progname);
|
||||
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
#ifndef WIN32
|
||||
struct passwd *pw;
|
||||
#endif
|
||||
char *pw_name_persist;
|
||||
|
||||
/*
|
||||
* Place platform-specific startup hacks here. This is the right place to
|
||||
* put code that must be executed early in launch of either a postmaster,
|
||||
* a standalone backend, or a standalone bootstrap run. Note that this
|
||||
* code will NOT be executed when a backend or sub-bootstrap run is forked
|
||||
* by the postmaster.
|
||||
*
|
||||
* XXX The need for code here is proof that the platform in question is
|
||||
* too brain-dead to provide a standard C execution environment without
|
||||
* help. Avoid adding more here, if you can.
|
||||
*/
|
||||
|
||||
#if defined(__alpha) /* no __alpha__ ? */
|
||||
#ifdef NOFIXADE
|
||||
int buffer[] = {SSIN_UACPROC, UAC_SIGBUS | UAC_NOPRINT};
|
||||
#endif
|
||||
#endif /* __alpha */
|
||||
|
||||
#ifdef WIN32
|
||||
char *env_locale;
|
||||
#endif
|
||||
|
||||
progname = get_progname(argv[0]);
|
||||
|
||||
/*
|
||||
* On some platforms, unaligned memory accesses result in a kernel trap;
|
||||
* the default kernel behavior is to emulate the memory access, but this
|
||||
* results in a significant performance penalty. We ought to fix PG not to
|
||||
* make such unaligned memory accesses, so this code disables the kernel
|
||||
* emulation: unaligned accesses will result in SIGBUS instead.
|
||||
*/
|
||||
#ifdef NOFIXADE
|
||||
|
||||
#if defined(ultrix4)
|
||||
syscall(SYS_sysmips, MIPS_FIXADE, 0, NULL, NULL, NULL);
|
||||
#endif
|
||||
|
||||
#if defined(__alpha) /* no __alpha__ ? */
|
||||
if (setsysinfo(SSI_NVPAIRS, buffer, 1, (caddr_t) NULL,
|
||||
(unsigned long) NULL) < 0)
|
||||
write_stderr("%s: setsysinfo failed: %s\n",
|
||||
argv[0], strerror(errno));
|
||||
#endif
|
||||
#endif /* NOFIXADE */
|
||||
|
||||
#if defined(WIN32)
|
||||
{
|
||||
WSADATA wsaData;
|
||||
int err;
|
||||
|
||||
/* Make output streams unbuffered by default */
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
setvbuf(stderr, NULL, _IONBF, 0);
|
||||
|
||||
/* Prepare Winsock */
|
||||
err = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
if (err != 0)
|
||||
{
|
||||
write_stderr("%s: WSAStartup failed: %d\n",
|
||||
argv[0], err);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* In case of general protection fault, don't show GUI popup box */
|
||||
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Not-quite-so-platform-specific startup environment checks. Still best
|
||||
* to minimize these.
|
||||
* Platform-specific startup hacks
|
||||
*/
|
||||
startup_hacks(progname);
|
||||
|
||||
/*
|
||||
* Remember the physical location of the initially given argv[] array for
|
||||
@ -153,23 +92,25 @@ main(int argc, char *argv[])
|
||||
set_pglocale_pgservice(argv[0], "postgres");
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
/*
|
||||
* Windows uses codepages rather than the environment, so we work around
|
||||
* that by querying the environment explicitly first for LC_COLLATE and
|
||||
* LC_CTYPE. We have to do this because initdb passes those values in the
|
||||
* environment. If there is nothing there we fall back on the codepage.
|
||||
*/
|
||||
{
|
||||
char *env_locale;
|
||||
|
||||
if ((env_locale = getenv("LC_COLLATE")) != NULL)
|
||||
pg_perm_setlocale(LC_COLLATE, env_locale);
|
||||
else
|
||||
pg_perm_setlocale(LC_COLLATE, "");
|
||||
if ((env_locale = getenv("LC_COLLATE")) != NULL)
|
||||
pg_perm_setlocale(LC_COLLATE, env_locale);
|
||||
else
|
||||
pg_perm_setlocale(LC_COLLATE, "");
|
||||
|
||||
if ((env_locale = getenv("LC_CTYPE")) != NULL)
|
||||
pg_perm_setlocale(LC_CTYPE, env_locale);
|
||||
else
|
||||
pg_perm_setlocale(LC_CTYPE, "");
|
||||
if ((env_locale = getenv("LC_CTYPE")) != NULL)
|
||||
pg_perm_setlocale(LC_CTYPE, env_locale);
|
||||
else
|
||||
pg_perm_setlocale(LC_CTYPE, "");
|
||||
}
|
||||
#else
|
||||
pg_perm_setlocale(LC_COLLATE, "");
|
||||
pg_perm_setlocale(LC_CTYPE, "");
|
||||
@ -195,80 +136,38 @@ main(int argc, char *argv[])
|
||||
unsetenv("LC_ALL");
|
||||
|
||||
/*
|
||||
* Skip permission checks if we're just trying to do --help or --version;
|
||||
* otherwise root will get unhelpful failure messages from initdb.
|
||||
* Catch standard options before doing much else
|
||||
*/
|
||||
if (!(argc > 1
|
||||
&& (strcmp(argv[1], "--help") == 0 ||
|
||||
strcmp(argv[1], "-?") == 0 ||
|
||||
strcmp(argv[1], "--version") == 0 ||
|
||||
strcmp(argv[1], "-V") == 0)))
|
||||
if (argc > 1)
|
||||
{
|
||||
#ifndef WIN32
|
||||
/*
|
||||
* Make sure we are not running as root.
|
||||
*/
|
||||
if (geteuid() == 0)
|
||||
if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
|
||||
{
|
||||
write_stderr("\"root\" execution of the PostgreSQL server is not permitted.\n"
|
||||
"The server must be started under an unprivileged user ID to prevent\n"
|
||||
"possible system security compromise. See the documentation for\n"
|
||||
"more information on how to properly start the server.\n");
|
||||
exit(1);
|
||||
help(progname);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Also make sure that real and effective uids are the same. Executing
|
||||
* Postgres as a setuid program from a root shell is a security hole,
|
||||
* since on many platforms a nefarious subroutine could setuid back to
|
||||
* root if real uid is root. (Since nobody actually uses Postgres as
|
||||
* a setuid program, trying to actively fix this situation seems more
|
||||
* trouble than it's worth; we'll just expend the effort to check for
|
||||
* it.)
|
||||
*/
|
||||
if (getuid() != geteuid())
|
||||
if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
|
||||
{
|
||||
write_stderr("%s: real and effective user IDs must match\n",
|
||||
argv[0]);
|
||||
exit(1);
|
||||
puts("postgres (PostgreSQL) " PG_VERSION);
|
||||
exit(0);
|
||||
}
|
||||
#else /* WIN32 */
|
||||
if (pgwin32_is_admin())
|
||||
{
|
||||
write_stderr("Execution of PostgreSQL by a user with administrative permissions is not\n"
|
||||
"permitted.\n"
|
||||
"The server must be started under an unprivileged user ID to prevent\n"
|
||||
"possible system security compromises. See the documentation for\n"
|
||||
"more information on how to properly start the server.\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif /* !WIN32 */
|
||||
}
|
||||
|
||||
/*
|
||||
* Now dispatch to one of PostmasterMain, PostgresMain, GucInfoMain,
|
||||
* SubPostmasterMain, or BootstrapMain depending on the program name (and
|
||||
* possibly first argument) we were called with. The lack of consistency
|
||||
* here is historical.
|
||||
* Make sure we are not running as root.
|
||||
*/
|
||||
if (strcmp(progname, "postmaster") == 0)
|
||||
{
|
||||
/* Called as "postmaster" */
|
||||
exit(PostmasterMain(argc, argv));
|
||||
}
|
||||
check_root(progname);
|
||||
|
||||
/*
|
||||
* If the first argument begins with "-fork", then invoke
|
||||
* SubPostmasterMain. This is used for forking postmaster child processes
|
||||
* on systems where we can't simply fork.
|
||||
* Dispatch to one of various subprograms depending on first
|
||||
* argument.
|
||||
*/
|
||||
|
||||
#ifdef EXEC_BACKEND
|
||||
if (argc > 1 && strncmp(argv[1], "-fork", 5) == 0)
|
||||
if (argc > 1 && strncmp(argv[1], "--fork", 6) == 0)
|
||||
exit(SubPostmasterMain(argc, argv));
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
/*
|
||||
* Start our win32 signal implementation
|
||||
*
|
||||
@ -278,47 +177,223 @@ main(int argc, char *argv[])
|
||||
pgwin32_signal_initialize();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If the first argument is "-boot", then invoke bootstrap mode. (This
|
||||
* path is taken only for a standalone bootstrap process.)
|
||||
*/
|
||||
if (argc > 1 && strcmp(argv[1], "-boot") == 0)
|
||||
if (argc > 1 && strcmp(argv[1], "--boot") == 0)
|
||||
exit(BootstrapMain(argc, argv));
|
||||
|
||||
/*
|
||||
* If the first argument is "--describe-config", then invoke runtime
|
||||
* configuration option display mode.
|
||||
*/
|
||||
if (argc > 1 && strcmp(argv[1], "--describe-config") == 0)
|
||||
exit(GucInfoMain());
|
||||
|
||||
if (argc > 1 && strcmp(argv[1], "--single") == 0)
|
||||
exit(PostgresMain(argc, argv, get_current_username(progname)));
|
||||
|
||||
exit(PostmasterMain(argc, argv));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Place platform-specific startup hacks here. This is the right
|
||||
* place to put code that must be executed early in launch of either a
|
||||
* postmaster, a standalone backend, or a standalone bootstrap run.
|
||||
* Note that this code will NOT be executed when a backend or
|
||||
* sub-bootstrap run is forked by the server.
|
||||
*
|
||||
* XXX The need for code here is proof that the platform in question
|
||||
* is too brain-dead to provide a standard C execution environment
|
||||
* without help. Avoid adding more here, if you can.
|
||||
*/
|
||||
static void
|
||||
startup_hacks(const char *progname)
|
||||
{
|
||||
#if defined(__alpha) /* no __alpha__ ? */
|
||||
#ifdef NOFIXADE
|
||||
int buffer[] = {SSIN_UACPROC, UAC_SIGBUS | UAC_NOPRINT};
|
||||
#endif
|
||||
#endif /* __alpha */
|
||||
|
||||
|
||||
/*
|
||||
* Otherwise we're a standalone backend. Invoke PostgresMain, specifying
|
||||
* current userid as the "authenticated" Postgres user name.
|
||||
* On some platforms, unaligned memory accesses result in a kernel
|
||||
* trap; the default kernel behavior is to emulate the memory
|
||||
* access, but this results in a significant performance penalty.
|
||||
* We ought to fix PG not to make such unaligned memory accesses,
|
||||
* so this code disables the kernel emulation: unaligned accesses
|
||||
* will result in SIGBUS instead.
|
||||
*/
|
||||
#ifdef NOFIXADE
|
||||
|
||||
#if defined(ultrix4)
|
||||
syscall(SYS_sysmips, MIPS_FIXADE, 0, NULL, NULL, NULL);
|
||||
#endif
|
||||
|
||||
#if defined(__alpha) /* no __alpha__ ? */
|
||||
if (setsysinfo(SSI_NVPAIRS, buffer, 1, (caddr_t) NULL,
|
||||
(unsigned long) NULL) < 0)
|
||||
write_stderr("%s: setsysinfo failed: %s\n",
|
||||
progname, strerror(errno));
|
||||
#endif
|
||||
|
||||
#endif /* NOFIXADE */
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
{
|
||||
WSADATA wsaData;
|
||||
int err;
|
||||
|
||||
/* Make output streams unbuffered by default */
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
setvbuf(stderr, NULL, _IONBF, 0);
|
||||
|
||||
/* Prepare Winsock */
|
||||
err = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
if (err != 0)
|
||||
{
|
||||
write_stderr("%s: WSAStartup failed: %d\n",
|
||||
progname, err);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* In case of general protection fault, don't show GUI popup box */
|
||||
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
|
||||
}
|
||||
#endif /* WIN32 */
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
help(const char *progname)
|
||||
{
|
||||
printf(_("%s is the PostgreSQL server.\n\n"), progname);
|
||||
printf(_("Usage:\n %s [OPTION]...\n\n"), progname);
|
||||
printf(_("Options:\n"));
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
printf(_(" -A 1|0 enable/disable run-time assert checking\n"));
|
||||
#endif
|
||||
printf(_(" -B NBUFFERS number of shared buffers\n"));
|
||||
printf(_(" -c NAME=VALUE set run-time parameter\n"));
|
||||
printf(_(" -d 1-5 debugging level\n"));
|
||||
printf(_(" -D DATADIR database directory\n"));
|
||||
printf(_(" -e use European date input format (DMY)\n"));
|
||||
printf(_(" -F turn fsync off\n"));
|
||||
printf(_(" -h HOSTNAME host name or IP address to listen on\n"));
|
||||
printf(_(" -i enable TCP/IP connections\n"));
|
||||
printf(_(" -k DIRECTORY Unix-domain socket location\n"));
|
||||
#ifdef USE_SSL
|
||||
printf(_(" -l enable SSL connections\n"));
|
||||
#endif
|
||||
printf(_(" -N MAX-CONNECT maximum number of allowed connections\n"));
|
||||
printf(_(" -o OPTIONS pass \"OPTIONS\" to each server process (obsolete)\n"));
|
||||
printf(_(" -p PORT port number to listen on\n"));
|
||||
printf(_(" -s show statistics after each query\n"));
|
||||
printf(_(" -S WORK-MEM set amount of memory for sorts (in kB)\n"));
|
||||
printf(_(" --NAME=VALUE set run-time parameter\n"));
|
||||
printf(_(" --describe-config describe configuration parameters, then exit\n"));
|
||||
printf(_(" --help show this help, then exit\n"));
|
||||
printf(_(" --version output version information, then exit\n"));
|
||||
|
||||
printf(_("\nDeveloper options:\n"));
|
||||
printf(_(" -f s|i|n|m|h forbid use of some plan types\n"));
|
||||
printf(_(" -n do not reinitialize shared memory after abnormal exit\n"));
|
||||
printf(_(" -O allow system table structure changes\n"));
|
||||
printf(_(" -P disable system indexes\n"));
|
||||
printf(_(" -t pa|pl|ex show timings after each query\n"));
|
||||
printf(_(" -T send SIGSTOP to all backend servers if one dies\n"));
|
||||
printf(_(" -W NUM wait NUM seconds to allow attach from a debugger\n"));
|
||||
|
||||
printf(_("\nOptions for single-user mode:\n"));
|
||||
printf(_(" --single selects single-user mode (must be first argument)\n"));
|
||||
printf(_(" DBNAME database name (defaults to user name)\n"));
|
||||
printf(_(" -d 0-5 override debugging level\n"));
|
||||
printf(_(" -E echo statement before execution\n"));
|
||||
printf(_(" -j do not use newline as interactive query delimiter\n"));
|
||||
printf(_(" -r FILENAME send stdout and stderr to given file\n"));
|
||||
|
||||
printf(_("\nOptions for bootstrapping mode:\n"));
|
||||
printf(_(" --boot selects bootstrapping mode (must be first argument)\n"));
|
||||
printf(_(" DBNAME database name (mandatory argument in bootstrapping mode)\n"));
|
||||
printf(_(" -r FILENAME send stdout and stderr to given file\n"));
|
||||
printf(_(" -x NUM internal use\n"));
|
||||
|
||||
printf(_("\nPlease read the documentation for the complete list of run-time\n"
|
||||
"configuration settings and how to set them on the command line or in\n"
|
||||
"the configuration file.\n\n"
|
||||
"Report bugs to <pgsql-bugs@postgresql.org>.\n"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
check_root(const char *progname)
|
||||
{
|
||||
#ifndef WIN32
|
||||
if (geteuid() == 0)
|
||||
{
|
||||
write_stderr("\"root\" execution of the PostgreSQL server is not permitted.\n"
|
||||
"The server must be started under an unprivileged user ID to prevent\n"
|
||||
"possible system security compromise. See the documentation for\n"
|
||||
"more information on how to properly start the server.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Also make sure that real and effective uids are the same.
|
||||
* Executing as a setuid program from a root shell is a security
|
||||
* hole, since on many platforms a nefarious subroutine could
|
||||
* setuid back to root if real uid is root. (Since nobody
|
||||
* actually uses postgres as a setuid program, trying to
|
||||
* actively fix this situation seems more trouble than it's worth;
|
||||
* we'll just expend the effort to check for it.)
|
||||
*/
|
||||
if (getuid() != geteuid())
|
||||
{
|
||||
write_stderr("%s: real and effective user IDs must match\n",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
#else /* WIN32 */
|
||||
if (pgwin32_is_admin())
|
||||
{
|
||||
write_stderr("Execution of PostgreSQL by a user with administrative permissions is not\n"
|
||||
"permitted.\n"
|
||||
"The server must be started under an unprivileged user ID to prevent\n"
|
||||
"possible system security compromises. See the documentation for\n"
|
||||
"more information on how to properly start the server.\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif /* WIN32 */
|
||||
}
|
||||
|
||||
|
||||
|
||||
static char *
|
||||
get_current_username(const char *progname)
|
||||
{
|
||||
#ifndef WIN32
|
||||
struct passwd *pw;
|
||||
|
||||
pw = getpwuid(geteuid());
|
||||
if (pw == NULL)
|
||||
{
|
||||
write_stderr("%s: invalid effective UID: %d\n",
|
||||
argv[0], (int) geteuid());
|
||||
progname, (int) geteuid());
|
||||
exit(1);
|
||||
}
|
||||
/* Allocate new memory because later getpwuid() calls can overwrite it */
|
||||
pw_name_persist = strdup(pw->pw_name);
|
||||
/* Allocate new memory because later getpwuid() calls can overwrite it. */
|
||||
return strdup(pw->pw_name);
|
||||
#else
|
||||
long namesize = 256 /* UNLEN */ + 1;
|
||||
char *name;
|
||||
|
||||
name = malloc(namesize);
|
||||
if (!GetUserName(name, &namesize))
|
||||
{
|
||||
long namesize = 256 /* UNLEN */ + 1;
|
||||
|
||||
pw_name_persist = malloc(namesize);
|
||||
if (!GetUserName(pw_name_persist, &namesize))
|
||||
{
|
||||
write_stderr("%s: could not determine user name (GetUserName failed)\n",
|
||||
argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
write_stderr("%s: could not determine user name (GetUserName failed)\n",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
#endif /* WIN32 */
|
||||
|
||||
exit(PostgresMain(argc, argv, pw_name_persist));
|
||||
return name;
|
||||
#endif
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.19 2006/05/19 15:15:37 alvherre Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.20 2006/06/18 15:38:37 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -208,7 +208,7 @@ autovac_forkexec(void)
|
||||
int ac = 0;
|
||||
|
||||
av[ac++] = "postgres";
|
||||
av[ac++] = "-forkautovac";
|
||||
av[ac++] = "--forkautovac";
|
||||
av[ac++] = NULL; /* filled in by postmaster_forkexec */
|
||||
av[ac] = NULL;
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.22 2006/05/30 17:08:14 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.23 2006/06/18 15:38:37 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -197,7 +197,7 @@ pgarch_forkexec(void)
|
||||
|
||||
av[ac++] = "postgres";
|
||||
|
||||
av[ac++] = "-forkarch";
|
||||
av[ac++] = "--forkarch";
|
||||
|
||||
av[ac++] = NULL; /* filled in by postmaster_forkexec */
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
* Copyright (c) 2001-2006, PostgreSQL Global Development Group
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.127 2006/05/30 02:35:39 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.128 2006/06/18 15:38:37 petere Exp $
|
||||
* ----------
|
||||
*/
|
||||
#include "postgres.h"
|
||||
@ -491,11 +491,11 @@ pgstat_forkexec(STATS_PROCESS_TYPE procType)
|
||||
switch (procType)
|
||||
{
|
||||
case STAT_PROC_BUFFER:
|
||||
av[ac++] = "-forkbuf";
|
||||
av[ac++] = "--forkbuf";
|
||||
break;
|
||||
|
||||
case STAT_PROC_COLLECTOR:
|
||||
av[ac++] = "-forkcol";
|
||||
av[ac++] = "--forkcol";
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -37,7 +37,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.485 2006/06/07 22:24:44 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.486 2006/06/18 15:38:37 petere Exp $
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
@ -266,7 +266,6 @@ static void LogChildExit(int lev, const char *procname,
|
||||
static void BackendInitialize(Port *port);
|
||||
static int BackendRun(Port *port);
|
||||
static void ExitPostmaster(int status);
|
||||
static void usage(const char *);
|
||||
static int ServerLoop(void);
|
||||
static int BackendStartup(Port *port);
|
||||
static int ProcessStartupPacket(Port *port, bool SSLdone);
|
||||
@ -384,29 +383,6 @@ PostmasterMain(int argc, char *argv[])
|
||||
|
||||
IsPostmasterEnvironment = true;
|
||||
|
||||
/*
|
||||
* Catch standard options before doing much else. This even works on
|
||||
* systems without getopt_long.
|
||||
*/
|
||||
if (argc > 1)
|
||||
{
|
||||
if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
|
||||
{
|
||||
usage(progname);
|
||||
ExitPostmaster(0);
|
||||
}
|
||||
if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
|
||||
{
|
||||
puts("postmaster (PostgreSQL) " PG_VERSION);
|
||||
ExitPostmaster(0);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
/* Start our win32 signal implementation */
|
||||
pgwin32_signal_initialize();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* for security, no dir or file created can be group or other accessible
|
||||
*/
|
||||
@ -1133,55 +1109,6 @@ pmdaemonize(void)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Print out help message
|
||||
*/
|
||||
static void
|
||||
usage(const char *progname)
|
||||
{
|
||||
printf(_("%s is the PostgreSQL server.\n\n"), progname);
|
||||
printf(_("Usage:\n %s [OPTION]...\n\n"), progname);
|
||||
printf(_("Options:\n"));
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
printf(_(" -A 1|0 enable/disable run-time assert checking\n"));
|
||||
#endif
|
||||
printf(_(" -B NBUFFERS number of shared buffers\n"));
|
||||
printf(_(" -c NAME=VALUE set run-time parameter\n"));
|
||||
printf(_(" -d 1-5 debugging level\n"));
|
||||
printf(_(" -D DATADIR database directory\n"));
|
||||
printf(_(" -e use European date input format (DMY)\n"));
|
||||
printf(_(" -F turn fsync off\n"));
|
||||
printf(_(" -h HOSTNAME host name or IP address to listen on\n"));
|
||||
printf(_(" -i enable TCP/IP connections\n"));
|
||||
printf(_(" -k DIRECTORY Unix-domain socket location\n"));
|
||||
#ifdef USE_SSL
|
||||
printf(_(" -l enable SSL connections\n"));
|
||||
#endif
|
||||
printf(_(" -N MAX-CONNECT maximum number of allowed connections\n"));
|
||||
printf(_(" -o OPTIONS pass \"OPTIONS\" to each server process (obsolete)\n"));
|
||||
printf(_(" -p PORT port number to listen on\n"));
|
||||
printf(_(" -s show statistics after each query\n"));
|
||||
printf(_(" -S WORK-MEM set amount of memory for sorts (in kB)\n"));
|
||||
printf(_(" --NAME=VALUE set run-time parameter\n"));
|
||||
printf(_(" --help show this help, then exit\n"));
|
||||
printf(_(" --version output version information, then exit\n"));
|
||||
|
||||
printf(_("\nDeveloper options:\n"));
|
||||
printf(_(" -f s|i|n|m|h forbid use of some plan types\n"));
|
||||
printf(_(" -n do not reinitialize shared memory after abnormal exit\n"));
|
||||
printf(_(" -O allow system table structure changes\n"));
|
||||
printf(_(" -P disable system indexes\n"));
|
||||
printf(_(" -t pa|pl|ex show timings after each query\n"));
|
||||
printf(_(" -T send SIGSTOP to all backend servers if one dies\n"));
|
||||
printf(_(" -W NUM wait NUM seconds to allow attach from a debugger\n"));
|
||||
|
||||
printf(_("\nPlease read the documentation for the complete list of run-time\n"
|
||||
"configuration settings and how to set them on the command line or in\n"
|
||||
"the configuration file.\n\n"
|
||||
"Report bugs to <pgsql-bugs@postgresql.org>.\n"));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Main idle loop of postmaster
|
||||
*/
|
||||
@ -2957,7 +2884,7 @@ backend_forkexec(Port *port)
|
||||
int ac = 0;
|
||||
|
||||
av[ac++] = "postgres";
|
||||
av[ac++] = "-forkbackend";
|
||||
av[ac++] = "--forkbackend";
|
||||
av[ac++] = NULL; /* filled in by internal_forkexec */
|
||||
|
||||
av[ac] = NULL;
|
||||
@ -3030,10 +2957,10 @@ internal_forkexec(int argc, char *argv[], Port *port)
|
||||
/* Make sure caller set up argv properly */
|
||||
Assert(argc >= 3);
|
||||
Assert(argv[argc] == NULL);
|
||||
Assert(strncmp(argv[1], "-fork", 5) == 0);
|
||||
Assert(strncmp(argv[1], "--fork", 6) == 0);
|
||||
Assert(argv[2] == NULL);
|
||||
|
||||
/* Insert temp file name after -fork argument */
|
||||
/* Insert temp file name after --fork argument */
|
||||
argv[2] = tmpfilename;
|
||||
|
||||
/* Fire off execv in child */
|
||||
@ -3081,7 +3008,7 @@ internal_forkexec(int argc, char *argv[], Port *port)
|
||||
/* Make sure caller set up argv properly */
|
||||
Assert(argc >= 3);
|
||||
Assert(argv[argc] == NULL);
|
||||
Assert(strncmp(argv[1], "-fork", 5) == 0);
|
||||
Assert(strncmp(argv[1], "--fork", 6) == 0);
|
||||
Assert(argv[2] == NULL);
|
||||
|
||||
/* Verify that there is room in the child list */
|
||||
@ -3119,7 +3046,7 @@ internal_forkexec(int argc, char *argv[], Port *port)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Insert temp file name after -fork argument */
|
||||
/* Insert temp file name after --fork argument */
|
||||
sprintf(paramHandleStr, "%lu", (DWORD) paramHandle);
|
||||
argv[2] = paramHandleStr;
|
||||
|
||||
@ -3242,7 +3169,7 @@ internal_forkexec(int argc, char *argv[], Port *port)
|
||||
* to what it would be if we'd simply forked on Unix, and then
|
||||
* dispatch to the appropriate place.
|
||||
*
|
||||
* The first two command line arguments are expected to be "-forkFOO"
|
||||
* The first two command line arguments are expected to be "--forkFOO"
|
||||
* (where FOO indicates which postmaster child we are to become), and
|
||||
* the name of a variables file that we can read to load data that would
|
||||
* have been inherited by fork() on Unix. Remaining arguments go to the
|
||||
@ -3282,9 +3209,9 @@ SubPostmasterMain(int argc, char *argv[])
|
||||
* to do this before going any further to ensure that we can attach at the
|
||||
* same address the postmaster used.
|
||||
*/
|
||||
if (strcmp(argv[1], "-forkbackend") == 0 ||
|
||||
strcmp(argv[1], "-forkautovac") == 0 ||
|
||||
strcmp(argv[1], "-forkboot") == 0)
|
||||
if (strcmp(argv[1], "--forkbackend") == 0 ||
|
||||
strcmp(argv[1], "--forkautovac") == 0 ||
|
||||
strcmp(argv[1], "--forkboot") == 0)
|
||||
PGSharedMemoryReAttach();
|
||||
|
||||
/*
|
||||
@ -3304,7 +3231,7 @@ SubPostmasterMain(int argc, char *argv[])
|
||||
read_nondefault_variables();
|
||||
|
||||
/* Run backend or appropriate child */
|
||||
if (strcmp(argv[1], "-forkbackend") == 0)
|
||||
if (strcmp(argv[1], "--forkbackend") == 0)
|
||||
{
|
||||
Assert(argc == 3); /* shouldn't be any more args */
|
||||
|
||||
@ -3356,7 +3283,7 @@ SubPostmasterMain(int argc, char *argv[])
|
||||
/* And run the backend */
|
||||
proc_exit(BackendRun(&port));
|
||||
}
|
||||
if (strcmp(argv[1], "-forkboot") == 0)
|
||||
if (strcmp(argv[1], "--forkboot") == 0)
|
||||
{
|
||||
/* Close the postmaster's sockets */
|
||||
ClosePostmasterPorts(false);
|
||||
@ -3373,7 +3300,7 @@ SubPostmasterMain(int argc, char *argv[])
|
||||
BootstrapMain(argc - 2, argv + 2);
|
||||
proc_exit(0);
|
||||
}
|
||||
if (strcmp(argv[1], "-forkautovac") == 0)
|
||||
if (strcmp(argv[1], "--forkautovac") == 0)
|
||||
{
|
||||
/* Close the postmaster's sockets */
|
||||
ClosePostmasterPorts(false);
|
||||
@ -3390,7 +3317,7 @@ SubPostmasterMain(int argc, char *argv[])
|
||||
AutoVacMain(argc - 2, argv + 2);
|
||||
proc_exit(0);
|
||||
}
|
||||
if (strcmp(argv[1], "-forkarch") == 0)
|
||||
if (strcmp(argv[1], "--forkarch") == 0)
|
||||
{
|
||||
/* Close the postmaster's sockets */
|
||||
ClosePostmasterPorts(false);
|
||||
@ -3400,7 +3327,7 @@ SubPostmasterMain(int argc, char *argv[])
|
||||
PgArchiverMain(argc, argv);
|
||||
proc_exit(0);
|
||||
}
|
||||
if (strcmp(argv[1], "-forkbuf") == 0)
|
||||
if (strcmp(argv[1], "--forkbuf") == 0)
|
||||
{
|
||||
/* Close the postmaster's sockets */
|
||||
ClosePostmasterPorts(false);
|
||||
@ -3410,7 +3337,7 @@ SubPostmasterMain(int argc, char *argv[])
|
||||
PgstatBufferMain(argc, argv);
|
||||
proc_exit(0);
|
||||
}
|
||||
if (strcmp(argv[1], "-forkcol") == 0)
|
||||
if (strcmp(argv[1], "--forkcol") == 0)
|
||||
{
|
||||
/*
|
||||
* Do NOT close postmaster sockets here, because we are forking from
|
||||
@ -3422,7 +3349,7 @@ SubPostmasterMain(int argc, char *argv[])
|
||||
PgstatCollectorMain(argc, argv);
|
||||
proc_exit(0);
|
||||
}
|
||||
if (strcmp(argv[1], "-forklog") == 0)
|
||||
if (strcmp(argv[1], "--forklog") == 0)
|
||||
{
|
||||
/* Close the postmaster's sockets */
|
||||
ClosePostmasterPorts(true);
|
||||
@ -3635,7 +3562,7 @@ StartChildProcess(int xlop)
|
||||
av[ac++] = "postgres";
|
||||
|
||||
#ifdef EXEC_BACKEND
|
||||
av[ac++] = "-forkboot";
|
||||
av[ac++] = "--forkboot";
|
||||
av[ac++] = NULL; /* filled in by postmaster_forkexec */
|
||||
#endif
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.24 2006/06/07 22:24:44 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.25 2006/06/18 15:38:37 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -534,7 +534,7 @@ syslogger_forkexec(void)
|
||||
char numbuf[2][32];
|
||||
|
||||
av[ac++] = "postgres";
|
||||
av[ac++] = "-forklog";
|
||||
av[ac++] = "--forklog";
|
||||
av[ac++] = NULL; /* filled in by postmaster_forkexec */
|
||||
|
||||
/* static variables (those not passed by write_backend_variables) */
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.487 2006/06/11 15:49:28 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.488 2006/06/18 15:38:37 petere Exp $
|
||||
*
|
||||
* NOTES
|
||||
* this is the "main" module of the postgres backend and
|
||||
@ -2399,41 +2399,6 @@ assign_max_stack_depth(int newval, bool doit, GucSource source)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
usage(const char *progname)
|
||||
{
|
||||
printf(_("%s is the PostgreSQL stand-alone backend. It is not\nintended to be used by normal users.\n\n"), progname);
|
||||
|
||||
printf(_("Usage:\n %s [OPTION]... DBNAME\n\n"), progname);
|
||||
printf(_("Options:\n"));
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
printf(_(" -A 1|0 enable/disable run-time assert checking\n"));
|
||||
#endif
|
||||
printf(_(" -B NBUFFERS number of shared buffers\n"));
|
||||
printf(_(" -c NAME=VALUE set run-time parameter\n"));
|
||||
printf(_(" -d 0-5 debugging level\n"));
|
||||
printf(_(" -D DATADIR database directory\n"));
|
||||
printf(_(" -e use European date input format (DMY)\n"));
|
||||
printf(_(" -E echo statement before execution\n"));
|
||||
printf(_(" -F turn fsync off\n"));
|
||||
printf(_(" -j do not use newline as interactive query delimiter\n"));
|
||||
printf(_(" -r FILENAME send stdout and stderr to given file\n"));
|
||||
printf(_(" -s show statistics after each query\n"));
|
||||
printf(_(" -S WORK-MEM set amount of memory for sorts (in kB)\n"));
|
||||
printf(_(" --NAME=VALUE set run-time parameter\n"));
|
||||
printf(_(" --describe-config describe configuration parameters, then exit\n"));
|
||||
printf(_(" --help show this help, then exit\n"));
|
||||
printf(_(" --version output version information, then exit\n"));
|
||||
printf(_("\nDeveloper options:\n"));
|
||||
printf(_(" -f s|i|n|m|h forbid use of some plan types\n"));
|
||||
printf(_(" -O allow system table structure changes\n"));
|
||||
printf(_(" -P disable system indexes\n"));
|
||||
printf(_(" -t pa|pl|ex show timings after each query\n"));
|
||||
printf(_(" -W NUM wait NUM seconds to allow attach from a debugger\n"));
|
||||
printf(_("\nReport bugs to <pgsql-bugs@postgresql.org>.\n"));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* set_debug_options --- apply "-d N" command line option
|
||||
*
|
||||
@ -2563,24 +2528,6 @@ PostgresMain(int argc, char *argv[], const char *username)
|
||||
(guc_names = lappend(guc_names, pstrdup(name)), \
|
||||
guc_values = lappend(guc_values, pstrdup(val)))
|
||||
|
||||
/*
|
||||
* 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)
|
||||
{
|
||||
usage(argv[0]);
|
||||
exit(0);
|
||||
}
|
||||
if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
|
||||
{
|
||||
puts(PG_VERSIONSTR);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* initialize globals (already done if under postmaster, but not if
|
||||
* standalone; cheap enough to do over)
|
||||
@ -2638,6 +2585,13 @@ PostgresMain(int argc, char *argv[], const char *username)
|
||||
* ----------------
|
||||
*/
|
||||
|
||||
/* Ignore the initial --single argument, if present */
|
||||
if (argc > 1 && strcmp(argv[1], "--single") == 0)
|
||||
{
|
||||
argv++;
|
||||
argc--;
|
||||
}
|
||||
|
||||
/* all options are allowed until '-p' */
|
||||
secure = true;
|
||||
ctx = PGC_POSTMASTER;
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* initdb creates (initializes) a PostgreSQL database cluster (site,
|
||||
* instance, installation, whatever). A database cluster is a
|
||||
* collection of PostgreSQL databases all managed by the same postmaster.
|
||||
* collection of PostgreSQL databases all managed by the same server.
|
||||
*
|
||||
* To create the database cluster, we create the directory that contains
|
||||
* all its data, create the files that hold the global tables, create
|
||||
@ -42,7 +42,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
* Portions taken from FreeBSD.
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.117 2006/06/07 22:24:44 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.118 2006/06/18 15:38:37 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -140,7 +140,7 @@ static char *authwarning = NULL;
|
||||
* (no quoting to worry about).
|
||||
*/
|
||||
static const char *boot_options = "-F";
|
||||
static const char *backend_options = "-F -O -c search_path=pg_catalog -c exit_on_error=true";
|
||||
static const char *backend_options = "--single -F -O -c search_path=pg_catalog -c exit_on_error=true";
|
||||
|
||||
|
||||
/* path to 'initdb' binary directory */
|
||||
@ -1138,7 +1138,7 @@ test_config_settings(void)
|
||||
test_max_fsm = FSM_FOR_BUFS(test_buffs);
|
||||
|
||||
snprintf(cmd, sizeof(cmd),
|
||||
"%s\"%s\" -boot -x0 %s "
|
||||
"%s\"%s\" --boot -x0 %s "
|
||||
"-c max_connections=%d "
|
||||
"-c shared_buffers=%d "
|
||||
"-c max_fsm_pages=%d "
|
||||
@ -1173,7 +1173,7 @@ test_config_settings(void)
|
||||
test_max_fsm = FSM_FOR_BUFS(test_buffs);
|
||||
|
||||
snprintf(cmd, sizeof(cmd),
|
||||
"%s\"%s\" -boot -x0 %s "
|
||||
"%s\"%s\" --boot -x0 %s "
|
||||
"-c max_connections=%d "
|
||||
"-c shared_buffers=%d "
|
||||
"-c max_fsm_pages=%d "
|
||||
@ -1402,7 +1402,7 @@ bootstrap_template1(char *short_version)
|
||||
unsetenv("PGCLIENTENCODING");
|
||||
|
||||
snprintf(cmd, sizeof(cmd),
|
||||
"\"%s\" -boot -x1 %s %s template1",
|
||||
"\"%s\" --boot -x1 %s %s template1",
|
||||
backend_exec, boot_options, talkargs);
|
||||
|
||||
PG_CMD_OPEN;
|
||||
@ -2963,7 +2963,7 @@ main(int argc, char *argv[])
|
||||
get_parent_directory(bin_dir);
|
||||
|
||||
printf(_("\nSuccess. You can now start the database server using:\n\n"
|
||||
" %s%s%spostmaster%s -D %s%s%s\n"
|
||||
" %s%s%spostgres%s -D %s%s%s\n"
|
||||
"or\n"
|
||||
" %s%s%spg_ctl%s -D %s%s%s -l logfile start\n\n"),
|
||||
QUOTE_PATH, bin_dir, (strlen(bin_dir) > 0) ? DIR_SEP : "", QUOTE_PATH,
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.68 2006/06/07 22:24:44 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.69 2006/06/18 15:38:37 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -46,8 +46,8 @@ typedef long pgpid_t;
|
||||
|
||||
#define WHITESPACE "\f\n\r\t\v" /* as defined by isspace() */
|
||||
|
||||
/* postmaster version ident string */
|
||||
#define PM_VERSIONSTR "postmaster (PostgreSQL) " PG_VERSION "\n"
|
||||
/* postgres version ident string */
|
||||
#define PM_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n"
|
||||
|
||||
|
||||
typedef enum
|
||||
@ -487,8 +487,8 @@ do_start(void)
|
||||
{
|
||||
old_pid = get_pgpid();
|
||||
if (old_pid != 0)
|
||||
write_stderr(_("%s: another postmaster may be running; "
|
||||
"trying to start postmaster anyway\n"),
|
||||
write_stderr(_("%s: another server may be running; "
|
||||
"trying to start server anyway\n"),
|
||||
progname);
|
||||
}
|
||||
|
||||
@ -553,7 +553,7 @@ do_start(void)
|
||||
|
||||
postmaster_path = pg_malloc(MAXPGPATH);
|
||||
|
||||
if ((ret = find_other_exec(argv0, "postmaster", PM_VERSIONSTR,
|
||||
if ((ret = find_other_exec(argv0, "postgres", PM_VERSIONSTR,
|
||||
postmaster_path)) < 0)
|
||||
{
|
||||
char full_path[MAXPGPATH];
|
||||
@ -562,13 +562,13 @@ do_start(void)
|
||||
StrNCpy(full_path, progname, MAXPGPATH);
|
||||
|
||||
if (ret == -1)
|
||||
write_stderr(_("The program \"postmaster\" is needed by %s "
|
||||
write_stderr(_("The program \"postgres\" is needed by %s "
|
||||
"but was not found in the\n"
|
||||
"same directory as \"%s\".\n"
|
||||
"Check your installation.\n"),
|
||||
progname, full_path);
|
||||
else
|
||||
write_stderr(_("The program \"postmaster\" was found by \"%s\"\n"
|
||||
write_stderr(_("The program \"postgres\" was found by \"%s\"\n"
|
||||
"but was not the same version as %s.\n"
|
||||
"Check your installation.\n"),
|
||||
full_path, progname);
|
||||
@ -580,7 +580,7 @@ do_start(void)
|
||||
exitcode = start_postmaster();
|
||||
if (exitcode != 0)
|
||||
{
|
||||
write_stderr(_("%s: could not start postmaster: exit code was %d\n"),
|
||||
write_stderr(_("%s: could not start server: exit code was %d\n"),
|
||||
progname, exitcode);
|
||||
exit(1);
|
||||
}
|
||||
@ -591,7 +591,7 @@ do_start(void)
|
||||
pid = get_pgpid();
|
||||
if (pid == old_pid)
|
||||
{
|
||||
write_stderr(_("%s: could not start postmaster\n"
|
||||
write_stderr(_("%s: could not start server\n"
|
||||
"Examine the log output.\n"),
|
||||
progname);
|
||||
exit(1);
|
||||
@ -600,21 +600,21 @@ do_start(void)
|
||||
|
||||
if (do_wait)
|
||||
{
|
||||
print_msg(_("waiting for postmaster to start..."));
|
||||
print_msg(_("waiting for server to start..."));
|
||||
|
||||
if (test_postmaster_connection() == false)
|
||||
{
|
||||
printf(_("could not start postmaster\n"));
|
||||
printf(_("could not start server\n"));
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
print_msg(_(" done\n"));
|
||||
print_msg(_("postmaster started\n"));
|
||||
print_msg(_("server started\n"));
|
||||
}
|
||||
}
|
||||
else
|
||||
print_msg(_("postmaster starting\n"));
|
||||
print_msg(_("server starting\n"));
|
||||
}
|
||||
|
||||
|
||||
@ -629,14 +629,14 @@ do_stop(void)
|
||||
if (pid == 0) /* no pid file */
|
||||
{
|
||||
write_stderr(_("%s: PID file \"%s\" does not exist\n"), progname, pid_file);
|
||||
write_stderr(_("Is postmaster running?\n"));
|
||||
write_stderr(_("Is server running?\n"));
|
||||
exit(1);
|
||||
}
|
||||
else if (pid < 0) /* standalone backend, not postmaster */
|
||||
{
|
||||
pid = -pid;
|
||||
write_stderr(_("%s: cannot stop postmaster; "
|
||||
"postgres is running (PID: %ld)\n"),
|
||||
write_stderr(_("%s: cannot stop server; "
|
||||
"single-user server is running (PID: %ld)\n"),
|
||||
progname, pid);
|
||||
exit(1);
|
||||
}
|
||||
@ -650,12 +650,12 @@ do_stop(void)
|
||||
|
||||
if (!do_wait)
|
||||
{
|
||||
print_msg(_("postmaster shutting down\n"));
|
||||
print_msg(_("server shutting down\n"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
print_msg(_("waiting for postmaster to shut down..."));
|
||||
print_msg(_("waiting for server to shut down..."));
|
||||
|
||||
for (cnt = 0; cnt < wait_seconds; cnt++)
|
||||
{
|
||||
@ -672,12 +672,12 @@ do_stop(void)
|
||||
{
|
||||
print_msg(_(" failed\n"));
|
||||
|
||||
write_stderr(_("%s: postmaster does not shut down\n"), progname);
|
||||
write_stderr(_("%s: server does not shut down\n"), progname);
|
||||
exit(1);
|
||||
}
|
||||
print_msg(_(" done\n"));
|
||||
|
||||
printf(_("postmaster stopped\n"));
|
||||
printf(_("server stopped\n"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -698,8 +698,8 @@ do_restart(void)
|
||||
{
|
||||
write_stderr(_("%s: PID file \"%s\" does not exist\n"),
|
||||
progname, pid_file);
|
||||
write_stderr(_("Is postmaster running?\n"));
|
||||
write_stderr(_("starting postmaster anyway\n"));
|
||||
write_stderr(_("Is server running?\n"));
|
||||
write_stderr(_("starting server anyway\n"));
|
||||
do_start();
|
||||
return;
|
||||
}
|
||||
@ -708,10 +708,10 @@ do_restart(void)
|
||||
pid = -pid;
|
||||
if (postmaster_is_alive((pid_t) pid))
|
||||
{
|
||||
write_stderr(_("%s: cannot restart postmaster; "
|
||||
"postgres is running (PID: %ld)\n"),
|
||||
write_stderr(_("%s: cannot restart server; "
|
||||
"single-user server is running (PID: %ld)\n"),
|
||||
progname, pid);
|
||||
write_stderr(_("Please terminate postgres and try again.\n"));
|
||||
write_stderr(_("Please terminate the single-user server and try again.\n"));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@ -725,7 +725,7 @@ do_restart(void)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
print_msg(_("waiting for postmaster to shut down..."));
|
||||
print_msg(_("waiting for server to shut down..."));
|
||||
|
||||
/* always wait for restart */
|
||||
|
||||
@ -744,18 +744,18 @@ do_restart(void)
|
||||
{
|
||||
print_msg(_(" failed\n"));
|
||||
|
||||
write_stderr(_("%s: postmaster does not shut down\n"), progname);
|
||||
write_stderr(_("%s: server does not shut down\n"), progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
print_msg(_(" done\n"));
|
||||
printf(_("postmaster stopped\n"));
|
||||
printf(_("server stopped\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
write_stderr(_("%s: old postmaster process (PID: %ld) seems to be gone\n"),
|
||||
write_stderr(_("%s: old server process (PID: %ld) seems to be gone\n"),
|
||||
progname, pid);
|
||||
write_stderr(_("starting postmaster anyway\n"));
|
||||
write_stderr(_("starting server anyway\n"));
|
||||
}
|
||||
|
||||
do_start();
|
||||
@ -771,16 +771,16 @@ do_reload(void)
|
||||
if (pid == 0) /* no pid file */
|
||||
{
|
||||
write_stderr(_("%s: PID file \"%s\" does not exist\n"), progname, pid_file);
|
||||
write_stderr(_("Is postmaster running?\n"));
|
||||
write_stderr(_("Is server running?\n"));
|
||||
exit(1);
|
||||
}
|
||||
else if (pid < 0) /* standalone backend, not postmaster */
|
||||
{
|
||||
pid = -pid;
|
||||
write_stderr(_("%s: cannot reload postmaster; "
|
||||
"postgres is running (PID: %ld)\n"),
|
||||
write_stderr(_("%s: cannot reload server; "
|
||||
"single-user server is running (PID: %ld)\n"),
|
||||
progname, pid);
|
||||
write_stderr(_("Please terminate postgres and try again.\n"));
|
||||
write_stderr(_("Please terminate the single-user server and try again.\n"));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -791,7 +791,7 @@ do_reload(void)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
print_msg(_("postmaster signaled\n"));
|
||||
print_msg(_("server signaled\n"));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -835,7 +835,7 @@ do_status(void)
|
||||
pid = -pid;
|
||||
if (postmaster_is_alive((pid_t) pid))
|
||||
{
|
||||
printf(_("%s: a standalone backend \"postgres\" is running (PID: %ld)\n"),
|
||||
printf(_("%s: single-user server is running (PID: %ld)\n"),
|
||||
progname, pid);
|
||||
return;
|
||||
}
|
||||
@ -847,7 +847,7 @@ do_status(void)
|
||||
{
|
||||
char **optlines;
|
||||
|
||||
printf(_("%s: postmaster is running (PID: %ld)\n"),
|
||||
printf(_("%s: server is running (PID: %ld)\n"),
|
||||
progname, pid);
|
||||
|
||||
optlines = readfile(postopts_file);
|
||||
@ -858,7 +858,7 @@ do_status(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
printf(_("%s: neither postmaster nor postgres running\n"), progname);
|
||||
printf(_("%s: no server running\n"), progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -909,10 +909,10 @@ pgwin32_CommandLine(bool registration)
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = find_other_exec(argv0, "postmaster", PM_VERSIONSTR, cmdLine);
|
||||
ret = find_other_exec(argv0, "postgres", PM_VERSIONSTR, cmdLine);
|
||||
if (ret != 0)
|
||||
{
|
||||
write_stderr(_("%s: could not find postmaster program executable\n"), progname);
|
||||
write_stderr(_("%s: could not find postgres program executable\n"), progname);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@ -1373,9 +1373,9 @@ do_help(void)
|
||||
|
||||
printf(_("\nOptions for start or restart:\n"));
|
||||
printf(_(" -l, --log FILENAME write (or append) server log to FILENAME\n"));
|
||||
printf(_(" -o OPTIONS command line options to pass to the postmaster\n"
|
||||
printf(_(" -o OPTIONS command line options to pass to postgres\n"
|
||||
" (PostgreSQL server executable)\n"));
|
||||
printf(_(" -p PATH-TO-POSTMASTER normally not necessary\n"));
|
||||
printf(_(" -p PATH-TO-POSTGRES normally not necessary\n"));
|
||||
|
||||
printf(_("\nOptions for stop or restart:\n"));
|
||||
printf(_(" -m SHUTDOWN-MODE may be \"smart\", \"fast\", or \"immediate\"\n"));
|
||||
|
Reference in New Issue
Block a user