Re: I am done

From: Gavin Sherry <swm(at)linuxworld(dot)com(dot)au>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: I am done
Date: 2002-09-05 06:31:14
Message-ID: Pine.LNX.4.21.0209051607380.7348-100000@linuxworld.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 4 Sep 2002, Tom Lane wrote:

> Gavin Sherry <swm(at)linuxworld(dot)com(dot)au> writes:
> > Does anyone else have an opinion on this? If not, I will implement it per
> > Bruce's commentary.
>
> > On Mon, 2 Sep 2002, Bruce Momjian wrote:
> >> I think the second, passing an arg to say whether it is server or
> >> client, will do the trick, though now you need an error one too. I
> >> guess you have to use #define and set it, or pass a string down with the
> >> GUC variable and test that with strcmp.
>
> I think you're going to end up un-merging the routines. There is no way
> to pass an extra parameter to the set/check routines (at least not

There is a wrapper around the generic function:

const char *
assign_min_error_statement(const char *newval, bool doit, bool
interactive)
{
return(assign_msglvl(&log_min_error_statement,newval,doit,interactive));
}

I would simply define some macros:

#define MSGLVL_MIN_ERR_STMT (1<<0)
#define MSGLVL_MIN_CLI_MSGS (1<<1)
#define MSGLVL_MIN_SVR_MSGS (1<<2)

And assign_msglvl(), having been passed the variable 'caller', determined
by the calling function, will do something like this:

/* everyone has likes debug */
if (strcasecmp(newval, "debug") == 0 &&
caller & (MSGLVL_MIN_ERR_STMT | MSGLVL_MIN_CLI_MSGS | MSGLVL_MIN_SVR_MSGS))
{ if (doit) (*var) = DEBUG1; }

/* ... */

else if (strcasecmp(newval, "fatal") == 0 &&
caller & (MSGLVL_MIN_ERR_STMT | MSGLVL_MIN_SVR_MSGS))
{ if (doit) (*var) = FATAL; }
else if (strcasecmp(newval, "off") == 0 &&
caller & MSGLVL_MIN_ERR_STMT)
{ if (doit) (*var) = MIN_ERR_STMT_OFF; }

Personally, I've never liked coding like this. The reason I merged the
base code for each function was so that the GUC code didn't get uglier as
more minimum-level-of-logging parameters were added. But with the code
above, the bitwise operations and appearance of the
assign_msglvl() routine will suffer the same fate, I'm afraid.

Since the flawed code is now in beta, it will need to be fixed. Do people
like the above solution or should I just revert to having a seperate
function for each GUC variable affected?

Gavin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Kings-Lynne 2002-09-05 06:35:48 contrib/tsearch
Previous Message Christopher Kings-Lynne 2002-09-05 06:18:13 Re: Beta1 schedule