]> granicus.if.org Git - postgresql/commitdiff
Avoid getting bit by roundoff error while checking $Safe::VERSION.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 24 Nov 2004 18:47:38 +0000 (18:47 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 24 Nov 2004 18:47:38 +0000 (18:47 +0000)
Per report from Mark Kirkwood.

src/pl/plperl/plperl.c

index ef5b35dbac8f1055fde4d3e0bedd6d1826bc0f9d..20364d27da6e953d080e1d9e97070cc977f1b923 100644 (file)
@@ -33,7 +33,7 @@
  *       ENHANCEMENTS, OR MODIFICATIONS.
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.63 2004/11/23 00:21:17 tgl Exp $
+ *       $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.64 2004/11/24 18:47:38 tgl Exp $
  *
  **********************************************************************/
 
@@ -238,13 +238,18 @@ plperl_safe_init(void)
                           ;
 
        SV                 *res;
-       float           safe_version;
+       double          safe_version;
 
        res = eval_pv(safe_module, FALSE);      /* TRUE = croak if failure */
 
        safe_version = SvNV(res);
 
-       eval_pv((safe_version < 2.09 ? safe_bad : safe_ok), FALSE);
+       /*
+        * We actually want to reject safe_version < 2.09, but it's risky to
+        * assume that floating-point comparisons are exact, so use a slightly
+        * smaller comparison value.
+        */
+       eval_pv((safe_version < 2.0899 ? safe_bad : safe_ok), FALSE);
 
        plperl_safe_init_done = true;
 }