More float test and portability fixes.
authorAndrew Gierth <rhodiumtoad@postgresql.org>
Wed, 13 Feb 2019 19:35:50 +0000 (19:35 +0000)
committerAndrew Gierth <rhodiumtoad@postgresql.org>
Wed, 13 Feb 2019 19:35:50 +0000 (19:35 +0000)
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.)

src/common/d2s.c
src/common/f2s.c
src/test/regress/expected/tstypes.out
src/test/regress/sql/tstypes.sql

index 58f60977a54bf1ef1bee7707ab41cf02197255da..1e4782c10a40662f55a71701e6f85475000bd4bf 100644 (file)
@@ -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;
index 62432a539e761c1261a1d42a22d5761e50b86ff1..ff22b56c926cee8ce629f5202116a51a3665298e 100644 (file)
@@ -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;
index 87a36ca32988a1e60e70b3783ed045c6655bd413..2c838ddffdb3d0d5c3f9953896ced4f7d67f5df9 100644 (file)
@@ -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:*');
index 0a40ec9350440b67ef2fe2c6cfb9112d0a31be36..94ee1772b44b7d597b90226a76935d769648e6dd 100644 (file)
@@ -1,3 +1,6 @@
+-- deal with numeric instability of ts_rank
+SET extra_float_digits = 0;
+
 --Base tsvector test
 
 SELECT '1'::tsvector;