Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite09155b

Browse files
committed
Add --no-instructions parameter to initdb
Specifying this parameter removes the informational messages about howto start the server. This is intended for use by wrappers in differentpackaging systems, where those instructions would most likely be wronganyway, but the other output from initdb would still be useful (and thusjust redirecting everything to /dev/null would be bad).Author: Magnus HaganderReviewed-By: Peter EisentrautDiscusion:https://postgr.es/m/CABUevEzo4t5bmTXF0_B9WzmuWpVbMpkNZZiGvzV8NZa-=fPqeQ@mail.gmail.com
1 parent960869d commite09155b

File tree

2 files changed

+47
-22
lines changed

2 files changed

+47
-22
lines changed

‎doc/src/sgml/ref/initdb.sgml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,19 @@ PostgreSQL documentation
275275
</listitem>
276276
</varlistentry>
277277

278+
<varlistentry>
279+
<term><option>--no-instructions</option></term>
280+
<listitem>
281+
<para>
282+
By default, <command>initdb</command> will write instructions for how
283+
to start the cluster at the end of its output. This option causes
284+
those instructions to be left out. This is primarily intended for use
285+
by tools that wrap <command>initdb</command> in platform specific
286+
behavior, where those instructions are likely to be incorrect.
287+
</para>
288+
</listitem>
289+
</varlistentry>
290+
278291
<varlistentry>
279292
<term><option>--pwfile=<replaceable>filename</replaceable></option></term>
280293
<listitem>

‎src/bin/initdb/initdb.c

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ static const char *authmethodhost = NULL;
139139
staticconstchar*authmethodlocal=NULL;
140140
staticbooldebug= false;
141141
staticboolnoclean= false;
142+
staticboolnoinstructions= false;
142143
staticbooldo_sync= true;
143144
staticboolsync_only= false;
144145
staticboolshow_setting= false;
@@ -2294,6 +2295,7 @@ usage(const char *progname)
22942295
printf(_(" -L DIRECTORY where to find the input files\n"));
22952296
printf(_(" -n, --no-clean do not clean up after errors\n"));
22962297
printf(_(" -N, --no-sync do not wait for changes to be written safely to disk\n"));
2298+
printf(_(" --no-instructions do not print instructions for next steps\n"));
22972299
printf(_(" -s, --show show internal settings\n"));
22982300
printf(_(" -S, --sync-only only sync data directory\n"));
22992301
printf(_("\nOther options:\n"));
@@ -2955,6 +2957,7 @@ main(int argc, char *argv[])
29552957
{"no-clean",no_argument,NULL,'n'},
29562958
{"nosync",no_argument,NULL,'N'},/* for backwards compatibility */
29572959
{"no-sync",no_argument,NULL,'N'},
2960+
{"no-instructions",no_argument,NULL,13},
29582961
{"sync-only",no_argument,NULL,'S'},
29592962
{"waldir",required_argument,NULL,'X'},
29602963
{"wal-segsize",required_argument,NULL,12},
@@ -3095,6 +3098,9 @@ main(int argc, char *argv[])
30953098
case12:
30963099
str_wal_segment_size_mb=pg_strdup(optarg);
30973100
break;
3101+
case13:
3102+
noinstructions= true;
3103+
break;
30983104
case'g':
30993105
SetDataDirectoryCreatePerm(PG_DIR_MODE_GROUP);
31003106
break;
@@ -3245,34 +3251,40 @@ main(int argc, char *argv[])
32453251
"--auth-local and --auth-host, the next time you run initdb.\n"));
32463252
}
32473253

3248-
/*
3249-
* Build up a shell command to tell the user how to start the server
3250-
*/
3251-
start_db_cmd=createPQExpBuffer();
3254+
if (!noinstructions)
3255+
{
3256+
/*
3257+
* Build up a shell command to tell the user how to start the server
3258+
*/
3259+
start_db_cmd=createPQExpBuffer();
3260+
3261+
/* Get directory specification used to start initdb ... */
3262+
strlcpy(pg_ctl_path,argv[0],sizeof(pg_ctl_path));
3263+
canonicalize_path(pg_ctl_path);
3264+
get_parent_directory(pg_ctl_path);
3265+
/* ... and tag on pg_ctl instead */
3266+
join_path_components(pg_ctl_path,pg_ctl_path,"pg_ctl");
32523267

3253-
/* Get directory specification used to start initdb ... */
3254-
strlcpy(pg_ctl_path,argv[0],sizeof(pg_ctl_path));
3255-
canonicalize_path(pg_ctl_path);
3256-
get_parent_directory(pg_ctl_path);
3257-
/* ... and tag on pg_ctl instead */
3258-
join_path_components(pg_ctl_path,pg_ctl_path,"pg_ctl");
3268+
/* path to pg_ctl, properly quoted */
3269+
appendShellString(start_db_cmd,pg_ctl_path);
32593270

3260-
/* path to pg_ctl, properly quoted */
3261-
appendShellString(start_db_cmd,pg_ctl_path);
3271+
/* add -D switch, with properly quoted data directory */
3272+
appendPQExpBufferStr(start_db_cmd," -D ");
3273+
appendShellString(start_db_cmd,pgdata_native);
32623274

3263-
/* add-D switch, with properly quoted data directory */
3264-
appendPQExpBufferStr(start_db_cmd," -D ");
3265-
appendShellString(start_db_cmd,pgdata_native);
3275+
/* addsuggested -l switch and "start" command */
3276+
/* translator: This is a placeholder in a shell command. */
3277+
appendPQExpBuffer(start_db_cmd," -l %s start",_("logfile"));
32663278

3267-
/* add suggested -l switch and "start" command */
3268-
/* translator: This is a placeholder in a shell command. */
3269-
appendPQExpBuffer(start_db_cmd," -l %s start",_("logfile"));
3279+
printf(_("\nSuccess. You can now start the database server using:\n\n"
3280+
" %s\n\n"),
3281+
start_db_cmd->data);
32703282

3271-
printf(_("\nSuccess. You can now start the database server using:\n\n"
3272-
" %s\n\n"),
3273-
start_db_cmd->data);
3283+
destroyPQExpBuffer(start_db_cmd);
3284+
3285+
printf(_("\nSuccess.\n"));
3286+
}
32743287

3275-
destroyPQExpBuffer(start_db_cmd);
32763288

32773289
success= true;
32783290
return0;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp