On Wed, 4 Sep 2002, Tom Lane wrote: > Gavin Sherry <[EMAIL PROTECTED]> 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 ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])