From abfb41757405b74e175fb8e6bf632b270de523dc Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sat, 4 Nov 2000 12:43:24 +0000 Subject: Make the backend grok relative paths for the data directory by converting it to an absolute path. --- src/backend/tcop/postgres.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'src/backend/tcop/postgres.c') diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index b024d604dc8..29192686e6c 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.184 2000/10/28 18:27:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.185 2000/11/04 12:43:24 petere Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -29,7 +29,7 @@ #include #if HAVE_SYS_SELECT_H #include -#endif /* aix */ +#endif #include #include #include @@ -1058,6 +1058,8 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha char *remote_host; unsigned short remote_port; + char *potential_DataDir = NULL; + extern int optind; extern char *optarg; extern int DebugLvl; @@ -1082,8 +1084,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha if (!IsUnderPostmaster) { ResetAllOptions(); - if (getenv("PGDATA")) - DataDir = strdup(getenv("PGDATA")); + potential_DataDir = getenv("PGDATA"); } StatFp = stderr; @@ -1142,9 +1143,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha case 'D': /* PGDATA directory */ if (secure) { - if (DataDir) - free(DataDir); - DataDir = strdup(optarg); + potential_DataDir = optarg; } break; @@ -1429,15 +1428,20 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha Show_query_stats = false; } - if (!DataDir) + if (!IsUnderPostmaster) { - fprintf(stderr, "%s does not know where to find the database system " - "data. You must specify the directory that contains the " - "database system either by specifying the -D invocation " - "option or by setting the PGDATA environment variable.\n\n", - argv[0]); - proc_exit(1); + if (!potential_DataDir) + { + fprintf(stderr, "%s does not know where to find the database system " + "data. You must specify the directory that contains the " + "database system either by specifying the -D invocation " + "option or by setting the PGDATA environment variable.\n\n", + argv[0]); + proc_exit(1); + } + SetDataDir(potential_DataDir); } + Assert(DataDir); /* * 1. Set BlockSig and UnBlockSig masks. 2. Set up signal handlers. 3. @@ -1631,7 +1635,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha if (!IsUnderPostmaster) { puts("\nPOSTGRES backend interactive interface "); - puts("$Revision: 1.184 $ $Date: 2000/10/28 18:27:56 $\n"); + puts("$Revision: 1.185 $ $Date: 2000/11/04 12:43:24 $\n"); } /* -- cgit v1.2.3