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

Commit506ef1d

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 parent32e7e7f commit506ef1d

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
@@ -189,7 +189,6 @@ static const char *backend_options = "--single -F -O -c search_path=pg_catalog -
189189

190190
staticconstchar*subdirs[]= {
191191
"global",
192-
"pg_xlog",
193192
"pg_xlog/archive_status",
194193
"pg_clog",
195194
"pg_commit_ts",
@@ -276,7 +275,7 @@ voidsetup_locale_encoding(void);
276275
voidsetup_signals(void);
277276
voidsetup_text_search(void);
278277
voidcreate_data_directory(void);
279-
voidcreate_xlog_symlink(void);
278+
voidcreate_xlog_or_symlink(void);
280279
voidwarn_on_mount_point(interror);
281280
voidinitialize_data_directory(void);
282281

@@ -3167,13 +3166,17 @@ create_data_directory(void)
31673166
}
31683167

31693168

3169+
/* Create transaction log directory, and symlink if required */
31703170
void
3171-
create_xlog_symlink(void)
3171+
create_xlog_or_symlink(void)
31723172
{
3173-
/* Create transaction log symlink, if required */
3173+
char*subdirloc;
3174+
3175+
/* form name of the place for the subdirectory or symlink */
3176+
subdirloc=psprintf("%s/pg_xlog",pg_data);
3177+
31743178
if (strcmp(xlog_dir,"")!=0)
31753179
{
3176-
char*linkloc;
31773180
intret;
31783181

31793182
/* clean up xlog directory name, check it's absolute */
@@ -3246,22 +3249,30 @@ create_xlog_symlink(void)
32463249
exit_nicely();
32473250
}
32483251

3249-
/* form name of the place where the symlink must go */
3250-
linkloc=psprintf("%s/pg_xlog",pg_data);
3251-
32523252
#ifdefHAVE_SYMLINK
3253-
if (symlink(xlog_dir,linkloc)!=0)
3253+
if (symlink(xlog_dir,subdirloc)!=0)
32543254
{
32553255
fprintf(stderr,_("%s: could not create symbolic link \"%s\": %s\n"),
3256-
progname,linkloc,strerror(errno));
3256+
progname,subdirloc,strerror(errno));
32573257
exit_nicely();
32583258
}
32593259
#else
32603260
fprintf(stderr,_("%s: symlinks are not supported on this platform"));
32613261
exit_nicely();
32623262
#endif
3263-
free(linkloc);
32643263
}
3264+
else
3265+
{
3266+
/* Without -X option, just make the subdirectory normally */
3267+
if (mkdir(subdirloc,S_IRWXU)<0)
3268+
{
3269+
fprintf(stderr,_("%s: could not create directory \"%s\": %s\n"),
3270+
progname,subdirloc,strerror(errno));
3271+
exit_nicely();
3272+
}
3273+
}
3274+
3275+
free(subdirloc);
32653276
}
32663277

32673278

@@ -3292,9 +3303,9 @@ initialize_data_directory(void)
32923303

32933304
create_data_directory();
32943305

3295-
create_xlog_symlink();
3306+
create_xlog_or_symlink();
32963307

3297-
/* Create required subdirectories */
3308+
/* Create required subdirectories(other than pg_xlog)*/
32983309
printf(_("creating subdirectories ... "));
32993310
fflush(stdout);
33003311

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp