aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Gierth <rhodiumtoad@postgresql.org>2019-02-13 19:35:50 +0000
committerAndrew Gierth <rhodiumtoad@postgresql.org>2019-02-13 19:35:50 +0000
commitda6520be7f946f5f0f8fe46c34e303d1d36ee080 (patch)
tree1adaa9c0d92824ed007bcd27ea978e36523a10a1 /src
parent711bab1e4d19b5c9967328315a542d93386b1ac5 (diff)
downloadpostgresql-da6520be7f946f5f0f8fe46c34e303d1d36ee080.tar.gz
postgresql-da6520be7f946f5f0f8fe46c34e303d1d36ee080.zip
More float test and portability fixes.
Avoid assuming exact results in tstypes test; some platforms vary. (per buildfarm members eulachon, danio, lapwing) Avoid dubious usage (inherited from upstream) of bool parameters to copy_special_str, to see if this fixes the mac/ppc failures (per buildfarm members prariedog and locust). (Isolated test programs on a ppc mac don't seem to show any other cause that would explain them.)
Diffstat (limited to 'src')
-rw-r--r--src/common/d2s.c2
-rw-r--r--src/common/f2s.c2
-rw-r--r--src/test/regress/expected/tstypes.out66
-rw-r--r--src/test/regress/sql/tstypes.sql3
4 files changed, 39 insertions, 34 deletions
diff --git a/src/common/d2s.c b/src/common/d2s.c
index 58f60977a54..1e4782c10a4 100644
--- a/src/common/d2s.c
+++ b/src/common/d2s.c
@@ -1028,7 +1028,7 @@ double_to_shortest_decimal_bufn(double f, char *result)
/* Case distinction; exit early for the easy cases. */
if (ieeeExponent == ((1u << DOUBLE_EXPONENT_BITS) - 1u) || (ieeeExponent == 0 && ieeeMantissa == 0))
{
- return copy_special_str(result, ieeeSign, ieeeExponent, ieeeMantissa);
+ return copy_special_str(result, ieeeSign, (ieeeExponent != 0), (ieeeMantissa != 0));
}
floating_decimal_64 v;
diff --git a/src/common/f2s.c b/src/common/f2s.c
index 62432a539e7..ff22b56c926 100644
--- a/src/common/f2s.c
+++ b/src/common/f2s.c
@@ -756,7 +756,7 @@ float_to_shortest_decimal_bufn(float f, char *result)
/* Case distinction; exit early for the easy cases. */
if (ieeeExponent == ((1u << FLOAT_EXPONENT_BITS) - 1u) || (ieeeExponent == 0 && ieeeMantissa == 0))
{
- return copy_special_str(result, ieeeSign, ieeeExponent, ieeeMantissa);
+ return copy_special_str(result, ieeeSign, (ieeeExponent != 0), (ieeeMantissa != 0));
}
floating_decimal_32 v;
diff --git a/src/test/regress/expected/tstypes.out b/src/test/regress/expected/tstypes.out
index 87a36ca3298..2c838ddffdb 100644
--- a/src/test/regress/expected/tstypes.out
+++ b/src/test/regress/expected/tstypes.out
@@ -1,3 +1,5 @@
+-- deal with numeric instability of ts_rank
+SET extra_float_digits = 0;
--Base tsvector test
SELECT '1'::tsvector;
tsvector
@@ -787,57 +789,57 @@ select to_tsvector('simple', '') @@ '!foo' AS "true";
--ranking
SELECT ts_rank(' a:1 s:2C d g'::tsvector, 'a | s');
- ts_rank
--------------
- 0.091189064
+ ts_rank
+-----------
+ 0.0911891
(1 row)
SELECT ts_rank(' a:1 sa:2C d g'::tsvector, 'a | s');
- ts_rank
--------------
- 0.030396355
+ ts_rank
+-----------
+ 0.0303964
(1 row)
SELECT ts_rank(' a:1 sa:2C d g'::tsvector, 'a | s:*');
- ts_rank
--------------
- 0.091189064
+ ts_rank
+-----------
+ 0.0911891
(1 row)
SELECT ts_rank(' a:1 sa:2C d g'::tsvector, 'a | sa:*');
- ts_rank
--------------
- 0.091189064
+ ts_rank
+-----------
+ 0.0911891
(1 row)
SELECT ts_rank(' a:1 s:2B d g'::tsvector, 'a | s');
- ts_rank
-------------
- 0.15198177
+ ts_rank
+----------
+ 0.151982
(1 row)
SELECT ts_rank(' a:1 s:2 d g'::tsvector, 'a | s');
- ts_rank
-------------
- 0.06079271
+ ts_rank
+-----------
+ 0.0607927
(1 row)
SELECT ts_rank(' a:1 s:2C d g'::tsvector, 'a & s');
- ts_rank
-------------
- 0.14015312
+ ts_rank
+----------
+ 0.140153
(1 row)
SELECT ts_rank(' a:1 s:2B d g'::tsvector, 'a & s');
- ts_rank
-------------
- 0.19820644
+ ts_rank
+----------
+ 0.198206
(1 row)
SELECT ts_rank(' a:1 s:2 d g'::tsvector, 'a & s');
- ts_rank
-------------
- 0.09910322
+ ts_rank
+-----------
+ 0.0991032
(1 row)
SELECT ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a | s');
@@ -885,7 +887,7 @@ SELECT ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a | s');
SELECT ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a & s');
ts_rank_cd
------------
- 0.13333334
+ 0.133333
(1 row)
SELECT ts_rank_cd(' a:1 s:2B d g'::tsvector, 'a & s');
@@ -903,13 +905,13 @@ SELECT ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a & s');
SELECT ts_rank_cd(' a:1 s:2A d g'::tsvector, 'a <-> s');
ts_rank_cd
------------
- 0.18181819
+ 0.181818
(1 row)
SELECT ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a <-> s');
ts_rank_cd
------------
- 0.13333334
+ 0.133333
(1 row)
SELECT ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a <-> s');
@@ -927,13 +929,13 @@ SELECT ts_rank_cd(' a:1 s:2 d:2A g'::tsvector, 'a <-> s');
SELECT ts_rank_cd(' a:1 s:2,3A d:2A g'::tsvector, 'a <2> s:A');
ts_rank_cd
------------
- 0.09090909
+ 0.0909091
(1 row)
SELECT ts_rank_cd(' a:1 b:2 s:3A d:2A g'::tsvector, 'a <2> s:A');
ts_rank_cd
------------
- 0.09090909
+ 0.0909091
(1 row)
SELECT ts_rank_cd(' a:1 sa:2D sb:2A g'::tsvector, 'a <-> s:*');
diff --git a/src/test/regress/sql/tstypes.sql b/src/test/regress/sql/tstypes.sql
index 0a40ec93504..94ee1772b44 100644
--- a/src/test/regress/sql/tstypes.sql
+++ b/src/test/regress/sql/tstypes.sql
@@ -1,3 +1,6 @@
+-- deal with numeric instability of ts_rank
+SET extra_float_digits = 0;
+
--Base tsvector test
SELECT '1'::tsvector;