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

Commitb41fb65

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 parentfa838b5 commitb41fb65

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

‎src/bin/initdb/initdb.c

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ static const char *backend_options = "--single -F -O -j -c search_path=pg_catalo
193193

194194
staticconstchar*constsubdirs[]= {
195195
"global",
196-
"pg_xlog",
197196
"pg_xlog/archive_status",
198197
"pg_clog",
199198
"pg_commit_ts",
@@ -280,7 +279,7 @@ voidsetup_locale_encoding(void);
280279
voidsetup_signals(void);
281280
voidsetup_text_search(void);
282281
voidcreate_data_directory(void);
283-
voidcreate_xlog_symlink(void);
282+
voidcreate_xlog_or_symlink(void);
284283
voidwarn_on_mount_point(interror);
285284
voidinitialize_data_directory(void);
286285

@@ -2948,13 +2947,17 @@ create_data_directory(void)
29482947
}
29492948

29502949

2950+
/* Create transaction log directory, and symlink if required */
29512951
void
2952-
create_xlog_symlink(void)
2952+
create_xlog_or_symlink(void)
29532953
{
2954-
/* Create transaction log symlink, if required */
2954+
char*subdirloc;
2955+
2956+
/* form name of the place for the subdirectory or symlink */
2957+
subdirloc=psprintf("%s/pg_xlog",pg_data);
2958+
29552959
if (strcmp(xlog_dir,"")!=0)
29562960
{
2957-
char*linkloc;
29582961
intret;
29592962

29602963
/* clean up xlog directory name, check it's absolute */
@@ -3027,22 +3030,30 @@ create_xlog_symlink(void)
30273030
exit_nicely();
30283031
}
30293032

3030-
/* form name of the place where the symlink must go */
3031-
linkloc=psprintf("%s/pg_xlog",pg_data);
3032-
30333033
#ifdefHAVE_SYMLINK
3034-
if (symlink(xlog_dir,linkloc)!=0)
3034+
if (symlink(xlog_dir,subdirloc)!=0)
30353035
{
30363036
fprintf(stderr,_("%s: could not create symbolic link \"%s\": %s\n"),
3037-
progname,linkloc,strerror(errno));
3037+
progname,subdirloc,strerror(errno));
30383038
exit_nicely();
30393039
}
30403040
#else
30413041
fprintf(stderr,_("%s: symlinks are not supported on this platform"));
30423042
exit_nicely();
30433043
#endif
3044-
free(linkloc);
30453044
}
3045+
else
3046+
{
3047+
/* Without -X option, just make the subdirectory normally */
3048+
if (mkdir(subdirloc,S_IRWXU)<0)
3049+
{
3050+
fprintf(stderr,_("%s: could not create directory \"%s\": %s\n"),
3051+
progname,subdirloc,strerror(errno));
3052+
exit_nicely();
3053+
}
3054+
}
3055+
3056+
free(subdirloc);
30463057
}
30473058

30483059

@@ -3074,9 +3085,9 @@ initialize_data_directory(void)
30743085

30753086
create_data_directory();
30763087

3077-
create_xlog_symlink();
3088+
create_xlog_or_symlink();
30783089

3079-
/* Create required subdirectories */
3090+
/* Create required subdirectories(other than pg_xlog)*/
30803091
printf(_("creating subdirectories ... "));
30813092
fflush(stdout);
30823093

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp