Skip to content

Commit 4d17a21

Browse files
committed
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
1 parent bf37983 commit 4d17a21

File tree

10 files changed

+45
-5
lines changed

10 files changed

+45
-5
lines changed

src/backend/utils/adt/float.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.165 2010/02/08 20:39:51 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.166 2010/02/27 21:53:21 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -130,7 +130,8 @@ get_float4_infinity(void)
130130
double
131131
get_float8_nan(void)
132132
{
133-
#ifdef NAN
133+
/* (double) NAN doesn't work on some NetBSD/MIPS releases */
134+
#if defined(NAN) && !(defined(__NetBSD__) && defined(__mips__))
134135
/* C99 standard way */
135136
return (double) NAN;
136137
#else

src/interfaces/ecpg/ecpglib/data.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.50 2010/02/26 02:01:29 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.51 2010/02/27 21:53:21 tgl Exp $ */
22

33
#define POSTGRES_ECPG_INTERNAL
44
#include "postgres_fe.h"
55

66
#include <stdlib.h>
77
#include <string.h>
8+
#include <float.h>
89
#include <math.h>
910

1011
#include "ecpgtype.h"
@@ -85,7 +86,8 @@ get_float8_infinity(void)
8586
static double
8687
get_float8_nan(void)
8788
{
88-
#ifdef NAN
89+
/* (double) NAN doesn't work on some NetBSD/MIPS releases */
90+
#if defined(NAN) && !(defined(__NetBSD__) && defined(__mips__))
8991
return (double) NAN;
9092
#else
9193
return (double) (0.0 / 0.0);

src/test/regress/expected/float4-exp-three-digits.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ SELECT 'nan'::float4 / 'nan'::float4;
119119
NaN
120120
(1 row)
121121

122+
SELECT 'nan'::numeric::float4;
123+
float4
124+
--------
125+
NaN
126+
(1 row)
127+
122128
SELECT '' AS five, * FROM FLOAT4_TBL;
123129
five | f1
124130
------+--------------

src/test/regress/expected/float4.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ SELECT 'nan'::float4 / 'nan'::float4;
119119
NaN
120120
(1 row)
121121

122+
SELECT 'nan'::numeric::float4;
123+
float4
124+
--------
125+
NaN
126+
(1 row)
127+
122128
SELECT '' AS five, * FROM FLOAT4_TBL;
123129
five | f1
124130
------+-------------

src/test/regress/expected/float8-exp-three-digits-win32.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ SELECT 'nan'::float8 / 'nan'::float8;
119119
NaN
120120
(1 row)
121121

122+
SELECT 'nan'::numeric::float8;
123+
float8
124+
--------
125+
NaN
126+
(1 row)
127+
122128
SELECT '' AS five, * FROM FLOAT8_TBL;
123129
five | f1
124130
------+----------------------

src/test/regress/expected/float8-small-is-zero.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ SELECT 'nan'::float8 / 'nan'::float8;
123123
NaN
124124
(1 row)
125125

126+
SELECT 'nan'::numeric::float8;
127+
float8
128+
--------
129+
NaN
130+
(1 row)
131+
126132
SELECT '' AS five, * FROM FLOAT8_TBL;
127133
five | f1
128134
------+----------------------

src/test/regress/expected/float8-small-is-zero_1.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ SELECT 'nan'::float8 / 'nan'::float8;
123123
NaN
124124
(1 row)
125125

126+
SELECT 'nan'::numeric::float8;
127+
float8
128+
--------
129+
NaN
130+
(1 row)
131+
126132
SELECT '' AS five, * FROM FLOAT8_TBL;
127133
five | f1
128134
------+----------------------

src/test/regress/expected/float8.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ SELECT 'nan'::float8 / 'nan'::float8;
119119
NaN
120120
(1 row)
121121

122+
SELECT 'nan'::numeric::float8;
123+
float8
124+
--------
125+
NaN
126+
(1 row)
127+
122128
SELECT '' AS five, * FROM FLOAT8_TBL;
123129
five | f1
124130
------+----------------------

src/test/regress/sql/float4.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ SELECT ' INFINITY x'::float4;
4040
SELECT 'Infinity'::float4 + 100.0;
4141
SELECT 'Infinity'::float4 / 'Infinity'::float4;
4242
SELECT 'nan'::float4 / 'nan'::float4;
43-
43+
SELECT 'nan'::numeric::float4;
4444

4545
SELECT '' AS five, * FROM FLOAT4_TBL;
4646

src/test/regress/sql/float8.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ SELECT ' INFINITY x'::float8;
4040
SELECT 'Infinity'::float8 + 100.0;
4141
SELECT 'Infinity'::float8 / 'Infinity'::float8;
4242
SELECT 'nan'::float8 / 'nan'::float8;
43+
SELECT 'nan'::numeric::float8;
4344

4445
SELECT '' AS five, * FROM FLOAT8_TBL;
4546

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy