]> granicus.if.org Git - postgresql/commitdiff
The problem is that read_pg_options needs DataDir to read its file but
authorBruce Momjian <bruce@momjian.us>
Fri, 16 Oct 1998 06:05:18 +0000 (06:05 +0000)
committerBruce Momjian <bruce@momjian.us>
Fri, 16 Oct 1998 06:05:18 +0000 (06:05 +0000)
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

src/backend/tcop/postgres.c
src/backend/utils/init/globals.c
src/backend/utils/misc/trace.c

index 61e7d431ade5bee0308976c7588a9bfc942d6f1c..17ad10af997f66dec70933a80c46fe57f8f2d382 100644 (file)
@@ -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");
        }
 
        /* ----------------
index 60dabd605dedc9457d157abbede1561d18fe2f87..2c7e3999dcb5df73c6069bdc03cb10245473b77e 100644 (file)
@@ -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
index 8adbb075be1254122e3d245ffe5658e3c38804b4..0f58a122dda96bd5f8fc7ece07a3c2a4887c0e9b 100644 (file)
@@ -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;