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
pull/50/head
Bruce Momjian 28 years ago
parent 9f69aa0831
commit 8fa2742ddf
  1. 9
      src/backend/tcop/postgres.c
  2. 4
      src/backend/utils/init/globals.c
  3. 5
      src/backend/utils/misc/trace.c

@ -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;

Loading…
Cancel
Save