diff -cr ../cvs-pgsql/doc/src/sgml/maintenance.sgml ./doc/src/sgml/maintenance.sgml *** ../cvs-pgsql/doc/src/sgml/maintenance.sgml 2005-12-08 21:47:16.000000000 +0100 --- ./doc/src/sgml/maintenance.sgml 2006-01-21 15:07:04.000000000 +0100 *************** *** 424,433 **** administrator recover without data loss, by manually executing the required VACUUM commands. However, since the system will not execute commands once it has gone into the safety shutdown mode, ! the only way to do this is to stop the postmaster and use a standalone backend to execute VACUUM. The shutdown mode is not enforced ! by a standalone backend. See the reference ! page for details about using a standalone backend. --- 424,433 ---- administrator recover without data loss, by manually executing the required VACUUM commands. However, since the system will not execute commands once it has gone into the safety shutdown mode, ! the only way to do this is to stop the server and use a single-user backend to execute VACUUM. The shutdown mode is not enforced ! by a single-user backend. See the reference ! page for details about using a single-user backend. diff -cr ../cvs-pgsql/doc/src/sgml/ref/allfiles.sgml ./doc/src/sgml/ref/allfiles.sgml *** ../cvs-pgsql/doc/src/sgml/ref/allfiles.sgml 2005-12-03 22:30:46.000000000 +0100 --- ./doc/src/sgml/ref/allfiles.sgml 2006-01-21 14:57:43.000000000 +0100 *************** *** 135,141 **** - --- 135,140 ---- diff -cr ../cvs-pgsql/doc/src/sgml/ref/initdb.sgml ./doc/src/sgml/ref/initdb.sgml *** ../cvs-pgsql/doc/src/sgml/ref/initdb.sgml 2005-06-30 18:31:48.000000000 +0200 --- ./doc/src/sgml/ref/initdb.sgml 2006-01-21 15:07:02.000000000 +0100 *************** *** 286,292 **** See Also - --- 286,291 ---- Nur in ../cvs-pgsql/doc/src/sgml/ref: postgres-ref.sgml. diff -cr ../cvs-pgsql/doc/src/sgml/ref/postmaster.sgml ./doc/src/sgml/ref/postmaster.sgml *** ../cvs-pgsql/doc/src/sgml/ref/postmaster.sgml 2006-01-09 10:57:53.000000000 +0100 --- ./doc/src/sgml/ref/postmaster.sgml 2006-01-21 17:41:49.000000000 +0100 *************** *** 12,18 **** postmaster ! PostgreSQL multiuser database server --- 12,18 ---- postmaster ! PostgreSQL database server *************** *** 31,44 **** postmaster is the ! PostgreSQL multiuser database server. ! In order for a client application to access a database it connects ! (over a network or locally) to a running ! postmaster. The ! postmaster then starts a separate server ! process () to handle ! the connection. The postmaster also ! manages the communication among server processes. --- 31,59 ---- postmaster is the ! PostgreSQL database server. In order ! for a client application to access a database it connects (over a ! network or locally) to a running postmaster. ! The postmaster then starts a separate server ! process to handle the connection. ! ! ! ! One postmaster always manages the data from ! exactly one database cluster. A database cluster is a collection ! of databases that is stored at a common file system location (the ! data area). More than one ! postmaster process can run on a system at one ! time, so long as they use different data areas and different ! communication ports (see below). When the ! postmaster starts it needs to know the location ! of the data area. The location must be specified by the ! option or the PGDATA environment ! variable; there is no default. Typically, or ! PGDATA points directly to the data area directory ! created by initdb. Other possible file layouts are ! discussed in . A ! data area is created with . *************** *** 49,73 **** ! One postmaster always manages the data ! from exactly one database cluster. A database cluster is a ! collection of databases that is stored at a common file system ! location (the data area). ! More than one postmaster process can run on a system ! at one time, so long as they use different data areas and different ! communication ports (see below). ! ! ! ! When the postmaster starts it needs ! to know the location of the data area. ! The location must be specified by the option ! or the PGDATA environment variable; there is no default. ! Typically, or PGDATA points ! directly to the data area directory created by initdb. ! Other possible file layouts are discussed in ! . ! A data area is created with . --- 64,84 ---- ! The postmaster command can also be called in ! single-user mode. The primary use for this mode is during ! bootstrapping by . Sometimes it is used ! for debugging or disaster recovery. When invoked in interactive ! mode from the shell, the user can enter queries and the results ! will be printed to the screen, but in a form that is more useful ! for developers than end users. But note that running a single-user ! server is not truly suitable for debugging the server since no ! realistic interprocess communication and locking will happen. When ! running a stand-alone server, the session user will be set to the ! user with ID 1. This user does not actually have to exist, so a ! stand-alone server can be used to manually recover from certain ! kinds of accidental damage to the system catalogs. Implicit ! superuser powers are granted to the user with ID 1 in single-user ! mode. *************** *** 75,84 **** Options ! postmaster accepts the following ! command line arguments. For a detailed discussion of the options ! consult . You can save typing most of these ! options by setting up a configuration file. --- 86,101 ---- Options ! postmaster accepts the following command-line ! arguments. For a detailed discussion of the options consult . You can save typing most of these ! options by setting up a configuration file. Some (safe) options ! can also be set from the connecting client in an ! application-dependent way to apply only for that session. For ! example, if the environment variable PGOPTIONS is ! set, then libpq-based clients will pass that ! string to the server, which will interpret it as ! postmaster command-line options. *************** *** 128,135 **** Sets the debug level. The higher this value is set, the more ! debugging output is written to the server log. Values are from ! 1 to 5. --- 145,155 ---- Sets the debug level. The higher this value is set, the more ! debugging output is written to the server log. Values are ! from 1 to 5. It is also possible to pass -d ! 0 for a specific session, which will prevent the ! server log level of the postmaster from being ! propagated to this session. *************** *** 261,269 **** The command line-style options specified in extra-options are passed to all server processes started by this ! postmaster. See for possibilities. If the option ! string contains any spaces, the entire string must be quoted. --- 281,288 ---- The command line-style options specified in extra-options are passed to all server processes started by this ! postmaster. If the option string contains ! any spaces, the entire string must be quoted. *************** *** 335,340 **** --- 354,369 ---- + + + + + This option dumps out the server's internal configuration variables, + descriptions, and defaults in tab-delimited COPY format. + It is designed primarily for use by administration tools. + + + *************** *** 347,355 **** recovery of severely damaged databases. There should be no reason to use them in a production database setup. These are listed here only for the use by PostgreSQL ! system developers. Use of any of these options is ! highly discouraged. Furthermore, any of these options ! may disappear or change in a future release without notice. --- 376,383 ---- recovery of severely damaged databases. There should be no reason to use them in a production database setup. These are listed here only for the use by PostgreSQL ! system developers. Furthermore, any of these options may ! disappear or change in a future release without notice. *************** *** 443,448 **** --- 471,487 ---- + protocol + + + Specifies the version number of the frontend/backend protocol + to be used for a particular session. This option is for + internal use only. + + + + + seconds *************** *** 453,458 **** --- 492,568 ---- + + + database + + + Indicates that this is a subprocess started by the + postmaster and specifies the database to + use. This option is for internal use only. + + + + + + + + Options for single-user mode + + + The following options only apply to the single-user mode. + + + + + + + + Selects the single-user mode. This must be the first argument + on the command line. + + + + + + database + + + Specifies the name of the database to be accessed. If it is + omitted it defaults to the user name. + + + + + + + + + Echo all commands. + + + + + + + + + Disables use of newline as a statement delimiter. + + + + + + filename + + + Send all server log output to filename. In normal multiuser + mode, this option is ignored, and stderr is + used by all processes. + + + *************** *** 521,542 **** Diagnostics ! A failure message mentioning semget or shmget ! probably indicates you need to configure your kernel to provide adequate ! shared memory and semaphores. For more discussion see . - - - You may be able to postpone reconfiguring your kernel by - decreasing to reduce the - shared memory consumption of PostgreSQL, and/or - by reducing to reduce the - semaphore consumption. - - - A failure message suggesting that another postmaster is already running should be checked carefully, for example by using the command --- 631,647 ---- Diagnostics ! A failure message mentioning semget or ! shmget probably indicates you need to configure your ! kernel to provide adequate shared memory and semaphores. For more ! discussion see . You may be able ! to postpone reconfiguring your kernel by decreasing to reduce the shared memory ! consumption of PostgreSQL, and/or by reducing ! to reduce the semaphore ! consumption. A failure message suggesting that another postmaster is already running should be checked carefully, for example by using the command *************** *** 573,580 **** If at all possible, do not use ! SIGKILL to kill the ! postmaster. Doing so will prevent postmaster from freeing the system resources (e.g., shared memory and semaphores) that it holds before terminating. This may cause problems for starting a fresh --- 678,685 ---- If at all possible, do not use ! SIGKILL to kill the main ! postmaster server. Doing so will prevent postmaster from freeing the system resources (e.g., shared memory and semaphores) that it holds before terminating. This may cause problems for starting a fresh *************** *** 582,595 **** ! To terminate the postmaster normally, ! the signals SIGTERM, SIGINT, ! or SIGQUIT can be used. The first will wait for all clients to terminate before quitting, the second will forcefully disconnect all clients, and the third will quit immediately without proper shutdown, resulting in a recovery run ! during restart. The SIGHUP signal will ! reload the server configuration files. --- 687,702 ---- ! To terminate the postmaster server normally, the ! signals SIGTERM, SIGINT, or ! SIGQUIT can be used. The first will wait for all clients to terminate before quitting, the second will forcefully disconnect all clients, and the third will quit immediately without proper shutdown, resulting in a recovery run ! during restart. The SIGHUP signal will reload ! the server configuration files. It is also possible to send ! SIGHUP to an individual server process, but that ! is usually not sensible. *************** *** 599,615 **** --- 706,783 ---- + To cancel a running query, send the SIGINT signal + to the process running that command. + + + + The postmaster uses SIGTERM + to tell subordinate server processes to quit normally and + SIGQUIT to terminate without the normal cleanup. + These signals should not be used by users. It + is also unwise to send SIGKILL to a server + process — the main postmaster process will + interpret this as a crash and will force all the sibling processes + to quit as part of its standard crash-recovery procedure. + + + + + Bugs + The + + + + Usage + + To start a single-user mode server, use a command like + + postmaster --single -D /usr/local/pgsql/data other-options my_database + + Provide the correct path to the database directory with + + + Normally, the single-user mode server treats newline as the command + entry terminator; there is no intelligence about semicolons, + as there is in psql. To continue a command + across multiple lines, you must type backslash just before each + newline except the last one. + + + + But if you use the + + + To quit the session, type EOF + (ControlD, usually). + If you've + used + + + Note that the single-user mode server does not provide sophisticated + line-editing features (no command history, for example). + Examples + To start postmaster in the background using default values, type: *************** *** 645,663 **** $ postmaster -c work_mem=1234 $ postmaster --work-mem=1234 ! Either form overrides whatever setting might exist for work_mem ! in postgresql.conf. Notice that underscores in parameter ! names can be written as either underscore or dash on the command line. ! ! ! ! ! Except for short-term experiments, it's probably better practice to edit the setting in postgresql.conf than to rely on a command-line switch to set a parameter. - --- 813,826 ---- $ postmaster -c work_mem=1234 $ postmaster --work-mem=1234 ! Either form overrides whatever setting might exist for ! work_mem in postgresql.conf. Notice that ! underscores in parameter names can be written as either underscore ! or dash on the command line. Except for short-term experiments, it's probably better practice to edit the setting in postgresql.conf than to rely on a command-line switch to set a parameter. *************** *** 669,688 **** - - --- 832,834 ---- diff -cr ../cvs-pgsql/doc/src/sgml/ref/reindex.sgml ./doc/src/sgml/ref/reindex.sgml *** ../cvs-pgsql/doc/src/sgml/ref/reindex.sgml 2005-09-18 11:44:46.000000000 +0200 --- ./doc/src/sgml/ref/reindex.sgml 2006-01-21 15:07:03.000000000 +0100 *************** *** 148,154 **** ! One way to do this is to shut down the postmaster and start a stand-alone PostgreSQL server with the option included on its command line. Then, REINDEX DATABASE, REINDEX SYSTEM, --- 148,154 ---- ! One way to do this is to shut down the server and start a single-user PostgreSQL server with the option included on its command line. Then, REINDEX DATABASE, REINDEX SYSTEM, *************** *** 156,164 **** issued, depending on how much you want to reconstruct. If in doubt, use REINDEX SYSTEM to select reconstruction of all system indexes in the database. Then quit ! the standalone server session and restart the regular server. ! See the reference page for more ! information about how to interact with the stand-alone server interface. --- 156,164 ---- issued, depending on how much you want to reconstruct. If in doubt, use REINDEX SYSTEM to select reconstruction of all system indexes in the database. Then quit ! the single-user server session and restart the regular server. ! See the reference page for more ! information about how to interact with the single-user server interface. diff -cr ../cvs-pgsql/doc/src/sgml/reference.sgml ./doc/src/sgml/reference.sgml *** ../cvs-pgsql/doc/src/sgml/reference.sgml 2005-12-03 22:30:46.000000000 +0100 --- ./doc/src/sgml/reference.sgml 2006-01-21 14:57:04.000000000 +0100 *************** *** 201,207 **** &pgControldata; &pgCtl; &pgResetxlog; - &postgres; &postmaster; --- 201,206 ---- diff -cr ../cvs-pgsql/src/backend/bootstrap/bootstrap.c ./src/backend/bootstrap/bootstrap.c *** ../cvs-pgsql/src/backend/bootstrap/bootstrap.c 2006-01-09 10:57:55.000000000 +0100 --- ./src/backend/bootstrap/bootstrap.c 2006-01-21 17:42:18.000000000 +0100 *************** *** 55,61 **** extern int Int_yyparse(void); - static void usage(void); static void bootstrap_signals(void); static hashnode *AddStr(char *str, int strlength, int mderef); static Form_pg_attribute AllocateAttribute(void); --- 55,60 ---- *************** *** 248,255 **** if (!IsUnderPostmaster) InitializeGUCOptions(); ! /* Ignore the initial -boot argument, if present */ ! if (argc > 1 && strcmp(argv[1], "-boot") == 0) { argv++; argc--; --- 247,254 ---- if (!IsUnderPostmaster) InitializeGUCOptions(); ! /* Ignore the initial --boot argument, if present */ ! if (argc > 1 && strcmp(argv[1], "--boot") == 0) { argv++; argc--; *************** *** 318,324 **** break; } default: ! usage(); break; } } --- 317,325 ---- break; } default: ! write_stderr("Try \"%s --help\" for more information.\n", ! progname); ! proc_exit(1); break; } } *************** *** 329,335 **** optind++; } if (!dbname || argc != optind) ! usage(); /* * Identify myself via ps --- 330,339 ---- optind++; } if (!dbname || argc != optind) ! { ! write_stderr("%s: invalid command-line arguments\n", progname); ! proc_exit(1); ! } /* * Identify myself via ps *************** *** 493,518 **** * ---------------------------------------------------------------- */ - /* 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 */ --- 497,502 ---- diff -cr ../cvs-pgsql/src/backend/main/main.c ./src/backend/main/main.c *** ../cvs-pgsql/src/backend/main/main.c 2006-01-09 10:57:58.000000000 +0100 --- ./src/backend/main/main.c 2006-01-21 17:41:49.000000000 +0100 *************** *** 47,127 **** ! 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 - /* - * 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); ! } ! } ! #endif /* ! * Not-quite-so-platform-specific startup environment checks. Still best ! * to minimize these. */ /* * Remember the physical location of the initially given argv[] array for --- 47,68 ---- ! 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[]) ! { ! const char *progname = get_progname(argv[0]); /* ! * Irrational platform-specific startup hacks */ + startup_hacks(progname); /* * Remember the physical location of the initially given argv[] array for *************** *** 148,170 **** 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. */ ! 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, ""); #else pg_perm_setlocale(LC_COLLATE, ""); pg_perm_setlocale(LC_CTYPE, ""); --- 89,113 ---- 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_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, ""); *************** *** 190,269 **** 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. */ ! if (!(argc > 1 ! && (strcmp(argv[1], "--help") == 0 || ! strcmp(argv[1], "-?") == 0 || ! strcmp(argv[1], "--version") == 0 || ! strcmp(argv[1], "-V") == 0))) { ! #ifndef WIN32 ! /* ! * Make sure we are not running as root. ! */ ! 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 ! * 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()) { ! write_stderr("%s: real and effective user IDs must match\n", ! argv[0]); ! 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 */ } /* ! * 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. */ ! if (strcmp(get_progname(argv[0]), "postmaster") == 0) ! { ! /* Called as "postmaster" */ ! exit(PostmasterMain(argc, argv)); ! } /* ! * 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. */ #ifdef EXEC_BACKEND ! if (argc > 1 && strncmp(argv[1], "-fork", 5) == 0) exit(SubPostmasterMain(argc, argv)); #endif #ifdef WIN32 - /* * Start our win32 signal implementation * --- 133,170 ---- unsetenv("LC_ALL"); /* ! * Catch standard options before doing much else. */ ! if (argc > 1) { ! if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0) { ! help(progname); ! exit(0); } ! if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0) { ! puts("postmaster (PostgreSQL) " PG_VERSION); ! exit(0); } } /* ! * Make sure we are not running as root. */ ! check_root(progname); /* ! * Dispatch to one of various subprograms depending on first ! * argument. */ + #ifdef EXEC_BACKEND ! if (argc > 1 && strncmp(argv[1], "--fork", 6) == 0) exit(SubPostmasterMain(argc, argv)); #endif #ifdef WIN32 /* * Start our win32 signal implementation * *************** *** 273,319 **** 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) 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()); /* ! * Otherwise we're a standalone backend. Invoke PostgresMain, specifying ! * current userid as the "authenticated" Postgres user name. */ #ifndef WIN32 pw = getpwuid(geteuid()); if (pw == NULL) { write_stderr("%s: invalid effective UID: %d\n", ! argv[0], (int) geteuid()); exit(1); } ! /* Allocate new memory because later getpwuid() calls can overwrite it */ ! pw_name_persist = strdup(pw->pw_name); #else ! { ! 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); ! } } - #endif /* WIN32 */ ! exit(PostgresMain(argc, argv, pw_name_persist)); } --- 174,393 ---- pgwin32_signal_initialize(); #endif ! if (argc > 1 && strcmp(argv[1], "--boot") == 0) exit(BootstrapMain(argc, argv)); 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 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. + */ + 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 */ + + + /* + * 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); + } + } + #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 .\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 postmaster 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", ! progname, (int) geteuid()); exit(1); } ! /* 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)) ! { ! write_stderr("%s: could not determine user name (GetUserName failed)\n", ! progname); ! exit(1); } ! return name; ! #endif } diff -cr ../cvs-pgsql/src/backend/Makefile ./src/backend/Makefile *** ../cvs-pgsql/src/backend/Makefile 2006-01-09 10:57:53.000000000 +0100 --- ./src/backend/Makefile 2006-01-20 20:38:18.000000000 +0100 *************** *** 8,14 **** # #------------------------------------------------------------------------- ! PGFILEDESC = "PostgreSQL Database Backend" subdir = src/backend top_builddir = ../.. include $(top_builddir)/src/Makefile.global --- 8,14 ---- # #------------------------------------------------------------------------- ! PGFILEDESC = "PostgreSQL Server" subdir = src/backend top_builddir = ../.. include $(top_builddir)/src/Makefile.global *************** *** 29,41 **** ########################################################################## ! all: submake-libpgport postgres $(POSTGRES_IMP) ifneq ($(PORTNAME), cygwin) ifneq ($(PORTNAME), win32) ifneq ($(PORTNAME), aix) ! postgres: $(OBJS) $(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o $@ endif --- 29,41 ---- ########################################################################## ! all: submake-libpgport postmaster_ $(POSTGRES_IMP) ifneq ($(PORTNAME), cygwin) ifneq ($(PORTNAME), win32) ifneq ($(PORTNAME), aix) ! postmaster_: $(OBJS) $(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o $@ endif *************** *** 44,50 **** ifeq ($(PORTNAME), cygwin) ! postgres: $(OBJS) $(DLLINIT) postgres.def libpostgres.a $(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(LIBS) $(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def --- 44,50 ---- ifeq ($(PORTNAME), cygwin) ! postmaster_: $(OBJS) $(DLLINIT) postgres.def libpostgres.a $(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(LIBS) $(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def *************** *** 55,67 **** $(DLLTOOL) --export-all --output-def $@ $^ libpostgres.a: postgres.def ! $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@ endif # cygwin ifeq ($(PORTNAME), win32) ! postgres: $(OBJS) $(DLLINIT) postgres.def libpostgres.a $(WIN32RES) $(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(WIN32RES) $(LIBS) $(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def --- 55,67 ---- $(DLLTOOL) --export-all --output-def $@ $^ libpostgres.a: postgres.def ! $(DLLTOOL) --dllname postmaster.exe --def postgres.def --output-lib $@ endif # cygwin ifeq ($(PORTNAME), win32) ! postmaster_: $(OBJS) $(DLLINIT) postgres.def libpostgres.a $(WIN32RES) $(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(WIN32RES) $(LIBS) $(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def *************** *** 72,93 **** $(DLLTOOL) --export-all --output-def $@ $^ libpostgres.a: postgres.def ! $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@ endif # win32 ifeq ($(PORTNAME), aix) ! postgres: $(POSTGRES_IMP) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -Wl,-bE:$(top_builddir)/src/backend/$(POSTGRES_IMP) $(LIBS) -o $@ $(POSTGRES_IMP): $(OBJS) $(LD) $(LDREL) $(LDOUT) SUBSYS.o $^ ifeq ($(host_os), aix3.2.5) ! $(MKLDEXPORT) SUBSYS.o $(bindir)/postgres > $@ else ifneq (,$(findstring aix4.1, $(host_os))) ! $(MKLDEXPORT) SUBSYS.o $(bindir)/postgres > $@ else $(MKLDEXPORT) SUBSYS.o . > $@ endif --- 72,93 ---- $(DLLTOOL) --export-all --output-def $@ $^ libpostgres.a: postgres.def ! $(DLLTOOL) --dllname postmaster.exe --def postgres.def --output-lib $@ endif # win32 ifeq ($(PORTNAME), aix) ! postmaster_: $(POSTGRES_IMP) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -Wl,-bE:$(top_builddir)/src/backend/$(POSTGRES_IMP) $(LIBS) -o $@ $(POSTGRES_IMP): $(OBJS) $(LD) $(LDREL) $(LDOUT) SUBSYS.o $^ ifeq ($(host_os), aix3.2.5) ! $(MKLDEXPORT) SUBSYS.o $(bindir)/postmaster_ > $@ else ifneq (,$(findstring aix4.1, $(host_os))) ! $(MKLDEXPORT) SUBSYS.o $(bindir)/postmaster_ > $@ else $(MKLDEXPORT) SUBSYS.o . > $@ endif *************** *** 165,178 **** $(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample '$(DESTDIR)$(datadir)/postgresql.conf.sample' $(INSTALL_DATA) $(srcdir)/access/transam/recovery.conf.sample '$(DESTDIR)$(datadir)/recovery.conf.sample' ! install-bin: postgres $(POSTGRES_IMP) installdirs ! $(INSTALL_PROGRAM) postgres$(X) '$(DESTDIR)$(bindir)/postgres$(X)' ! ifneq ($(PORTNAME), win32) ! @rm -f '$(DESTDIR)$(bindir)/postmaster$(X)' ! ln -s postgres$(X) '$(DESTDIR)$(bindir)/postmaster$(X)' ! else ! $(INSTALL_PROGRAM) postgres$(X) '$(DESTDIR)$(bindir)/postmaster$(X)' ! endif ifeq ($(MAKE_EXPORTS), true) $(INSTALL_DATA) $(POSTGRES_IMP) '$(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)' endif --- 165,172 ---- $(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample '$(DESTDIR)$(datadir)/postgresql.conf.sample' $(INSTALL_DATA) $(srcdir)/access/transam/recovery.conf.sample '$(DESTDIR)$(datadir)/recovery.conf.sample' ! install-bin: postmaster_ $(POSTGRES_IMP) installdirs ! $(INSTALL_PROGRAM) postmaster_$(X) '$(DESTDIR)$(bindir)/postmaster$(X)' ifeq ($(MAKE_EXPORTS), true) $(INSTALL_DATA) $(POSTGRES_IMP) '$(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)' endif *************** *** 199,205 **** ########################################################################## uninstall: ! rm -f '$(DESTDIR)$(bindir)/postgres$(X)' '$(DESTDIR)$(bindir)/postmaster' ifeq ($(MAKE_EXPORTS), true) rm -f '$(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)' endif --- 193,199 ---- ########################################################################## uninstall: ! rm -f '$(DESTDIR)$(bindir)/postmaster' ifeq ($(MAKE_EXPORTS), true) rm -f '$(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)' endif *************** *** 223,229 **** ########################################################################## clean: ! rm -f postgres$(X) $(POSTGRES_IMP) \ $(top_srcdir)/src/include/parser/parse.h \ $(top_builddir)/src/include/utils/fmgroids.h ifeq ($(PORTNAME), cygwin) --- 217,223 ---- ########################################################################## clean: ! rm -f postmaster_$(X) $(POSTGRES_IMP) \ $(top_srcdir)/src/include/parser/parse.h \ $(top_builddir)/src/include/utils/fmgroids.h ifeq ($(PORTNAME), cygwin) *************** *** 251,261 **** # # Support for code development. # ! # Use target "quick" to build "postgres" when you know all the subsystems # are up to date. It saves the time of doing all the submakes. .PHONY: quick quick: $(OBJS) ! $(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o postgres depend dep: $(top_srcdir)/src/include/parser/parse.h $(top_builddir)/src/include/utils/fmgroids.h for i in $(DIRS); do $(MAKE) -C $$i $@; done --- 245,255 ---- # # Support for code development. # ! # Use target "quick" to build "postmaster" when you know all the subsystems # are up to date. It saves the time of doing all the submakes. .PHONY: quick quick: $(OBJS) ! $(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o postmaster_ depend dep: $(top_srcdir)/src/include/parser/parse.h $(top_builddir)/src/include/utils/fmgroids.h for i in $(DIRS); do $(MAKE) -C $$i $@; done diff -cr ../cvs-pgsql/src/backend/postmaster/autovacuum.c ./src/backend/postmaster/autovacuum.c *** ../cvs-pgsql/src/backend/postmaster/autovacuum.c 2006-01-20 19:02:07.000000000 +0100 --- ./src/backend/postmaster/autovacuum.c 2006-01-20 20:13:15.000000000 +0100 *************** *** 202,209 **** char *av[10]; int ac = 0; ! av[ac++] = "postgres"; ! av[ac++] = "-forkautovac"; av[ac++] = NULL; /* filled in by postmaster_forkexec */ av[ac] = NULL; --- 202,209 ---- char *av[10]; int ac = 0; ! av[ac++] = "postmaster"; ! av[ac++] = "--forkautovac"; av[ac++] = NULL; /* filled in by postmaster_forkexec */ av[ac] = NULL; diff -cr ../cvs-pgsql/src/backend/postmaster/pgarch.c ./src/backend/postmaster/pgarch.c *** ../cvs-pgsql/src/backend/postmaster/pgarch.c 2006-01-09 10:58:10.000000000 +0100 --- ./src/backend/postmaster/pgarch.c 2006-01-20 20:13:17.000000000 +0100 *************** *** 195,203 **** char *av[10]; int ac = 0; ! av[ac++] = "postgres"; ! av[ac++] = "-forkarch"; av[ac++] = NULL; /* filled in by postmaster_forkexec */ --- 195,203 ---- char *av[10]; int ac = 0; ! av[ac++] = "postmaster"; ! av[ac++] = "--forkarch"; av[ac++] = NULL; /* filled in by postmaster_forkexec */ diff -cr ../cvs-pgsql/src/backend/postmaster/pgstat.c ./src/backend/postmaster/pgstat.c *** ../cvs-pgsql/src/backend/postmaster/pgstat.c 2006-01-20 19:02:08.000000000 +0100 --- ./src/backend/postmaster/pgstat.c 2006-01-20 20:13:16.000000000 +0100 *************** *** 488,503 **** i; char pgstatBuf[2][32]; ! av[ac++] = "postgres"; switch (procType) { case STAT_PROC_BUFFER: ! av[ac++] = "-forkbuf"; break; case STAT_PROC_COLLECTOR: ! av[ac++] = "-forkcol"; break; default: --- 488,503 ---- i; char pgstatBuf[2][32]; ! av[ac++] = "postmaster"; switch (procType) { case STAT_PROC_BUFFER: ! av[ac++] = "--forkbuf"; break; case STAT_PROC_COLLECTOR: ! av[ac++] = "--forkcol"; break; default: diff -cr ../cvs-pgsql/src/backend/postmaster/postmaster.c ./src/backend/postmaster/postmaster.c *** ../cvs-pgsql/src/backend/postmaster/postmaster.c 2006-01-09 10:58:10.000000000 +0100 --- ./src/backend/postmaster/postmaster.c 2006-01-21 22:55:28.000000000 +0100 *************** *** 269,275 **** 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); --- 269,274 ---- *************** *** 391,419 **** 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 */ umask((mode_t) 0077); --- 390,395 ---- *************** *** 629,635 **** #ifdef EXEC_BACKEND /* Locate executable backend before we change working directory */ ! if (find_other_exec(argv[0], "postgres", PG_VERSIONSTR, postgres_exec_path) < 0) ereport(FATAL, (errmsg("%s: could not locate matching postgres executable", --- 605,611 ---- #ifdef EXEC_BACKEND /* Locate executable backend before we change working directory */ ! if (find_other_exec(argv[0], "postmaster", PG_VERSIONSTR, postgres_exec_path) < 0) ereport(FATAL, (errmsg("%s: could not locate matching postgres executable", *************** *** 1140,1194 **** /* - * 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 .\n")); - } - - - /* * Main idle loop of postmaster */ static int --- 1116,1121 ---- *************** *** 2864,2870 **** maxac * sizeof(char *)); ac = 0; ! av[ac++] = "postgres"; /* * Pass any backend switches specified with -o in the postmaster's own --- 2791,2797 ---- maxac * sizeof(char *)); ac = 0; ! av[ac++] = "postmaster"; /* * Pass any backend switches specified with -o in the postmaster's own *************** *** 2959,2966 **** char *av[4]; int ac = 0; ! av[ac++] = "postgres"; ! av[ac++] = "-forkbackend"; av[ac++] = NULL; /* filled in by internal_forkexec */ av[ac] = NULL; --- 2886,2893 ---- char *av[4]; int ac = 0; ! av[ac++] = "postmaster"; ! av[ac++] = "--forkbackend"; av[ac++] = NULL; /* filled in by internal_forkexec */ av[ac] = NULL; *************** *** 3033,3042 **** /* Make sure caller set up argv properly */ Assert(argc >= 3); Assert(argv[argc] == NULL); ! Assert(strncmp(argv[1], "-fork", 5) == 0); Assert(argv[2] == NULL); ! /* Insert temp file name after -fork argument */ argv[2] = tmpfilename; /* Fire off execv in child */ --- 2960,2969 ---- /* Make sure caller set up argv properly */ Assert(argc >= 3); Assert(argv[argc] == NULL); ! Assert(strncmp(argv[1], "--fork", 6) == 0); Assert(argv[2] == NULL); ! /* Insert temp file name after --fork argument */ argv[2] = tmpfilename; /* Fire off execv in child */ *************** *** 3084,3090 **** /* Make sure caller set up argv properly */ Assert(argc >= 3); Assert(argv[argc] == NULL); ! Assert(strncmp(argv[1], "-fork", 5) == 0); Assert(argv[2] == NULL); /* Verify that there is room in the child list */ --- 3011,3017 ---- /* Make sure caller set up argv properly */ Assert(argc >= 3); Assert(argv[argc] == NULL); ! Assert(strncmp(argv[1], "--fork", 6) == 0); Assert(argv[2] == NULL); /* Verify that there is room in the child list */ *************** *** 3122,3128 **** return -1; } ! /* Insert temp file name after -fork argument */ sprintf(paramHandleStr, "%lu", (DWORD) paramHandle); argv[2] = paramHandleStr; --- 3049,3055 ---- return -1; } ! /* Insert temp file name after --fork argument */ sprintf(paramHandleStr, "%lu", (DWORD) paramHandle); argv[2] = paramHandleStr; *************** *** 3245,3251 **** * 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" * (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 --- 3172,3178 ---- * 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" * (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 *************** *** 3285,3293 **** * 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) PGSharedMemoryReAttach(); /* --- 3212,3220 ---- * 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) PGSharedMemoryReAttach(); /* *************** *** 3307,3313 **** read_nondefault_variables(); /* Run backend or appropriate child */ ! if (strcmp(argv[1], "-forkbackend") == 0) { Assert(argc == 3); /* shouldn't be any more args */ --- 3234,3240 ---- read_nondefault_variables(); /* Run backend or appropriate child */ ! if (strcmp(argv[1], "--forkbackend") == 0) { Assert(argc == 3); /* shouldn't be any more args */ *************** *** 3348,3354 **** /* And run the backend */ proc_exit(BackendRun(&port)); } ! if (strcmp(argv[1], "-forkboot") == 0) { /* Close the postmaster's sockets */ ClosePostmasterPorts(false); --- 3275,3281 ---- /* And run the backend */ proc_exit(BackendRun(&port)); } ! if (strcmp(argv[1], "--forkboot") == 0) { /* Close the postmaster's sockets */ ClosePostmasterPorts(false); *************** *** 3365,3371 **** BootstrapMain(argc - 2, argv + 2); proc_exit(0); } ! if (strcmp(argv[1], "-forkautovac") == 0) { /* Close the postmaster's sockets */ ClosePostmasterPorts(false); --- 3292,3298 ---- BootstrapMain(argc - 2, argv + 2); proc_exit(0); } ! if (strcmp(argv[1], "--forkautovac") == 0) { /* Close the postmaster's sockets */ ClosePostmasterPorts(false); *************** *** 3382,3388 **** AutoVacMain(argc - 2, argv + 2); proc_exit(0); } ! if (strcmp(argv[1], "-forkarch") == 0) { /* Close the postmaster's sockets */ ClosePostmasterPorts(false); --- 3309,3315 ---- AutoVacMain(argc - 2, argv + 2); proc_exit(0); } ! if (strcmp(argv[1], "--forkarch") == 0) { /* Close the postmaster's sockets */ ClosePostmasterPorts(false); *************** *** 3392,3398 **** PgArchiverMain(argc, argv); proc_exit(0); } ! if (strcmp(argv[1], "-forkbuf") == 0) { /* Close the postmaster's sockets */ ClosePostmasterPorts(false); --- 3319,3325 ---- PgArchiverMain(argc, argv); proc_exit(0); } ! if (strcmp(argv[1], "--forkbuf") == 0) { /* Close the postmaster's sockets */ ClosePostmasterPorts(false); *************** *** 3402,3408 **** PgstatBufferMain(argc, argv); proc_exit(0); } ! if (strcmp(argv[1], "-forkcol") == 0) { /* * Do NOT close postmaster sockets here, because we are forking from --- 3329,3335 ---- PgstatBufferMain(argc, argv); proc_exit(0); } ! if (strcmp(argv[1], "--forkcol") == 0) { /* * Do NOT close postmaster sockets here, because we are forking from *************** *** 3414,3420 **** PgstatCollectorMain(argc, argv); proc_exit(0); } ! if (strcmp(argv[1], "-forklog") == 0) { /* Close the postmaster's sockets */ ClosePostmasterPorts(true); --- 3341,3347 ---- PgstatCollectorMain(argc, argv); proc_exit(0); } ! if (strcmp(argv[1], "--forklog") == 0) { /* Close the postmaster's sockets */ ClosePostmasterPorts(true); *************** *** 3624,3633 **** /* * Set up command-line arguments for subprocess */ ! av[ac++] = "postgres"; #ifdef EXEC_BACKEND ! av[ac++] = "-forkboot"; av[ac++] = NULL; /* filled in by postmaster_forkexec */ #endif --- 3551,3560 ---- /* * Set up command-line arguments for subprocess */ ! av[ac++] = "postmaster"; #ifdef EXEC_BACKEND ! av[ac++] = "--forkboot"; av[ac++] = NULL; /* filled in by postmaster_forkexec */ #endif diff -cr ../cvs-pgsql/src/backend/postmaster/syslogger.c ./src/backend/postmaster/syslogger.c *** ../cvs-pgsql/src/backend/postmaster/syslogger.c 2006-01-09 10:58:10.000000000 +0100 --- ./src/backend/postmaster/syslogger.c 2006-01-20 20:13:16.000000000 +0100 *************** *** 533,540 **** i; char numbuf[2][32]; ! av[ac++] = "postgres"; ! av[ac++] = "-forklog"; av[ac++] = NULL; /* filled in by postmaster_forkexec */ /* static variables (those not passed by write_backend_variables) */ --- 533,540 ---- i; char numbuf[2][32]; ! av[ac++] = "postmaster"; ! av[ac++] = "--forklog"; av[ac++] = NULL; /* filled in by postmaster_forkexec */ /* static variables (those not passed by write_backend_variables) */ diff -cr ../cvs-pgsql/src/backend/tcop/postgres.c ./src/backend/tcop/postgres.c *** ../cvs-pgsql/src/backend/tcop/postgres.c 2006-01-20 19:02:09.000000000 +0100 --- ./src/backend/tcop/postgres.c 2006-01-20 20:49:27.000000000 +0100 *************** *** 2342,2382 **** } - 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 .\n")); - } - - /* * set_debug_options --- apply "-d N" command line option * --- 2342,2347 ---- *************** *** 2507,2530 **** 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) */ --- 2472,2477 ---- *************** *** 2581,2586 **** --- 2528,2540 ---- * ---------------- */ + /* 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; diff -cr ../cvs-pgsql/src/bin/initdb/initdb.c ./src/bin/initdb/initdb.c *** ../cvs-pgsql/src/bin/initdb/initdb.c 2006-01-09 10:58:16.000000000 +0100 --- ./src/bin/initdb/initdb.c 2006-01-20 20:44:08.000000000 +0100 *************** *** 71,77 **** /* version string we expect back from postgres */ ! #define PG_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n" /* * these values are passed in by makefile defines --- 71,77 ---- /* version string we expect back from postgres */ ! #define PG_VERSIONSTR "postmaster (PostgreSQL) " PG_VERSION "\n" /* * these values are passed in by makefile defines *************** *** 140,146 **** * (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"; /* path to 'initdb' binary directory */ --- 140,146 ---- * (no quoting to worry about). */ static const char *boot_options = "-F"; ! static const char *backend_options = "--single -F -O -c search_path=pg_catalog -c exit_on_error=true"; /* path to 'initdb' binary directory */ *************** *** 195,201 **** /* ! * macros for running pipes to postgres */ #define PG_CMD_DECL char cmd[MAXPGPATH]; FILE *cmdfd --- 195,201 ---- /* ! * macros for running pipes to postmaster */ #define PG_CMD_DECL char cmd[MAXPGPATH]; FILE *cmdfd *************** *** 1131,1137 **** test_max_fsm = FSM_FOR_BUFS(test_buffs); snprintf(cmd, sizeof(cmd), ! "%s\"%s\" -boot -x0 %s " "-c max_connections=%d " "-c shared_buffers=%d " "-c max_fsm_pages=%d " --- 1131,1137 ---- test_max_fsm = FSM_FOR_BUFS(test_buffs); snprintf(cmd, sizeof(cmd), ! "%s\"%s\" --boot -x0 %s " "-c max_connections=%d " "-c shared_buffers=%d " "-c max_fsm_pages=%d " *************** *** 1166,1172 **** test_max_fsm = FSM_FOR_BUFS(test_buffs); snprintf(cmd, sizeof(cmd), ! "%s\"%s\" -boot -x0 %s " "-c max_connections=%d " "-c shared_buffers=%d " "-c max_fsm_pages=%d " --- 1166,1172 ---- test_max_fsm = FSM_FOR_BUFS(test_buffs); snprintf(cmd, sizeof(cmd), ! "%s\"%s\" --boot -x0 %s " "-c max_connections=%d " "-c shared_buffers=%d " "-c max_fsm_pages=%d " *************** *** 1395,1401 **** unsetenv("PGCLIENTENCODING"); snprintf(cmd, sizeof(cmd), ! "\"%s\" -boot -x1 %s %s template1", backend_exec, boot_options, talkargs); PG_CMD_OPEN; --- 1395,1401 ---- unsetenv("PGCLIENTENCODING"); snprintf(cmd, sizeof(cmd), ! "\"%s\" --boot -x1 %s %s template1", backend_exec, boot_options, talkargs); PG_CMD_OPEN; *************** *** 1463,1469 **** } /* ! * get the superuser password if required, and call postgres to set it */ static void get_set_pwd(void) --- 1463,1469 ---- } /* ! * get the superuser password if required, and call postmaster to set it */ static void get_set_pwd(void) *************** *** 2498,2504 **** canonicalize_path(pg_data); /* ! * we have to set PGDATA for postgres rather than pass it on the command * line to avoid dumb quoting problems on Windows, and we would especially * need quotes otherwise on Windows because paths there are most likely to * have embedded spaces. --- 2498,2504 ---- canonicalize_path(pg_data); /* ! * we have to set PGDATA for postmaster rather than pass it on the command * line to avoid dumb quoting problems on Windows, and we would especially * need quotes otherwise on Windows because paths there are most likely to * have embedded spaces. *************** *** 2507,2513 **** sprintf(pgdenv, "PGDATA=%s", pg_data); putenv(pgdenv); ! if ((ret = find_other_exec(argv[0], "postgres", PG_VERSIONSTR, backend_exec)) < 0) { char full_path[MAXPGPATH]; --- 2507,2513 ---- sprintf(pgdenv, "PGDATA=%s", pg_data); putenv(pgdenv); ! if ((ret = find_other_exec(argv[0], "postmaster", PG_VERSIONSTR, backend_exec)) < 0) { char full_path[MAXPGPATH]; *************** *** 2517,2530 **** if (ret == -1) fprintf(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 fprintf(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); --- 2517,2530 ---- if (ret == -1) fprintf(stderr, ! _("The program \"postmaster\" is needed by %s " "but was not found in the\n" "same directory as \"%s\".\n" "Check your installation.\n"), progname, full_path); else fprintf(stderr, ! _("The program \"postmaster\" was found by \"%s\"\n" "but was not the same version as %s.\n" "Check your installation.\n"), full_path, progname); diff -cr ../cvs-pgsql/src/include/miscadmin.h ./src/include/miscadmin.h *** ../cvs-pgsql/src/include/miscadmin.h 2006-01-09 10:58:23.000000000 +0100 --- ./src/include/miscadmin.h 2006-01-21 22:55:25.000000000 +0100 *************** *** 24,30 **** #define MISCADMIN_H ! #define PG_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n" /***************************************************************************** --- 24,30 ---- #define MISCADMIN_H ! #define PG_VERSIONSTR "postmaster (PostgreSQL) " PG_VERSION "\n" /*****************************************************************************