aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/init/miscinit.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2014-04-04 18:42:13 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2014-04-04 18:42:13 -0400
commit9aca51250681d2e8d18ed1d73e7cd1283d1cf303 (patch)
treeb1b9e945db659fd59bbdf8aacf3f21aad18f5b15 /src/backend/utils/init/miscinit.c
parent8120c7452a51a773ad7a249b55557439f39d41ef (diff)
downloadpostgresql-9aca51250681d2e8d18ed1d73e7cd1283d1cf303.tar.gz
postgresql-9aca51250681d2e8d18ed1d73e7cd1283d1cf303.zip
Make sure -D is an absolute path when starting server on Windows.
This is needed because Windows services may get started with a different current directory than where pg_ctl is executed. We want relative -D paths to be interpreted relative to pg_ctl's CWD, similarly to what happens on other platforms. In support of this, move the backend's make_absolute_path() function into src/port/path.c (where it probably should have been long since) and get rid of the rather inferior version in pg_regress. Kumar Rajeev Rastogi, reviewed by MauMau
Diffstat (limited to 'src/backend/utils/init/miscinit.c')
-rw-r--r--src/backend/utils/init/miscinit.c71
1 files changed, 0 insertions, 71 deletions
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
index c17bca83061..6115ce3f337 100644
--- a/src/backend/utils/init/miscinit.c
+++ b/src/backend/utils/init/miscinit.c
@@ -117,77 +117,6 @@ ChangeToDataDir(void)
DataDir)));
}
-/*
- * If the given pathname isn't already absolute, make it so, interpreting
- * it relative to the current working directory.
- *
- * Also canonicalizes the path. The result is always a malloc'd copy.
- *
- * Note: interpretation of relative-path arguments during postmaster startup
- * should happen before doing ChangeToDataDir(), else the user will probably
- * not like the results.
- */
-char *
-make_absolute_path(const char *path)
-{
- char *new;
-
- /* Returning null for null input is convenient for some callers */
- if (path == NULL)
- return NULL;
-
- if (!is_absolute_path(path))
- {
- char *buf;
- size_t buflen;
-
- buflen = MAXPGPATH;
- for (;;)
- {
- buf = malloc(buflen);
- if (!buf)
- ereport(FATAL,
- (errcode(ERRCODE_OUT_OF_MEMORY),
- errmsg("out of memory")));
-
- if (getcwd(buf, buflen))
- break;
- else if (errno == ERANGE)
- {
- free(buf);
- buflen *= 2;
- continue;
- }
- else
- {
- free(buf);
- elog(FATAL, "could not get current working directory: %m");
- }
- }
-
- new = malloc(strlen(buf) + strlen(path) + 2);
- if (!new)
- ereport(FATAL,
- (errcode(ERRCODE_OUT_OF_MEMORY),
- errmsg("out of memory")));
- sprintf(new, "%s/%s", buf, path);
- free(buf);
- }
- else
- {
- new = strdup(path);
- if (!new)
- ereport(FATAL,
- (errcode(ERRCODE_OUT_OF_MEMORY),
- errmsg("out of memory")));
- }
-
- /* Make sure punctuation is canonical, too */
- canonicalize_path(new);
-
- return new;
-}
-
/* ----------------------------------------------------------------
* User ID state