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

Commit26374f2

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 parent630cd14 commit26374f2

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
voidsetup_bin_paths(constchar*argv0);
256256
voidsetup_data_file_paths(void);
257257
voidsetup_locale_encoding(void);
258-
voidsetup_signals_and_umask(void);
258+
voidsetup_signals(void);
259259
voidsetup_text_search(void);
260-
voidprocess(constchar*argv0);
260+
voidcreate_data_directory(void);
261+
voidcreate_xlog_symlink(void);
262+
voidinitialize_data_directory(void);
261263

262264

263265
#ifdefWIN32
@@ -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
#ifdefSIGHUP
@@ -3184,19 +3186,12 @@ setup_signals_and_umask(void)
31843186
#ifdefSIGPIPE
31853187
pqsignal(SIGPIPE,SIG_IGN);
31863188
#endif
3187-
3188-
umask(S_IRWXG |S_IRWXO);
31893189
}
31903190

31913191

31923192
void
3193-
process(constchar*argv0)
3193+
create_data_directory(void)
31943194
{
3195-
inti;
3196-
charbin_dir[MAXPGPATH];
3197-
3198-
setup_signals_and_umask();
3199-
32003195
switch (pg_check_dir(pg_data))
32013196
{
32023197
case0:
@@ -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+
inti;
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
intc;
34603462
intoption_index;
34613463
char*effective_user;
3464+
charbin_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
return0;
36483664
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp