Skip to content

Commit 26374f2

Browse files
committed
In initdb.c, rename some newly created functions, and move the directory
creation and xlog symlink creation to separate functions. Per suggestions from Andrew Dunstan.
1 parent 630cd14 commit 26374f2

File tree

1 file changed

+41
-25
lines changed

1 file changed

+41
-25
lines changed

src/bin/initdb/initdb.c

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,11 @@ void setup_pgdata(void);
255255
void setup_bin_paths(const char *argv0);
256256
void setup_data_file_paths(void);
257257
void setup_locale_encoding(void);
258-
void setup_signals_and_umask(void);
258+
void setup_signals(void);
259259
void setup_text_search(void);
260-
void process(const char *argv0);
260+
void create_data_directory(void);
261+
void create_xlog_symlink(void);
262+
void initialize_data_directory(void);
261263

262264

263265
#ifdef WIN32
@@ -3164,7 +3166,7 @@ setup_text_search(void)
31643166

31653167

31663168
void
3167-
setup_signals_and_umask(void)
3169+
setup_signals(void)
31683170
{
31693171
/* some of these are not valid on Windows */
31703172
#ifdef SIGHUP
@@ -3184,19 +3186,12 @@ setup_signals_and_umask(void)
31843186
#ifdef SIGPIPE
31853187
pqsignal(SIGPIPE, SIG_IGN);
31863188
#endif
3187-
3188-
umask(S_IRWXG | S_IRWXO);
31893189
}
31903190

31913191

31923192
void
3193-
process(const char *argv0)
3193+
create_data_directory(void)
31943194
{
3195-
int i;
3196-
char bin_dir[MAXPGPATH];
3197-
3198-
setup_signals_and_umask();
3199-
32003195
switch (pg_check_dir(pg_data))
32013196
{
32023197
case 0:
@@ -3249,7 +3244,12 @@ process(const char *argv0)
32493244
progname, pg_data, strerror(errno));
32503245
exit_nicely();
32513246
}
3247+
}
3248+
32523249

3250+
void
3251+
create_xlog_symlink(void)
3252+
{
32533253
/* Create transaction log symlink, if required */
32543254
if (strcmp(xlog_dir, "") != 0)
32553255
{
@@ -3336,6 +3336,21 @@ process(const char *argv0)
33363336
exit_nicely();
33373337
#endif
33383338
}
3339+
}
3340+
3341+
3342+
void
3343+
initialize_data_directory(void)
3344+
{
3345+
int i;
3346+
3347+
setup_signals();
3348+
3349+
umask(S_IRWXG | S_IRWXO);
3350+
3351+
create_data_directory();
3352+
3353+
create_xlog_symlink();
33393354

33403355
/* Create required subdirectories */
33413356
printf(_("creating subdirectories ... "));
@@ -3404,19 +3419,6 @@ process(const char *argv0)
34043419

34053420
if (authwarning != NULL)
34063421
fprintf(stderr, "%s", authwarning);
3407-
3408-
/* Get directory specification used to start this executable */
3409-
strlcpy(bin_dir, argv0, sizeof(bin_dir));
3410-
get_parent_directory(bin_dir);
3411-
3412-
printf(_("\nSuccess. You can now start the database server using:\n\n"
3413-
" %s%s%spostgres%s -D %s%s%s\n"
3414-
"or\n"
3415-
" %s%s%spg_ctl%s -D %s%s%s -l logfile start\n\n"),
3416-
QUOTE_PATH, bin_dir, (strlen(bin_dir) > 0) ? DIR_SEP : "", QUOTE_PATH,
3417-
QUOTE_PATH, pgdata_native, QUOTE_PATH,
3418-
QUOTE_PATH, bin_dir, (strlen(bin_dir) > 0) ? DIR_SEP : "", QUOTE_PATH,
3419-
QUOTE_PATH, pgdata_native, QUOTE_PATH);
34203422
}
34213423

34223424

@@ -3459,6 +3461,7 @@ main(int argc, char *argv[])
34593461
int c;
34603462
int option_index;
34613463
char *effective_user;
3464+
char bin_dir[MAXPGPATH];
34623465

34633466
progname = get_progname(argv[0]);
34643467
set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("initdb"));
@@ -3642,7 +3645,20 @@ main(int argc, char *argv[])
36423645

36433646
printf("\n");
36443647

3645-
process(argv[0]);
3648+
initialize_data_directory();
36463649

3650+
/* Get directory specification used to start this executable */
3651+
strlcpy(bin_dir, argv[0], sizeof(bin_dir));
3652+
get_parent_directory(bin_dir);
3653+
3654+
printf(_("\nSuccess. You can now start the database server using:\n\n"
3655+
" %s%s%spostgres%s -D %s%s%s\n"
3656+
"or\n"
3657+
" %s%s%spg_ctl%s -D %s%s%s -l logfile start\n\n"),
3658+
QUOTE_PATH, bin_dir, (strlen(bin_dir) > 0) ? DIR_SEP : "", QUOTE_PATH,
3659+
QUOTE_PATH, pgdata_native, QUOTE_PATH,
3660+
QUOTE_PATH, bin_dir, (strlen(bin_dir) > 0) ? DIR_SEP : "", QUOTE_PATH,
3661+
QUOTE_PATH, pgdata_native, QUOTE_PATH);
3662+
36473663
return 0;
36483664
}

0 commit comments

Comments
 (0)