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

Commit452064f

Browse files
committed
Fix unobvious interaction between -X switch and subdirectory creation.
Turns out the only reason initdb -X worked is that pg_mkdir_p won'twhine if you point it at something that's a symlink to a directory.Otherwise, the attempt to create pg_xlog/ just like all the othersubdirectories would have failed. Let's be a little more explicitabout what's happening. Oversight in my patch for bug #13853(mea culpa for not testing -X ...)
1 parent9486d02 commit452064f

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

‎src/bin/initdb/initdb.c

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ char *restrict_env;
188188
#endif
189189
constchar*subdirs[]= {
190190
"global",
191-
"pg_xlog",
192191
"pg_xlog/archive_status",
193192
"pg_clog",
194193
"pg_notify",
@@ -270,7 +269,7 @@ voidsetup_locale_encoding(void);
270269
voidsetup_signals(void);
271270
voidsetup_text_search(void);
272271
voidcreate_data_directory(void);
273-
voidcreate_xlog_symlink(void);
272+
voidcreate_xlog_or_symlink(void);
274273
voidwarn_on_mount_point(interror);
275274
voidinitialize_data_directory(void);
276275

@@ -3250,13 +3249,18 @@ create_data_directory(void)
32503249
}
32513250

32523251

3252+
/* Create transaction log directory, and symlink if required */
32533253
void
3254-
create_xlog_symlink(void)
3254+
create_xlog_or_symlink(void)
32553255
{
3256-
/* Create transaction log symlink, if required */
3256+
char*subdirloc;
3257+
3258+
/* form name of the place for the subdirectory or symlink */
3259+
subdirloc= (char*)pg_malloc(strlen(pg_data)+8+1);
3260+
sprintf(subdirloc,"%s/pg_xlog",pg_data);
3261+
32573262
if (strcmp(xlog_dir,"")!=0)
32583263
{
3259-
char*linkloc;
32603264
intret;
32613265

32623266
/* clean up xlog directory name, check it's absolute */
@@ -3329,22 +3333,30 @@ create_xlog_symlink(void)
33293333
exit_nicely();
33303334
}
33313335

3332-
/* form name of the place where the symlink must go */
3333-
linkloc= (char*)pg_malloc(strlen(pg_data)+8+1);
3334-
sprintf(linkloc,"%s/pg_xlog",pg_data);
3335-
33363336
#ifdefHAVE_SYMLINK
3337-
if (symlink(xlog_dir,linkloc)!=0)
3337+
if (symlink(xlog_dir,subdirloc)!=0)
33383338
{
33393339
fprintf(stderr,_("%s: could not create symbolic link \"%s\": %s\n"),
3340-
progname,linkloc,strerror(errno));
3340+
progname,subdirloc,strerror(errno));
33413341
exit_nicely();
33423342
}
33433343
#else
33443344
fprintf(stderr,_("%s: symlinks are not supported on this platform"));
33453345
exit_nicely();
33463346
#endif
33473347
}
3348+
else
3349+
{
3350+
/* Without -X option, just make the subdirectory normally */
3351+
if (mkdir(subdirloc,S_IRWXU)<0)
3352+
{
3353+
fprintf(stderr,_("%s: could not create directory \"%s\": %s\n"),
3354+
progname,subdirloc,strerror(errno));
3355+
exit_nicely();
3356+
}
3357+
}
3358+
3359+
free(subdirloc);
33483360
}
33493361

33503362

@@ -3375,9 +3387,9 @@ initialize_data_directory(void)
33753387

33763388
create_data_directory();
33773389

3378-
create_xlog_symlink();
3390+
create_xlog_or_symlink();
33793391

3380-
/* Create required subdirectories */
3392+
/* Create required subdirectories(other than pg_xlog)*/
33813393
printf(_("creating subdirectories ... "));
33823394
fflush(stdout);
33833395

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp