Commit 187ca5e8 authored by Peter Eisentraut's avatar Peter Eisentraut

Revert "pg_ctl: Add idempotent option"

This reverts commit 87306184.  The
behavior in certain cases is still being debated, and it's too late to
solve this before beta.
parent db9f0e1d
...@@ -89,12 +89,12 @@ case $1 in ...@@ -89,12 +89,12 @@ case $1 in
;; ;;
stop) stop)
echo -n "Stopping PostgreSQL: " echo -n "Stopping PostgreSQL: "
su - $PGUSER -c "$PGCTL stop -I -D '$PGDATA' -s -m fast" su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast"
echo "ok" echo "ok"
;; ;;
restart) restart)
echo -n "Restarting PostgreSQL: " echo -n "Restarting PostgreSQL: "
su - $PGUSER -c "$PGCTL stop -I -D '$PGDATA' -s -m fast -w" su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w"
test x"$OOM_SCORE_ADJ" != x && echo "$OOM_SCORE_ADJ" > /proc/self/oom_score_adj test x"$OOM_SCORE_ADJ" != x && echo "$OOM_SCORE_ADJ" > /proc/self/oom_score_adj
test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adj test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adj
su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1 su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
......
...@@ -39,7 +39,6 @@ PostgreSQL documentation ...@@ -39,7 +39,6 @@ PostgreSQL documentation
<arg choice="opt"><option>-o</option> <replaceable>options</replaceable></arg> <arg choice="opt"><option>-o</option> <replaceable>options</replaceable></arg>
<arg choice="opt"><option>-p</option> <replaceable>path</replaceable></arg> <arg choice="opt"><option>-p</option> <replaceable>path</replaceable></arg>
<arg choice="opt"><option>-c</option></arg> <arg choice="opt"><option>-c</option></arg>
<arg choice="opt"><option>-I</option></arg>
</cmdsynopsis> </cmdsynopsis>
<cmdsynopsis> <cmdsynopsis>
...@@ -56,7 +55,6 @@ PostgreSQL documentation ...@@ -56,7 +55,6 @@ PostgreSQL documentation
<arg choice="plain"><option>i[mmediate]</option></arg> <arg choice="plain"><option>i[mmediate]</option></arg>
</group> </group>
</arg> </arg>
<arg choice="opt"><option>-I</option></arg>
</cmdsynopsis> </cmdsynopsis>
<cmdsynopsis> <cmdsynopsis>
...@@ -272,25 +270,6 @@ PostgreSQL documentation ...@@ -272,25 +270,6 @@ PostgreSQL documentation
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>-I</option></term>
<term><option>--idempotent</option></term>
<listitem>
<para>
When used with the <literal>start</literal> or <literal>stop</literal>
actions, return exit code 0 if the server is already running or
stopped, respectively. Otherwise, an error is raised and a nonzero
exit code is returned in these cases.
</para>
<para>
This option is useful for System-V-style init scripts, which require
the <literal>start</literal> and <literal>stop</literal> actions to be
idempotent.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>-l <replaceable class="parameter">filename</replaceable></option></term> <term><option>-l <replaceable class="parameter">filename</replaceable></option></term>
<term><option>--log <replaceable class="parameter">filename</replaceable></option></term> <term><option>--log <replaceable class="parameter">filename</replaceable></option></term>
......
...@@ -85,7 +85,6 @@ static char *pg_config = NULL; ...@@ -85,7 +85,6 @@ static char *pg_config = NULL;
static char *pgdata_opt = NULL; static char *pgdata_opt = NULL;
static char *post_opts = NULL; static char *post_opts = NULL;
static const char *progname; static const char *progname;
static bool idempotent = false;
static char *log_file = NULL; static char *log_file = NULL;
static char *exec_path = NULL; static char *exec_path = NULL;
static char *register_servicename = "PostgreSQL"; /* FIXME: + version ID? */ static char *register_servicename = "PostgreSQL"; /* FIXME: + version ID? */
...@@ -774,15 +773,9 @@ do_start(void) ...@@ -774,15 +773,9 @@ do_start(void)
{ {
old_pid = get_pgpid(); old_pid = get_pgpid();
if (old_pid != 0) if (old_pid != 0)
{ write_stderr(_("%s: another server might be running; "
if (idempotent) "trying to start server anyway\n"),
exit(0); progname);
else
{
write_stderr(_("%s: another server might be running\n"), progname);
exit(1);
}
}
} }
read_post_opts(); read_post_opts();
...@@ -866,8 +859,6 @@ do_stop(void) ...@@ -866,8 +859,6 @@ do_stop(void)
if (pid == 0) /* no pid file */ if (pid == 0) /* no pid file */
{ {
if (idempotent)
exit(0);
write_stderr(_("%s: PID file \"%s\" does not exist\n"), progname, pid_file); write_stderr(_("%s: PID file \"%s\" does not exist\n"), progname, pid_file);
write_stderr(_("Is server running?\n")); write_stderr(_("Is server running?\n"));
exit(1); exit(1);
...@@ -1771,8 +1762,8 @@ do_help(void) ...@@ -1771,8 +1762,8 @@ do_help(void)
printf(_("%s is a utility to initialize, start, stop, or control a PostgreSQL server.\n\n"), progname); printf(_("%s is a utility to initialize, start, stop, or control a PostgreSQL server.\n\n"), progname);
printf(_("Usage:\n")); printf(_("Usage:\n"));
printf(_(" %s init[db] [-D DATADIR] [-s] [-o \"OPTIONS\"]\n"), progname); printf(_(" %s init[db] [-D DATADIR] [-s] [-o \"OPTIONS\"]\n"), progname);
printf(_(" %s start [-w] [-t SECS] [-D DATADIR] [-s] [-I] [-l FILENAME] [-o \"OPTIONS\"]\n"), progname); printf(_(" %s start [-w] [-t SECS] [-D DATADIR] [-s] [-l FILENAME] [-o \"OPTIONS\"]\n"), progname);
printf(_(" %s stop [-W] [-t SECS] [-D DATADIR] [-s] [-I] [-m SHUTDOWN-MODE]\n"), progname); printf(_(" %s stop [-W] [-t SECS] [-D DATADIR] [-s] [-m SHUTDOWN-MODE]\n"), progname);
printf(_(" %s restart [-w] [-t SECS] [-D DATADIR] [-s] [-m SHUTDOWN-MODE]\n" printf(_(" %s restart [-w] [-t SECS] [-D DATADIR] [-s] [-m SHUTDOWN-MODE]\n"
" [-o \"OPTIONS\"]\n"), progname); " [-o \"OPTIONS\"]\n"), progname);
printf(_(" %s reload [-D DATADIR] [-s]\n"), progname); printf(_(" %s reload [-D DATADIR] [-s]\n"), progname);
...@@ -1806,8 +1797,6 @@ do_help(void) ...@@ -1806,8 +1797,6 @@ do_help(void)
printf(_(" -o OPTIONS command line options to pass to postgres\n" printf(_(" -o OPTIONS command line options to pass to postgres\n"
" (PostgreSQL server executable) or initdb\n")); " (PostgreSQL server executable) or initdb\n"));
printf(_(" -p PATH-TO-POSTGRES normally not necessary\n")); printf(_(" -p PATH-TO-POSTGRES normally not necessary\n"));
printf(_("\nOptions for start or stop:\n"));
printf(_(" -I, --idempotent don't error if server already running or stopped\n"));
printf(_("\nOptions for stop, restart, or promote:\n")); printf(_("\nOptions for stop, restart, or promote:\n"));
printf(_(" -m, --mode=MODE MODE can be \"smart\", \"fast\", or \"immediate\"\n")); printf(_(" -m, --mode=MODE MODE can be \"smart\", \"fast\", or \"immediate\"\n"));
...@@ -1986,7 +1975,6 @@ main(int argc, char **argv) ...@@ -1986,7 +1975,6 @@ main(int argc, char **argv)
{"silent", no_argument, NULL, 's'}, {"silent", no_argument, NULL, 's'},
{"timeout", required_argument, NULL, 't'}, {"timeout", required_argument, NULL, 't'},
{"core-files", no_argument, NULL, 'c'}, {"core-files", no_argument, NULL, 'c'},
{"idempotent", no_argument, NULL, 'I'},
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
}; };
...@@ -2052,7 +2040,7 @@ main(int argc, char **argv) ...@@ -2052,7 +2040,7 @@ main(int argc, char **argv)
/* process command-line options */ /* process command-line options */
while (optind < argc) while (optind < argc)
{ {
while ((c = getopt_long(argc, argv, "cD:Il:m:N:o:p:P:sS:t:U:wW", long_options, &option_index)) != -1) while ((c = getopt_long(argc, argv, "cD:l:m:N:o:p:P:sS:t:U:wW", long_options, &option_index)) != -1)
{ {
switch (c) switch (c)
{ {
...@@ -2078,9 +2066,6 @@ main(int argc, char **argv) ...@@ -2078,9 +2066,6 @@ main(int argc, char **argv)
pgdata_D); pgdata_D);
break; break;
} }
case 'I':
idempotent = true;
break;
case 'l': case 'l':
log_file = pg_strdup(optarg); log_file = pg_strdup(optarg);
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment