Commit 8fa2742d authored by Bruce Momjian's avatar Bruce Momjian

The problem is that read_pg_options needs DataDir to read its file but

DataDir is set after read_pg_options if postgres is called
interactively.  If postgres is forked by postgres DataDir is read from
the PGDATA enviromnent variable set by the postmaster and this explains
while the bug disappears.  I have written this patch but I don't like
it. Any better idea?

Massimo Dal Zotto
parent 9f69aa08
......@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.93 1998/10/13 20:05:44 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.94 1998/10/16 06:05:13 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
......@@ -1053,6 +1053,11 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
break;
case 'D': /* PGDATA directory */
if (!DataDir) {
DataDir = optarg;
/* must be done after DataDir is defined */
read_pg_options(0);
}
DataDir = optarg;
break;
......@@ -1514,7 +1519,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
puts("$Revision: 1.93 $ $Date: 1998/10/13 20:05:44 $\n");
puts("$Revision: 1.94 $ $Date: 1998/10/16 06:05:13 $\n");
}
/* ----------------
......
......@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.25 1998/08/25 21:24:10 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.26 1998/10/16 06:05:16 momjian Exp $
*
* NOTES
* Globals used all over the place should be declared here and not
......@@ -46,7 +46,7 @@ int MyProcPid;
struct Port *MyProcPort;
long MyCancelKey;
char *DataDir;
char *DataDir = NULL;
/*
* The PGDATA directory user says to use, or defaults to via environment
......
......@@ -339,6 +339,11 @@ read_pg_options(SIGNAL_ARGS)
char *s,
*p;
if (!DataDir) {
fprintf(stderr, "read_pg_options: DataDir not defined\n");
return;
}
sprintf(buffer, "%s/%s", DataDir, "pg_options");
if ((fd = open(buffer, O_RDONLY)) < 0)
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment