Re: reset all update - Mailing list pgsql-patches

From Peter Eisentraut
Subject Re: reset all update
Date
Msg-id Pine.LNX.4.30.0106122128400.756-100000@peter.localdomain
Whole thread Raw
In response to reset all update  (Marko Kreen <marko@l-t.ee>)
Responses Re: reset all update
List pgsql-patches
Marko Kreen writes:

> * GUCify command line arguments.
> * ResetAllOptions() comment
> * split set_config_option()
> * use set_config_option_real() on string reset
>   - it calls hooks and free()'s the previous val
> * check if string val changed on reset

Seems on track.  Comments below.


> Index: src/backend/tcop/postgres.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/tcop/postgres.c,v
> retrieving revision 1.219
> diff -u -c -r1.219 postgres.c
> *** src/backend/tcop/postgres.c    2001/06/07 04:50:57    1.219
> --- src/backend/tcop/postgres.c    2001/06/11 09:17:07
> ***************
> *** 1108,1113 ****
> --- 1108,1115 ----
>       const char *DBName = NULL;
>       bool        secure = true;
>       int            errs = 0;
> +     GucContext    ctx;
> +     char        *tmp;
>
>       int            firstchar;
>       StringInfo    parser_input;
> ***************
> *** 1117,1122 ****
> --- 1119,1126 ----
>
>       char       *potential_DataDir = NULL;
>
> +     ctx = IsUnderPostmaster ? PGC_BACKEND : PGC_POSTMASTER;
> +

This is wrong.  If you're in PostgresMain then the context is PGC_BACKEND
-- by definition.

>       /*
>        * Catch standard options before doing much else.  This even works on
>        * systems without getopt_long.
> ***************

> Index: src/backend/utils/misc/guc.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/utils/misc/guc.c,v
> retrieving revision 1.37
> diff -u -c -r1.37 guc.c
> *** src/backend/utils/misc/guc.c    2001/06/07 04:50:57    1.37
> --- src/backend/utils/misc/guc.c    2001/06/11 09:17:09
> ***************

> --- 437,459 ----
>       for (i = 0; ConfigureNamesString[i].name; i++)
>       {
>           char       *str = NULL;
> +         struct config_string *cf = &ConfigureNamesString[i];
>
> !         if (!cf->default_val && cf->boot_default_val)
>           {
> !             str = strdup(cf->boot_default_val);
>               if (str == NULL)
>                   elog(ERROR, "out of memory");
>
> !             cf->default_val = str;
>           }
> !
> !         if (!cf->variable || !cf->default_val)
> !             continue;

This shouldn't happen.  Just let it crash.

> !
> !         if (!*cf->variable || strcmp(cf->default_val, *cf->variable))

Evil coding style alert.  Suggest:

    if (*cf->variable == NULL || strcmp(cf->default_val, *cf->variable) != 0)

> !             set_config_option_real(PGC_STRING, (struct config_generic *)cf,
> !                     cf->default_val, true, false, ERROR);
>       }
>
>       if (getenv("PGPORT"))
> ***************

--
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter


pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Patch to include PAM support...
Next
From: Tom Lane
Date:
Subject: Re: Patch to include PAM support...