float-fix.diff

text/plain

Filename: float-fix.diff
Type: text/plain
Part: 0
Message: Re: Re: [GENERAL] +/- Inf for float8's

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: context
File+
backend/access/nbtree/nbtcompare.c.orig 1 3
backend/utils/adt/float.c 15 3
*** backend/utils/adt/float.c.orig	Sun Aug 13 21:28:03 2000
--- backend/utils/adt/float.c	Sun Aug 20 11:49:27 2000
***************
*** 248,253 ****
--- 248,255 ----
  			val = NAN;
  		else if (strcasecmp(num, "Infinity") == 0)
  			val = HUGE_VAL;
+ 		else if (strcasecmp(num, "-Infinity") == 0)
+ 			val = -HUGE_VAL;
  		else
  			elog(ERROR, "Bad float8 input format '%s'", num);
  	}
***************
*** 275,283 ****
  
  	if (isnan(num))
  		PG_RETURN_CSTRING(strcpy(ascii, "NaN"));
! 	if (isinf(num))
! 		PG_RETURN_CSTRING(strcpy(ascii, "Infinity"));
! 
  	sprintf(ascii, "%.*g", DBL_DIG, num);
  	PG_RETURN_CSTRING(ascii);
  }
--- 277,293 ----
  
  	if (isnan(num))
  		PG_RETURN_CSTRING(strcpy(ascii, "NaN"));
! 	switch (isinf(num))
! 	{
! 		case -1:
! 			PG_RETURN_CSTRING(strcpy(ascii, "-Infinity"));
! 			break;
! 		case 1:
! 			PG_RETURN_CSTRING(strcpy(ascii, "Infinity"));
! 			break;
! 		default:
! 			break;
! 	}
  	sprintf(ascii, "%.*g", DBL_DIG, num);
  	PG_RETURN_CSTRING(ascii);
  }
***************
*** 614,619 ****
--- 624,630 ----
  	float8		arg1 = PG_GETARG_FLOAT8(0);
  	float8		arg2 = PG_GETARG_FLOAT8(1);
  
+ 	if (isnan(arg2)) PG_RETURN_BOOL(1); 
  	PG_RETURN_BOOL(arg1 < arg2);
  }
  
***************
*** 632,637 ****
--- 643,649 ----
  	float8		arg1 = PG_GETARG_FLOAT8(0);
  	float8		arg2 = PG_GETARG_FLOAT8(1);
  
+ 	if (isnan(arg2)) PG_RETURN_BOOL(1); 
  	PG_RETURN_BOOL(arg1 > arg2);
  }
  
*** backend/access/nbtree/nbtcompare.c	Sun Aug 20 09:47:12 2000
--- backend/access/nbtree/nbtcompare.c.orig	Fri Jul 14 11:15:59 2000
***************
*** 105,113 ****
  	float8		a = PG_GETARG_FLOAT8(0);
  	float8		b = PG_GETARG_FLOAT8(1);
  
! 	if (isnan(a))
! 		PG_RETURN_INT32(1);
! 	else if (a > b)
  		PG_RETURN_INT32(1);
  	else if (a == b)
  		PG_RETURN_INT32(0);
--- 105,111 ----
  	float8		a = PG_GETARG_FLOAT8(0);
  	float8		b = PG_GETARG_FLOAT8(1);
  
! 	if (a > b)
  		PG_RETURN_INT32(1);
  	else if (a == b)
  		PG_RETURN_INT32(0);