Boszormenyi Zoltan írta:
> Hi,
>
> buildfarm member "pika" fails the NaN test.
> Does FreeBSD/MIPS really return true for isinf(NaN)?
> Anyway, the attached patch tries to fix the test case
> by testing isnan() first and doesn't check isinf()
> if isnan() returned true.
>   

I lied in the patch name, it wasn't a context diff.
Also, the same remedy seems to be needed in ecpglib/execute.c, too.

Best regards,
Zoltán Böszörményi

-- 
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/execute.c pgsql/src/interfaces/ecpg/ecpglib/execute.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/execute.c	2010-02-04 11:10:03.000000000 +0100
--- pgsql/src/interfaces/ecpg/ecpglib/execute.c	2010-02-16 12:19:38.000000000 +0100
*************** ecpg_store_result(const PGresult *result
*** 468,482 ****
  static void
  sprintf_double_value(char *ptr, double value, const char *delim)
  {
! 	if (isinf(value))
  	{
  		if (value < 0)
  			sprintf(ptr, "%s%s", "-Infinity", delim);
  		else
  			sprintf(ptr, "%s%s", "Infinity", delim);
  	}
- 	else if (isnan(value))
- 		sprintf(ptr, "%s%s", "NaN", delim);
  	else
  		sprintf(ptr, "%.14g%s", value, delim);
  }
--- 468,482 ----
  static void
  sprintf_double_value(char *ptr, double value, const char *delim)
  {
! 	if (isnan(value))
! 		sprintf(ptr, "%s%s", "NaN", delim);
! 	else if (isinf(value))
  	{
  		if (value < 0)
  			sprintf(ptr, "%s%s", "-Infinity", delim);
  		else
  			sprintf(ptr, "%s%s", "Infinity", delim);
  	}
  	else
  		sprintf(ptr, "%.14g%s", value, delim);
  }
*************** sprintf_double_value(char *ptr, double v
*** 484,498 ****
  static void
  sprintf_float_value(char *ptr, float value, const char *delim)
  {
! 	if (isinf(value))
  	{
  		if (value < 0)
  			sprintf(ptr, "%s%s", "-Infinity", delim);
  		else
  			sprintf(ptr, "%s%s", "Infinity", delim);
  	}
- 	else if (isnan(value))
- 		sprintf(ptr, "%s%s", "NaN", delim);
  	else
  		sprintf(ptr, "%.14g%s", value, delim);
  }
--- 484,498 ----
  static void
  sprintf_float_value(char *ptr, float value, const char *delim)
  {
! 	if (isnan(value))
! 		sprintf(ptr, "%s%s", "NaN", delim);
! 	else if (isinf(value))
  	{
  		if (value < 0)
  			sprintf(ptr, "%s%s", "-Infinity", delim);
  		else
  			sprintf(ptr, "%s%s", "Infinity", delim);
  	}
  	else
  		sprintf(ptr, "%.14g%s", value, delim);
  }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c pgsql/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c	2010-02-09 11:43:57.000000000 +0100
--- pgsql/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c	2010-02-16 12:10:55.000000000 +0100
*************** if (sqlca.sqlcode < 0) sqlprint ( );}
*** 104,113 ****
  
  		if (sqlca.sqlcode)
  			break;
- 		if (isinf(d))
- 			printf("%d %sInf '%s'\n", id, (d < 0 ? "-" : "+"), val);
  		if (isnan(d))
  			printf("%d  NaN '%s'\n", id, val);
  
  		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into nantest1 ( id , d ) values ( $1  + 3 , $2  )", 
  	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
--- 104,113 ----
  
  		if (sqlca.sqlcode)
  			break;
  		if (isnan(d))
  			printf("%d  NaN '%s'\n", id, val);
+ 		else if (isinf(d))
+ 			printf("%d %sInf '%s'\n", id, (d < 0 ? "-" : "+"), val);
  
  		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into nantest1 ( id , d ) values ( $1  + 3 , $2  )", 
  	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/pgtypeslib/nan_test.pgc pgsql/src/interfaces/ecpg/test/pgtypeslib/nan_test.pgc
*** pgsql.orig/src/interfaces/ecpg/test/pgtypeslib/nan_test.pgc	2010-02-09 11:43:57.000000000 +0100
--- pgsql/src/interfaces/ecpg/test/pgtypeslib/nan_test.pgc	2010-02-16 12:04:59.000000000 +0100
*************** main(void)
*** 37,46 ****
  		exec sql fetch from cur into :id, :d, :val;
  		if (sqlca.sqlcode)
  			break;
- 		if (isinf(d))
- 			printf("%d %sInf '%s'\n", id, (d < 0 ? "-" : "+"), val);
  		if (isnan(d))
  			printf("%d  NaN '%s'\n", id, val);
  
  		exec sql insert into nantest1 (id, d) values (:id + 3, :d);
  		exec sql insert into nantest1 (id, d) values (:id + 6, :val);
--- 37,46 ----
  		exec sql fetch from cur into :id, :d, :val;
  		if (sqlca.sqlcode)
  			break;
  		if (isnan(d))
  			printf("%d  NaN '%s'\n", id, val);
+ 		else if (isinf(d))
+ 			printf("%d %sInf '%s'\n", id, (d < 0 ? "-" : "+"), val);
  
  		exec sql insert into nantest1 (id, d) values (:id + 3, :d);
  		exec sql insert into nantest1 (id, d) values (:id + 6, :val);
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to