Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
1bc2d544
Commit
1bc2d544
authored
Mar 15, 2004
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Localize our dependencies on the way to create NAN or INFINITY.
Per recent proposal to pghackers.
parent
89ab5c4a
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
106 additions
and
81 deletions
+106
-81
contrib/seg/seg.c
contrib/seg/seg.c
+2
-2
contrib/seg/segparse.y
contrib/seg/segparse.y
+2
-6
src/backend/port/qnx4/isnan.c
src/backend/port/qnx4/isnan.c
+9
-3
src/backend/utils/adt/float.c
src/backend/utils/adt/float.c
+80
-19
src/backend/utils/adt/numeric.c
src/backend/utils/adt/numeric.c
+4
-13
src/backend/utils/adt/timestamp.c
src/backend/utils/adt/timestamp.c
+1
-5
src/include/port/qnx4.h
src/include/port/qnx4.h
+0
-10
src/include/port/solaris.h
src/include/port/solaris.h
+1
-22
src/include/utils/builtins.h
src/include/utils/builtins.h
+7
-1
No files found.
contrib/seg/seg.c
View file @
1bc2d544
...
@@ -755,7 +755,7 @@ seg_cmp(SEG * a, SEG * b)
...
@@ -755,7 +755,7 @@ seg_cmp(SEG * a, SEG * b)
* a->lower == b->lower, so consider type of boundary.
* a->lower == b->lower, so consider type of boundary.
*
*
* A '-' lower bound is < any other kind (this could only be relevant if
* A '-' lower bound is < any other kind (this could only be relevant if
* -HUGE is used as a regular data value). A '<' lower bound is < any
* -HUGE
_VAL
is used as a regular data value). A '<' lower bound is < any
* other kind except '-'. A '>' lower bound is > any other kind.
* other kind except '-'. A '>' lower bound is > any other kind.
*/
*/
if
(
a
->
l_ext
!=
b
->
l_ext
)
if
(
a
->
l_ext
!=
b
->
l_ext
)
...
@@ -813,7 +813,7 @@ seg_cmp(SEG * a, SEG * b)
...
@@ -813,7 +813,7 @@ seg_cmp(SEG * a, SEG * b)
* a->upper == b->upper, so consider type of boundary.
* a->upper == b->upper, so consider type of boundary.
*
*
* A '-' upper bound is > any other kind (this could only be relevant if
* A '-' upper bound is > any other kind (this could only be relevant if
* HUGE is used as a regular data value). A '<' upper bound is < any
* HUGE
_VAL
is used as a regular data value). A '<' upper bound is < any
* other kind. A '>' upper bound is > any other kind except '-'.
* other kind. A '>' upper bound is > any other kind except '-'.
*/
*/
if
(
a
->
u_ext
!=
b
->
u_ext
)
if
(
a
->
u_ext
!=
b
->
u_ext
)
...
...
contrib/seg/segparse.y
View file @
1bc2d544
...
@@ -6,10 +6,6 @@
...
@@ -6,10 +6,6 @@
#include <math.h>
#include <math.h>
#include "segdata.h"
#include "segdata.h"
#ifdef __CYGWIN__
#define HUGE HUGE_VAL
#endif /* __CYGWIN__ */
#undef yylex /* falure to redefine yylex will result in calling the */
#undef yylex /* falure to redefine yylex will result in calling the */
#define yylex seg_yylex /* wrong scanner when running inside postgres backend */
#define yylex seg_yylex /* wrong scanner when running inside postgres backend */
...
@@ -86,7 +82,7 @@ range:
...
@@ -86,7 +82,7 @@ range:
|
|
boundary RANGE {
boundary RANGE {
((SEG *)result)->lower = $1.val;
((SEG *)result)->lower = $1.val;
((SEG *)result)->upper = HUGE;
((SEG *)result)->upper = HUGE
_VAL
;
((SEG *)result)->l_sigd = $1.sigd;
((SEG *)result)->l_sigd = $1.sigd;
((SEG *)result)->u_sigd = 0;
((SEG *)result)->u_sigd = 0;
((SEG *)result)->l_ext = ( $1.ext ? $1.ext : '\0' );
((SEG *)result)->l_ext = ( $1.ext ? $1.ext : '\0' );
...
@@ -94,7 +90,7 @@ range:
...
@@ -94,7 +90,7 @@ range:
}
}
|
|
RANGE boundary {
RANGE boundary {
((SEG *)result)->lower = -HUGE;
((SEG *)result)->lower = -HUGE
_VAL
;
((SEG *)result)->upper = $2.val;
((SEG *)result)->upper = $2.val;
((SEG *)result)->l_sigd = 0;
((SEG *)result)->l_sigd = 0;
((SEG *)result)->u_sigd = $2.sigd;
((SEG *)result)->u_sigd = $2.sigd;
...
...
src/backend/port/qnx4/isnan.c
View file @
1bc2d544
...
@@ -7,17 +7,23 @@
...
@@ -7,17 +7,23 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/port/qnx4/isnan.c,v 1.
4 2003/11/29 19:51:54 pgsq
l Exp $
* $PostgreSQL: pgsql/src/backend/port/qnx4/isnan.c,v 1.
5 2004/03/15 03:29:22 tg
l Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
#include "c.h"
#include "c.h"
unsigned
char
__nan
[
8
]
=
__nan_bytes
;
#include <math.h>
#ifndef __nan_bytes
#define __nan_bytes { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f }
#endif
/* __nan_bytes */
static
unsigned
char
__nan
[
8
]
=
__nan_bytes
;
int
int
isnan
(
double
dsrc
)
isnan
(
double
dsrc
)
{
{
return
!
memcmp
(
&
dsrc
,
&
NAN
,
sizeof
(
double
))
;
return
memcmp
(
&
dsrc
,
__nan
,
sizeof
(
double
))
==
0
;
}
}
src/backend/utils/adt/float.c
View file @
1bc2d544
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.10
0 2004/03/14 05:22:52 neilc
Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.10
1 2004/03/15 03:29:22 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -54,9 +54,8 @@
...
@@ -54,9 +54,8 @@
#include <ctype.h>
#include <ctype.h>
#include <errno.h>
#include <errno.h>
#include <float.h>
/* faked on sunos4 */
#include <float.h>
#include <math.h>
#include <math.h>
#include <limits.h>
#include <limits.h>
/* for finite() on Solaris */
/* for finite() on Solaris */
#ifdef HAVE_IEEEFP_H
#ifdef HAVE_IEEEFP_H
...
@@ -70,19 +69,11 @@
...
@@ -70,19 +69,11 @@
#include "utils/builtins.h"
#include "utils/builtins.h"
#ifndef HAVE_CBRT
static
double
cbrt
(
double
x
);
#endif
/* HAVE_CBRT */
#ifndef M_PI
#ifndef M_PI
/* from my RH5.2 gcc math.h file - thomas 2000-04-03 */
/* from my RH5.2 gcc math.h file - thomas 2000-04-03 */
#define M_PI 3.14159265358979323846
#define M_PI 3.14159265358979323846
#endif
#endif
#ifndef NAN
#define NAN (0.0/0.0)
#endif
#ifndef SHRT_MAX
#ifndef SHRT_MAX
#define SHRT_MAX 32767
#define SHRT_MAX 32767
#endif
#endif
...
@@ -109,9 +100,78 @@ int extra_float_digits = 0; /* Added to DBL_DIG or FLT_DIG */
...
@@ -109,9 +100,78 @@ int extra_float_digits = 0; /* Added to DBL_DIG or FLT_DIG */
static
void
CheckFloat4Val
(
double
val
);
static
void
CheckFloat4Val
(
double
val
);
static
void
CheckFloat8Val
(
double
val
);
static
void
CheckFloat8Val
(
double
val
);
static
int
is_infinite
(
double
val
);
static
int
float4_cmp_internal
(
float4
a
,
float4
b
);
static
int
float4_cmp_internal
(
float4
a
,
float4
b
);
static
int
float8_cmp_internal
(
float8
a
,
float8
b
);
static
int
float8_cmp_internal
(
float8
a
,
float8
b
);
#ifndef HAVE_CBRT
static
double
cbrt
(
double
x
);
#endif
/* HAVE_CBRT */
/*
* Routines to provide reasonably platform-independent handling of
* infinity and NaN. We assume that isinf() and isnan() are available
* and work per spec. (On some platforms, we have to supply our own;
* see src/port.) However, generating an Infinity or NaN in the first
* place is less well standardized; pre-C99 systems tend not to have C99's
* INFINITY and NAN macros. We centralize our workarounds for this here.
*/
double
get_float8_infinity
(
void
)
{
#ifdef INFINITY
/* C99 standard way */
return
(
double
)
INFINITY
;
#else
/*
* On some platforms, HUGE_VAL is an infinity, elsewhere it's just the
* largest normal double. We assume forcing an overflow will get us
* a true infinity.
*/
return
(
double
)
(
HUGE_VAL
*
HUGE_VAL
);
#endif
}
float
get_float4_infinity
(
void
)
{
#ifdef INFINITY
/* C99 standard way */
return
(
float
)
INFINITY
;
#else
/*
* On some platforms, HUGE_VAL is an infinity, elsewhere it's just the
* largest normal double. We assume forcing an overflow will get us
* a true infinity.
*/
return
(
float
)
(
HUGE_VAL
*
HUGE_VAL
);
#endif
}
double
get_float8_nan
(
void
)
{
#ifdef NAN
/* C99 standard way */
return
(
double
)
NAN
;
#else
/* Assume we can get a NAN via zero divide */
return
(
double
)
(
0
.
0
/
0
.
0
);
#endif
}
float
get_float4_nan
(
void
)
{
#ifdef NAN
/* C99 standard way */
return
(
float
)
NAN
;
#else
/* Assume we can get a NAN via zero divide */
return
(
float
)
(
0
.
0
/
0
.
0
);
#endif
}
/*
/*
* Returns -1 if 'val' represents negative infinity, 1 if 'val'
* Returns -1 if 'val' represents negative infinity, 1 if 'val'
...
@@ -120,7 +180,7 @@ static int float8_cmp_internal(float8 a, float8 b);
...
@@ -120,7 +180,7 @@ static int float8_cmp_internal(float8 a, float8 b);
* does not specify that isinf() needs to distinguish between positive
* does not specify that isinf() needs to distinguish between positive
* and negative infinity.
* and negative infinity.
*/
*/
static
int
int
is_infinite
(
double
val
)
is_infinite
(
double
val
)
{
{
int
inf
=
isinf
(
val
);
int
inf
=
isinf
(
val
);
...
@@ -134,6 +194,7 @@ is_infinite(double val)
...
@@ -134,6 +194,7 @@ is_infinite(double val)
return
-
1
;
return
-
1
;
}
}
/*
/*
* check to see if a float4 val is outside of the FLOAT4_MIN,
* check to see if a float4 val is outside of the FLOAT4_MIN,
* FLOAT4_MAX bounds.
* FLOAT4_MAX bounds.
...
@@ -237,17 +298,17 @@ float4in(PG_FUNCTION_ARGS)
...
@@ -237,17 +298,17 @@ float4in(PG_FUNCTION_ARGS)
*/
*/
if
(
strncasecmp
(
num
,
"NaN"
,
3
)
==
0
)
if
(
strncasecmp
(
num
,
"NaN"
,
3
)
==
0
)
{
{
val
=
NAN
;
val
=
get_float4_nan
()
;
endptr
=
num
+
3
;
endptr
=
num
+
3
;
}
}
else
if
(
strncasecmp
(
num
,
"Infinity"
,
8
)
==
0
)
else
if
(
strncasecmp
(
num
,
"Infinity"
,
8
)
==
0
)
{
{
val
=
HUGE_VAL
;
val
=
get_float4_infinity
()
;
endptr
=
num
+
8
;
endptr
=
num
+
8
;
}
}
else
if
(
strncasecmp
(
num
,
"-Infinity"
,
9
)
==
0
)
else
if
(
strncasecmp
(
num
,
"-Infinity"
,
9
)
==
0
)
{
{
val
=
-
HUGE_VAL
;
val
=
-
get_float4_infinity
()
;
endptr
=
num
+
9
;
endptr
=
num
+
9
;
}
}
else
else
...
@@ -402,17 +463,17 @@ float8in(PG_FUNCTION_ARGS)
...
@@ -402,17 +463,17 @@ float8in(PG_FUNCTION_ARGS)
*/
*/
if
(
strncasecmp
(
num
,
"NaN"
,
3
)
==
0
)
if
(
strncasecmp
(
num
,
"NaN"
,
3
)
==
0
)
{
{
val
=
NAN
;
val
=
get_float8_nan
()
;
endptr
=
num
+
3
;
endptr
=
num
+
3
;
}
}
else
if
(
strncasecmp
(
num
,
"Infinity"
,
8
)
==
0
)
else
if
(
strncasecmp
(
num
,
"Infinity"
,
8
)
==
0
)
{
{
val
=
HUGE_VAL
;
val
=
get_float8_infinity
()
;
endptr
=
num
+
8
;
endptr
=
num
+
8
;
}
}
else
if
(
strncasecmp
(
num
,
"-Infinity"
,
9
)
==
0
)
else
if
(
strncasecmp
(
num
,
"-Infinity"
,
9
)
==
0
)
{
{
val
=
-
HUGE_VAL
;
val
=
-
get_float8_infinity
()
;
endptr
=
num
+
9
;
endptr
=
num
+
9
;
}
}
else
else
...
...
src/backend/utils/adt/numeric.c
View file @
1bc2d544
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
* Copyright (c) 1998-2003, PostgreSQL Global Development Group
* Copyright (c) 1998-2003, PostgreSQL Global Development Group
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.7
1 2004/02/04 01:11:47 neilc
Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.7
2 2004/03/15 03:29:22 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -42,15 +42,6 @@
...
@@ -42,15 +42,6 @@
*/
*/
/* ----------
* Local definitions
* ----------
*/
#ifndef NAN
#define NAN (0.0/0.0)
#endif
/* ----------
/* ----------
* Local data types
* Local data types
*
*
...
@@ -1790,7 +1781,7 @@ numeric_float8(PG_FUNCTION_ARGS)
...
@@ -1790,7 +1781,7 @@ numeric_float8(PG_FUNCTION_ARGS)
Datum
result
;
Datum
result
;
if
(
NUMERIC_IS_NAN
(
num
))
if
(
NUMERIC_IS_NAN
(
num
))
PG_RETURN_FLOAT8
(
NAN
);
PG_RETURN_FLOAT8
(
get_float8_nan
()
);
tmp
=
DatumGetCString
(
DirectFunctionCall1
(
numeric_out
,
tmp
=
DatumGetCString
(
DirectFunctionCall1
(
numeric_out
,
NumericGetDatum
(
num
)));
NumericGetDatum
(
num
)));
...
@@ -1811,7 +1802,7 @@ numeric_float8_no_overflow(PG_FUNCTION_ARGS)
...
@@ -1811,7 +1802,7 @@ numeric_float8_no_overflow(PG_FUNCTION_ARGS)
double
val
;
double
val
;
if
(
NUMERIC_IS_NAN
(
num
))
if
(
NUMERIC_IS_NAN
(
num
))
PG_RETURN_FLOAT8
(
NAN
);
PG_RETURN_FLOAT8
(
get_float8_nan
()
);
val
=
numeric_to_double_no_overflow
(
num
);
val
=
numeric_to_double_no_overflow
(
num
);
...
@@ -1850,7 +1841,7 @@ numeric_float4(PG_FUNCTION_ARGS)
...
@@ -1850,7 +1841,7 @@ numeric_float4(PG_FUNCTION_ARGS)
Datum
result
;
Datum
result
;
if
(
NUMERIC_IS_NAN
(
num
))
if
(
NUMERIC_IS_NAN
(
num
))
PG_RETURN_FLOAT4
(
(
float4
)
NAN
);
PG_RETURN_FLOAT4
(
get_float4_nan
()
);
tmp
=
DatumGetCString
(
DirectFunctionCall1
(
numeric_out
,
tmp
=
DatumGetCString
(
DirectFunctionCall1
(
numeric_out
,
NumericGetDatum
(
num
)));
NumericGetDatum
(
num
)));
...
...
src/backend/utils/adt/timestamp.c
View file @
1bc2d544
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.10
0 2004/03/05 02:41:14 momjian
Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.10
1 2004/03/15 03:29:22 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -20,10 +20,6 @@
...
@@ -20,10 +20,6 @@
#include <errno.h>
#include <errno.h>
#include <float.h>
#include <float.h>
#include <limits.h>
#include <limits.h>
/* for finite() on Solaris */
#ifdef HAVE_IEEEFP_H
#include <ieeefp.h>
#endif
#include "access/hash.h"
#include "access/hash.h"
#include "access/xact.h"
#include "access/xact.h"
...
...
src/include/port/qnx4.h
View file @
1bc2d544
...
@@ -9,18 +9,8 @@
...
@@ -9,18 +9,8 @@
#define strncasecmp strnicmp
#define strncasecmp strnicmp
#ifndef NAN
#ifndef __nan_bytes
#define __nan_bytes { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f }
#endif
/* __nan_bytes */
extern
unsigned
char
__nan
[
8
];
#define NAN (*(const double *) __nan)
#endif
/* NAN */
typedef
u_short
ushort
;
typedef
u_short
ushort
;
extern
int
isnan
(
double
dsrc
);
extern
int
isnan
(
double
dsrc
);
extern
long
random
(
void
);
extern
long
random
(
void
);
extern
void
srandom
(
unsigned
int
seed
);
extern
void
srandom
(
unsigned
int
seed
);
src/include/port/solaris.h
View file @
1bc2d544
/* $PostgreSQL: pgsql/src/include/port/solaris.h,v 1.1
0 2003/12/23 03:31:30 momjian
Exp $ */
/* $PostgreSQL: pgsql/src/include/port/solaris.h,v 1.1
1 2004/03/15 03:29:22 tgl
Exp $ */
/*
/*
* Sort this out for all operating systems some time. The __xxx
* Sort this out for all operating systems some time. The __xxx
...
@@ -35,24 +35,3 @@
...
@@ -35,24 +35,3 @@
#define BYTE_ORDER LITTLE_ENDIAN
#define BYTE_ORDER LITTLE_ENDIAN
#endif
#endif
#endif
#endif
#ifndef NAN
#if defined(__GNUC__) && defined(__i386__)
#ifndef __nan_bytes
#define __nan_bytes { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f }
#endif
#define NAN \
(__extension__ ((union { unsigned char __c[8]; double __d; }) \
{ __nan_bytes }).__d)
#else
/* not GNUC and i386 */
#define NAN (0.0/0.0)
#endif
/* GCC. */
#endif
/* not NAN */
src/include/utils/builtins.h
View file @
1bc2d544
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.23
4 2004/02/03 08:29:57 joe
Exp $
* $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.23
5 2004/03/15 03:29:22 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -240,6 +240,12 @@ extern Datum bttext_pattern_cmp(PG_FUNCTION_ARGS);
...
@@ -240,6 +240,12 @@ extern Datum bttext_pattern_cmp(PG_FUNCTION_ARGS);
/* float.c */
/* float.c */
extern
DLLIMPORT
int
extra_float_digits
;
extern
DLLIMPORT
int
extra_float_digits
;
extern
double
get_float8_infinity
(
void
);
extern
float
get_float4_infinity
(
void
);
extern
double
get_float8_nan
(
void
);
extern
float
get_float4_nan
(
void
);
extern
int
is_infinite
(
double
val
);
extern
Datum
float4in
(
PG_FUNCTION_ARGS
);
extern
Datum
float4in
(
PG_FUNCTION_ARGS
);
extern
Datum
float4out
(
PG_FUNCTION_ARGS
);
extern
Datum
float4out
(
PG_FUNCTION_ARGS
);
extern
Datum
float4recv
(
PG_FUNCTION_ARGS
);
extern
Datum
float4recv
(
PG_FUNCTION_ARGS
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment