Re: guc comment changes (was Re: [HACKERS] Getting a move on for 8.2 beta)

2006-09-18 Thread Peter Eisentraut
Am Freitag, 15. September 2006 20:32 schrieb Tom Lane:
 I've finally taken a close look at this patch, and I don't like it any
 more than Peter does.  The refactoring might or might not be good at its
 core, but as presented it is horrid.

Joachim Wieland is in the process of reworking the original feature patch 
(resetting commented out parameters) in a much more compact form.  But it 
turns out that there are a couple of very tricky situations involving custom 
variables, which may need more discussion than we have time for now.

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: guc comment changes (was Re: [HACKERS] Getting a move on for 8.2 beta)

2006-09-18 Thread Joachim Wieland
On Mon, Sep 18, 2006 at 01:13:45PM +0200, Peter Eisentraut wrote:
 Joachim Wieland is in the process of reworking the original feature patch 
 (resetting commented out parameters) in a much more compact form.  But it 
 turns out that there are a couple of very tricky situations involving custom 
 variables, which may need more discussion than we have time for now.

The problem with custom variables is the definition of their default value.
First I defined it to be variable does not exist and tried to have a close
analogy to what happens on set/set local/reset with normal variables.
However that means that custom variables have to vanish (where other
variables show their default value) and revive (where other variables show a
changed value). For example if you have:

begin;
savepoint a;
set foo.var to 3;
(here we delete foo.var from the configuration file and send SIGHUP)
savepoint b;
reset foo.var;

There seem to exist quite a few possible definitions as to what happens if you
run show foo.var after the reset directly or after rolling back to the
savepoints a and b.

The result of the discussion with Peter was that all that seems not worth
doing since it is a rare special case. In the current form of the patch if you
delete a custom variable from the configuration file it gets deleted
internally and all reference to it results in error. There is still one
special case which is:

begin;
set foo.var to 3;
(here we delete foo.var from the configuration file and send SIGHUP)
commit;

This transaction will fail because commit cannot change the value of the
variable to 3 as requested by the user.

I have the patch almost ready in the described form, if there is any chance
it will make it into 8.2 I will clean it up and post it ASAP but Peter wrote
me that chances are close to zero and so I stopped working on it for now.


Joachim

-- 
Joachim Wieland  [EMAIL PROTECTED]
   GPG key available

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: guc comment changes (was Re: [HACKERS] Getting a move on for 8.2 beta)

2006-09-18 Thread Tom Lane
Joachim Wieland [EMAIL PROTECTED] writes:
 I have the patch almost ready in the described form, if there is any chance
 it will make it into 8.2 I will clean it up and post it ASAP but Peter wrote
 me that chances are close to zero and so I stopped working on it for now.

If you'd mentioned it a bit sooner I would have encouraged you to get
it done.  But given your description it sounds a bit too
hairy/potentially-destabilizing to be dropping in the day before beta.
(I certainly hadn't thought about custom vars at all :-()
Let's plan it for 8.3 instead.

regards, tom lane

---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster


guc comment changes (was Re: [HACKERS] Getting a move on for 8.2 beta)

2006-09-15 Thread Tom Lane
Peter Eisentraut [EMAIL PROTECTED] writes:
 That does not mean that the patch is bad, and I certainly support the 
 feature change.  But I can't efficiently review the patch.  If someone 
 else wants to do it, go ahead.

I've finally taken a close look at this patch, and I don't like it any
more than Peter does.  The refactoring might or might not be good at its
core, but as presented it is horrid.  As just one example, it replaces one
reasonably well-commented function with three misnamed, poorly commented
functions.  In place of

  /*
!  * Sets option `name' to given value. The value should be a string
!  * which is going to be parsed and converted to the appropriate data
!  * type.  The context and source parameters indicate in which context this
!  * function is being called so it can apply the access restrictions
!  * properly.
!  *
!  * If value is NULL, set the option to its default value. If the
!  * parameter changeVal is false then don't really set the option but do all
!  * the checks to see if it would work.
!  *
!  * If there is an error (non-existing option, invalid value) then an
!  * ereport(ERROR) is thrown *unless* this is called in a context where we
!  * don't want to ereport (currently, startup or SIGHUP config file reread).
!  * In that case we write a suitable error message via ereport(DEBUG) and
!  * return false. This is working around the deficiencies in the ereport
!  * mechanism, so don't blame me.  In all other cases, the function
!  * returns true, including cases where the input is valid but we chose
!  * not to apply it because of context or source-priority considerations.
!  *
!  * See also SetConfigOption for an external interface.
   */
! bool
! set_config_option(const char *name, const char *value,
! GucContext context, GucSource source,
! bool isLocal, bool changeVal)

we find

  /*
!  * Try to parse value. Determine what is type and call related
!  * parsing function or if newval is equal to NULL, reset value 
!  * to default or bootval. If the value parsed okay return true,
!  * else false.
   */
! static bool
! parse_value(int elevel, const struct config_generic *record, 
!   const char *value, GucSource *source, bool changeVal, 
!   union config_var_value *retval)

which doesn't tell you quite what the parameters do, but more
fundamentally is misnamed because one would expect parse_value
returning bool to merely check whether the value is syntactically
correct.  Well, it doesn't do that: it applies the value too.
Another broken-out routine is

! /*
!  * Check if the option can be set at this time. See guc.h for the precise
!  * rules. 
!  */
! static bool
! checkContext(int elevel, struct config_generic *record, GucContext context)

which is again a misleading description because it doesn't bother to
explain that control may not come back if the option is rejected
(depending on elevel).  One might also think, given that description,
that the caller is supposed to emit an error message on false result.
Lastly we have

+ /*
+  * Verify if option exists and value is valid.
+  * It is primary used for validation of items in configuration file.
+  */
+ bool
+ verify_config_option(const char *name, const char *value,
+   GucContext context, GucSource source,
+   bool *isNewEqual, bool *isContextOK)

which again is far south of my ideas for adequate documentation of a
function with a fairly complicated API.  And guess what, this one has 
side effects too, which it surely should not (and that leads directly
to a bug: GUC_IN_CONFFILE could remain set in a variable after a
parsing failure).

It's possible that a refactoring along these lines could be an
improvement if it were well coded and well documented, but this patch
is not it.

The comment-reversion part of the patch is not any better.  It's poorly
factored (what the heck is guc-file.l doing patching up the source
settings after calling set_config_option?), which is surprising
considering the whole point of the refactoring was to support this.
And the handling of reversion to a PGC_S_ENV_VAR setting is just a kluge
involving duplicated code (what was that about refactoring again?).

In short, whether or not it has any remaining undetected bugs, this
patch is a severe disimprovement from the standpoint of source code
quality, and I recommend rejecting it.

regards, tom lane

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq