summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2010-02-27 21:53:21 +0000
committerTom Lane2010-02-27 21:53:21 +0000
commit4d17a2146ca7f48bca1da4c73a745fb09ec43ed3 (patch)
treecea3f7cd728afe3be857f4c98cbe0f8040fb936b
parentbf379837dcd7f0f080d61955ed630b023a3b392d (diff)
Insert a hack into get_float8_nan (both core and ecpg copies) to deal with
the fact that NetBSD/mips is currently broken, as per buildfarm member pika. Also add regression tests to ensure that get_float8_nan and get_float4_nan are exercised even on platforms where they are not needed by float8in/float4in. Zoltán Böszörményi and Tom Lane
-rw-r--r--src/backend/utils/adt/float.c5
-rw-r--r--src/interfaces/ecpg/ecpglib/data.c6
-rw-r--r--src/test/regress/expected/float4-exp-three-digits.out6
-rw-r--r--src/test/regress/expected/float4.out6
-rw-r--r--src/test/regress/expected/float8-exp-three-digits-win32.out6
-rw-r--r--src/test/regress/expected/float8-small-is-zero.out6
-rw-r--r--src/test/regress/expected/float8-small-is-zero_1.out6
-rw-r--r--src/test/regress/expected/float8.out6
-rw-r--r--src/test/regress/sql/float4.sql2
-rw-r--r--src/test/regress/sql/float8.sql1
10 files changed, 45 insertions, 5 deletions
diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c
index 82e95704fb..f396b1d1cc 100644
--- a/src/backend/utils/adt/float.c
+++ b/src/backend/utils/adt/float.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.165 2010/02/08 20:39:51 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.166 2010/02/27 21:53:21 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -130,7 +130,8 @@ get_float4_infinity(void)
double
get_float8_nan(void)
{
-#ifdef NAN
+ /* (double) NAN doesn't work on some NetBSD/MIPS releases */
+#if defined(NAN) && !(defined(__NetBSD__) && defined(__mips__))
/* C99 standard way */
return (double) NAN;
#else
diff --git a/src/interfaces/ecpg/ecpglib/data.c b/src/interfaces/ecpg/ecpglib/data.c
index f5190049e1..5035dbd705 100644
--- a/src/interfaces/ecpg/ecpglib/data.c
+++ b/src/interfaces/ecpg/ecpglib/data.c
@@ -1,10 +1,11 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.50 2010/02/26 02:01:29 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.51 2010/02/27 21:53:21 tgl Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
#include <stdlib.h>
#include <string.h>
+#include <float.h>
#include <math.h>
#include "ecpgtype.h"
@@ -85,7 +86,8 @@ get_float8_infinity(void)
static double
get_float8_nan(void)
{
-#ifdef NAN
+ /* (double) NAN doesn't work on some NetBSD/MIPS releases */
+#if defined(NAN) && !(defined(__NetBSD__) && defined(__mips__))
return (double) NAN;
#else
return (double) (0.0 / 0.0);
diff --git a/src/test/regress/expected/float4-exp-three-digits.out b/src/test/regress/expected/float4-exp-three-digits.out
index b849910151..ff680f4792 100644
--- a/src/test/regress/expected/float4-exp-three-digits.out
+++ b/src/test/regress/expected/float4-exp-three-digits.out
@@ -119,6 +119,12 @@ SELECT 'nan'::float4 / 'nan'::float4;
NaN
(1 row)
+SELECT 'nan'::numeric::float4;
+ float4
+--------
+ NaN
+(1 row)
+
SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+--------------
diff --git a/src/test/regress/expected/float4.out b/src/test/regress/expected/float4.out
index 2c19e7eb08..dd8066a79c 100644
--- a/src/test/regress/expected/float4.out
+++ b/src/test/regress/expected/float4.out
@@ -119,6 +119,12 @@ SELECT 'nan'::float4 / 'nan'::float4;
NaN
(1 row)
+SELECT 'nan'::numeric::float4;
+ float4
+--------
+ NaN
+(1 row)
+
SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+-------------
diff --git a/src/test/regress/expected/float8-exp-three-digits-win32.out b/src/test/regress/expected/float8-exp-three-digits-win32.out
index 4d133b42dc..a4b8b47bad 100644
--- a/src/test/regress/expected/float8-exp-three-digits-win32.out
+++ b/src/test/regress/expected/float8-exp-three-digits-win32.out
@@ -119,6 +119,12 @@ SELECT 'nan'::float8 / 'nan'::float8;
NaN
(1 row)
+SELECT 'nan'::numeric::float8;
+ float8
+--------
+ NaN
+(1 row)
+
SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+----------------------
diff --git a/src/test/regress/expected/float8-small-is-zero.out b/src/test/regress/expected/float8-small-is-zero.out
index 6c756a6f8e..3037892ffe 100644
--- a/src/test/regress/expected/float8-small-is-zero.out
+++ b/src/test/regress/expected/float8-small-is-zero.out
@@ -123,6 +123,12 @@ SELECT 'nan'::float8 / 'nan'::float8;
NaN
(1 row)
+SELECT 'nan'::numeric::float8;
+ float8
+--------
+ NaN
+(1 row)
+
SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+----------------------
diff --git a/src/test/regress/expected/float8-small-is-zero_1.out b/src/test/regress/expected/float8-small-is-zero_1.out
index 8b25f0955c..c48bb538c4 100644
--- a/src/test/regress/expected/float8-small-is-zero_1.out
+++ b/src/test/regress/expected/float8-small-is-zero_1.out
@@ -123,6 +123,12 @@ SELECT 'nan'::float8 / 'nan'::float8;
NaN
(1 row)
+SELECT 'nan'::numeric::float8;
+ float8
+--------
+ NaN
+(1 row)
+
SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+----------------------
diff --git a/src/test/regress/expected/float8.out b/src/test/regress/expected/float8.out
index e9e71bb7aa..d8350d100e 100644
--- a/src/test/regress/expected/float8.out
+++ b/src/test/regress/expected/float8.out
@@ -119,6 +119,12 @@ SELECT 'nan'::float8 / 'nan'::float8;
NaN
(1 row)
+SELECT 'nan'::numeric::float8;
+ float8
+--------
+ NaN
+(1 row)
+
SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+----------------------
diff --git a/src/test/regress/sql/float4.sql b/src/test/regress/sql/float4.sql
index 5944e2fc14..4cde9d742f 100644
--- a/src/test/regress/sql/float4.sql
+++ b/src/test/regress/sql/float4.sql
@@ -40,7 +40,7 @@ SELECT ' INFINITY x'::float4;
SELECT 'Infinity'::float4 + 100.0;
SELECT 'Infinity'::float4 / 'Infinity'::float4;
SELECT 'nan'::float4 / 'nan'::float4;
-
+SELECT 'nan'::numeric::float4;
SELECT '' AS five, * FROM FLOAT4_TBL;
diff --git a/src/test/regress/sql/float8.sql b/src/test/regress/sql/float8.sql
index 92b6b0d7b9..142e6d7d73 100644
--- a/src/test/regress/sql/float8.sql
+++ b/src/test/regress/sql/float8.sql
@@ -40,6 +40,7 @@ SELECT ' INFINITY x'::float8;
SELECT 'Infinity'::float8 + 100.0;
SELECT 'Infinity'::float8 / 'Infinity'::float8;
SELECT 'nan'::float8 / 'nan'::float8;
+SELECT 'nan'::numeric::float8;
SELECT '' AS five, * FROM FLOAT8_TBL;