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

Commit51e61b0

Browse files
committed
Ensure pg_ctl behaves sanely when data directory is not specified.
Commitaaa6e1d introduced multiple hazardsin the case where pg_ctl is executed with neither a -D switch nor anyPGDATA environment variable. It would dump core on machines which areunforgiving about printf("%s", NULL), or failing that possibly give arather unhelpful complaint about being unable to execute "postgres -C",rather than the logically prior complaint about not being told where thedata directory is.Edmund Horner's report suggests that there is another, Windows-specifichazard here, but I'm not the person to fix that; it would in any case onlybe significant when trying to use a config-only PGDATA pointer.
1 parentbf0945e commit51e61b0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

‎src/bin/pg_ctl/pg_ctl.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,6 +1902,10 @@ adjust_data_dir(void)
19021902
*my_exec_path;
19031903
FILE*fd;
19041904

1905+
/* do nothing if we're working without knowledge of data dir */
1906+
if (pg_config==NULL)
1907+
return;
1908+
19051909
/* If there is no postgresql.conf, it can't be a config-only dir */
19061910
snprintf(filename,sizeof(filename),"%s/postgresql.conf",pg_config);
19071911
if ((fd=fopen(filename,"r"))==NULL)
@@ -2188,8 +2192,10 @@ main(int argc, char **argv)
21882192
pg_data=xstrdup(pg_config);
21892193
}
21902194

2195+
/* -D might point at config-only directory; if so find the real PGDATA */
21912196
adjust_data_dir();
21922197

2198+
/* Complain if -D needed and not provided */
21932199
if (pg_config==NULL&&
21942200
ctl_command!=KILL_COMMAND&&ctl_command!=UNREGISTER_COMMAND)
21952201
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp