From 5597fee8d701bc8f3cb859ff935699ef6ce08b31 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 24 Nov 2004 18:47:38 +0000 Subject: [PATCH] Avoid getting bit by roundoff error while checking $Safe::VERSION. Per report from Mark Kirkwood. --- src/pl/plperl/plperl.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c index ef5b35dbac..20364d27da 100644 --- a/src/pl/plperl/plperl.c +++ b/src/pl/plperl/plperl.c @@ -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; }