Fix that deals with unusable custom variables. - Mailing list pgsql-patches

From Thomas Hallgren
Subject Fix that deals with unusable custom variables.
Date
Msg-id 4237246E.7030305@mailblocks.com
Whole thread Raw
Responses Re: Fix that deals with unusable custom variables.  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
This is a bit embarrassing but the patch I submitted that enables custom
variable classes (8-10 months ago) was somewhat incomplete. The
DefineCustomIntVariable and DefineCustomRealVariable functions doesn't
have parameters that make it possible to set the min and max values of
the variables. Consequently, custom variables of int and real type are
completely useless. This patch adds the additional parameters minValue
and maxValue to those functions.

No one but me have used this so far (or someone would have noticed) so I
think it would be safe to backport this for 8.0.2.

Regards,
Thomas Hallgren

Index: src/backend/utils/misc/guc.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/misc/guc.c,v
retrieving revision 1.255
diff -u -r1.255 guc.c
--- src/backend/utils/misc/guc.c    13 Mar 2005 09:36:31 -0000    1.255
+++ src/backend/utils/misc/guc.c    15 Mar 2005 16:12:05 -0000
@@ -4176,6 +4176,8 @@
                         const char *short_desc,
                         const char *long_desc,
                         int *valueAddr,
+                        int minValue,
+                        int maxValue,
                         GucContext context,
                         GucIntAssignHook assign_hook,
                         GucShowHook show_hook)
@@ -4188,6 +4190,8 @@

     var->variable = valueAddr;
     var->reset_val = *valueAddr;
+    var->min = minValue;
+    var->max = maxValue;
     var->assign_hook = assign_hook;
     var->show_hook = show_hook;
     define_custom_variable(&var->gen);
@@ -4199,6 +4203,8 @@
                          const char *short_desc,
                          const char *long_desc,
                          double *valueAddr,
+                         double minValue,
+                         double maxValue,
                          GucContext context,
                          GucRealAssignHook assign_hook,
                          GucShowHook show_hook)
@@ -4211,6 +4217,8 @@

     var->variable = valueAddr;
     var->reset_val = *valueAddr;
+    var->min = minValue;
+    var->max = maxValue;
     var->assign_hook = assign_hook;
     var->show_hook = show_hook;
     define_custom_variable(&var->gen);
Index: src/include/utils/guc.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/utils/guc.h,v
retrieving revision 1.58
diff -u -r1.58 guc.h
--- src/include/utils/guc.h    1 Jan 2005 05:43:09 -0000    1.58
+++ src/include/utils/guc.h    15 Mar 2005 16:12:06 -0000
@@ -149,6 +149,8 @@
                         const char *short_desc,
                         const char *long_desc,
                         int *valueAddr,
+                        int minValue,
+                        int maxValue,
                         GucContext context,
                         GucIntAssignHook assign_hook,
                         GucShowHook show_hook);
@@ -158,6 +160,8 @@
                          const char *short_desc,
                          const char *long_desc,
                          double *valueAddr,
+                         double minValue,
+                         double maxValue,
                          GucContext context,
                          GucRealAssignHook assign_hook,
                          GucShowHook show_hook);

pgsql-patches by date:

Previous
From: "Magnus Hagander"
Date:
Subject: Kerberos code overwrites it's own error message
Next
From: "Magnus Hagander"
Date:
Subject: Kerberos on win32