Re: [PATCHES] Fix that deals with unusable custom variables.

2005-03-25 Thread Tom Lane
Thomas Hallgren <[EMAIL PROTECTED]> writes:
> 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.

Applied to HEAD and 8.0.

regards, tom lane

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


[PATCHES] Fix that deals with unusable custom variables.

2005-03-15 Thread Thomas Hallgren
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.c13 Mar 2005 09:36:31 -  1.255
+++ src/backend/utils/misc/guc.c15 Mar 2005 16:12:05 -
@@ -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 -   1.58
+++ src/include/utils/guc.h 15 Mar 2005 16:12:06 -
@@ -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);

---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match