Re: [HACKERS] Odd problem with read_pg_options ...

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: dz(at)cs(dot)unitn(dot)it (Massimo Dal Zotto)
Cc: hackers(at)postgreSQL(dot)org, scrappy(at)hub(dot)org
Subject: Re: [HACKERS] Odd problem with read_pg_options ...
Date: 1998-10-16 06:05:28
Message-ID: 199810160605.CAA00813@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> 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?

I have applied it. You can improve it later, if you wish.

>
> *** src/backend/utils/init/globals.c.orig Thu Oct 15 00:13:03 1998
> --- src/backend/utils/init/globals.c Thu Oct 15 00:13:07 1998
> ***************
> *** 46,52 ****
> struct Port *MyProcPort;
> long MyCancelKey;
>
> ! char *DataDir;
>
> /*
> * The PGDATA directory user says to use, or defaults to via environment
> --- 46,52 ----
> struct Port *MyProcPort;
> long MyCancelKey;
>
> ! char *DataDir = NULL;
>
> /*
> * The PGDATA directory user says to use, or defaults to via environment
> *** src/backend/utils/misc/trace.c.orig Thu Sep 3 09:00:39 1998
> --- src/backend/utils/misc/trace.c Thu Oct 15 00:18:49 1998
> ***************
> *** 343,348 ****
> --- 343,353 ----
> 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;
> *** src/backend/tcop/postgres.c.orig Tue Sep 1 09:01:27 1998
> --- src/backend/tcop/postgres.c Thu Oct 15 00:23:24 1998
> ***************
> *** 1049,1055 ****
> --- 1049,1061 ----
> break;
>
> case 'D': /* PGDATA directory */
> + if (!DataDir) {
> + DataDir = optarg;
> + /* must be done after DataDir is defined */
> + read_pg_options(0);
> + }
> DataDir = optarg;
> + break;
>
> case 'd': /* debug level */
> flagQ = false;
>
> --
> Massimo Dal Zotto
>
> +----------------------------------------------------------------------+
> | Massimo Dal Zotto email: dz(at)cs(dot)unitn(dot)it |
> | Via Marconi, 141 phone: ++39-461-534251 |
> | 38057 Pergine Valsugana (TN) www: http://www.cs.unitn.it/~dz/ |
> | Italy pgp: finger dz(at)tango(dot)cs(dot)unitn(dot)it |
> +----------------------------------------------------------------------+
>
>

--
Bruce Momjian | http://www.op.net/~candle
maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas G. Lockhart 1998-10-16 06:10:54 Re: [HACKERS] Re: [SQL] Optimizing perfomance using indexes
Previous Message Bruce Momjian 1998-10-16 05:34:33 Re: [HACKERS] What about LIMIT in SELECT ?