Re: [HACKERS] [PATCHES] [BUGS] BUG #2846: inconsistent and

2006-12-30 Thread Bruce Momjian
Tom Lane wrote:
> Bruce Momjian <[EMAIL PROTECTED]> writes:
> > OK, are you saying that there is a signal we are ignoring for
> > overflow/underflow, or that we should just silently overflow/underflow
> > and not throw an error?
> 
> Silent underflow is fine with me; it's the norm in most all float
> implementations and won't surprise anyone.  For overflow I'm OK with
> either returning infinity or throwing an error --- but if an error,
> it should only be about inf-out-with-non-inf-in, not comparisons to any
> artificial MAX/MIN values.

OK, I am happy to remove the MIN/MAX comparisons.  Those were in the
original code.

The attached, updated patch creates a single CHECKFLOATVAL() macro that
does the overflow/underflow comparisons and throws an error.  This also
reduces the isinf() calls.  Should I be concerned we are now duplicating
the error text in all call sites?

Regression wording modified now that float4/float8 checks are merged.  I
haven't update the platform-specific float* expected files yet, but will
on commit.

-- 
  Bruce Momjian   [EMAIL PROTECTED]
  EnterpriseDBhttp://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: src/backend/utils/adt/float.c
===
RCS file: /cvsroot/pgsql/src/backend/utils/adt/float.c,v
retrieving revision 1.131
diff -c -c -r1.131 float.c
*** src/backend/utils/adt/float.c	23 Dec 2006 02:13:24 -	1.131
--- src/backend/utils/adt/float.c	30 Dec 2006 18:19:57 -
***
*** 12,59 
   *
   *-
   */
- /*--
-  * OLD COMMENTS
-  *		Basic float4 ops:
-  *		 float4in, float4out, float4recv, float4send
-  *		 float4abs, float4um, float4up
-  *		Basic float8 ops:
-  *		 float8in, float8out, float8recv, float8send
-  *		 float8abs, float8um, float8up
-  *		Arithmetic operators:
-  *		 float4pl, float4mi, float4mul, float4div
-  *		 float8pl, float8mi, float8mul, float8div
-  *		Comparison operators:
-  *		 float4eq, float4ne, float4lt, float4le, float4gt, float4ge, float4cmp
-  *		 float8eq, float8ne, float8lt, float8le, float8gt, float8ge, float8cmp
-  *		Conversion routines:
-  *		 ftod, dtof, i4tod, dtoi4, i2tod, dtoi2, itof, ftoi, i2tof, ftoi2
-  *
-  *		Random float8 ops:
-  *		 dround, dtrunc, dsqrt, dcbrt, dpow, dexp, dlog1
-  *		Arithmetic operators:
-  *		 float48pl, float48mi, float48mul, float48div
-  *		 float84pl, float84mi, float84mul, float84div
-  *		Comparison operators:
-  *		 float48eq, float48ne, float48lt, float48le, float48gt, float48ge
-  *		 float84eq, float84ne, float84lt, float84le, float84gt, float84ge
-  *
-  *		(You can do the arithmetic and comparison stuff using conversion
-  *		 routines, but then you pay the overhead of invoking a separate
-  *		 conversion function...)
-  *
-  * XXX GLUESOME STUFF. FIX IT! -AY '94
-  *
-  *		Added some additional conversion routines and cleaned up
-  *		 a bit of the existing code. Need to change the error checking
-  *		 for calls to pow(), exp() since on some machines (my Linux box
-  *		 included) these routines do not set errno. - tgl 97/05/10
-  *--
-  */
  #include "postgres.h"
  
  #include 
- #include 
  #include 
  #include 
  /* for finite() on Solaris */
--- 12,20 
***
*** 91,111 
  #define MAXFLOATWIDTH	64
  #define MAXDOUBLEWIDTH	128
  
! /* == USER I/O ROUTINES == */
  
  
! #define FLOAT4_MAX		 FLT_MAX
! #define FLOAT4_MIN		 FLT_MIN
! #define FLOAT8_MAX		 DBL_MAX
! #define FLOAT8_MIN		 DBL_MIN
  
  
  /* Configurable GUC parameter */
  int			extra_float_digits = 0;		/* Added to DBL_DIG or FLT_DIG */
  
  
- static void CheckFloat4Val(double val);
- static void CheckFloat8Val(double val);
  static int	float4_cmp_internal(float4 a, float4 b);
  static int	float8_cmp_internal(float8 a, float8 b);
  
--- 52,81 
  #define MAXFLOATWIDTH	64
  #define MAXDOUBLEWIDTH	128
  
! /*
!  * check to see if a float4/8 val has underflowed or overflowed
!  */
! #define CHECKFLOATVAL(val, inf_is_valid, zero_is_valid)			\
! do {			\
! 	if (isinf(val) && !(inf_is_valid))			\
! 		ereport(ERROR,			\
! (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),	\
! 		  errmsg("value out of range: overflow")));\
! \
! 	if ((val) == 0.0 && !(zero_is_valid))		\
! 		ereport(ERROR,			\
! (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),	\
! 		 errmsg("value out of range: underflow")));\
! } while(0)
  
  
! /* == USER I/O ROUTINES == */
  
  
  /* Configurable GUC parameter */
  int			extra_float_digits = 0;		/* Added to DBL_DIG or FLT_DIG */
  
  
  static int	float4_cmp_internal(float4 a, float4 b);
  static int	float8_cmp_internal(float8 a, float8 b);
  
***
*** 205,248 
  
  
  /*
-  * check to see if a float4 val is outside of the FLOAT4_MIN,
-  * FLOAT4_MAX bounds.
-  *
-  * raise an ereport() 

Re: [HACKERS] [PATCHES] Bundle of patches

2006-12-30 Thread Tom Lane
Teodor Sigaev <[EMAIL PROTECTED]> writes:
> Just a freshing for clean applying..
> http://www.sigaev.ru/misc/user_defined_typmod-0.11.gz

Applied with some revisions, and pg_dump support and regression tests
added.

regards, tom lane

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

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


Re: [PATCHES] [HACKERS] Recent SIGSEGV failures in buildfarm HEAD

2006-12-30 Thread Andrew Dunstan
Stefan Kaltenbrunner wrote:
> Tom Lane wrote:
>> Andrew Dunstan <[EMAIL PROTECTED]> writes:
>>> ... And then we'd need to change the regression makefile to use
>>> the option, based on an environment variable a bit like
>>> MAX_CONNEXCTIONS
>>> maybe.
>>
>> Why wouldn't we just use it always?  If a regression test dumps core,
>> that's going to deserve investigation.
>
> enabling it always for the regression tests probably makes sense - but
> there is also the possibility that such a core can get very large and
> potentially run the partitition the regression test runs on out of space.
>
>

I think Tom is right. You can always set the hard limit before calling
"make check" or running the buildfarm script. I'll prepare a patch to use
similar code unconditionally in pg_regress.

cheers

andrew



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