Skip to content

Commit

Permalink
Fix compatibility with old versions of PostgreSQL dealing with double…
Browse files Browse the repository at this point in the history
… precision
  • Loading branch information
PierreSenellart committed Sep 4, 2024
1 parent 36c9511 commit ad50b66
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions sql/provsql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ $$ LANGUAGE SQL IMMUTABLE PARALLEL SAFE;

CREATE OR REPLACE FUNCTION epsilon() RETURNS DOUBLE PRECISION AS
$$
SELECT 0.001
SELECT CAST(0.001 AS DOUBLE PRECISION)
$$ LANGUAGE SQL IMMUTABLE PARALLEL SAFE;

CREATE OR REPLACE FUNCTION provenance_times(VARIADIC tokens uuid[])
Expand Down Expand Up @@ -688,10 +688,10 @@ BEGIN
ELSE
RAISE EXCEPTION USING MESSAGE='Cannot compute expected value for aggregation function ' || aggregation_function;
END IF;
IF prov <> gate_one() AND result <> 0. THEN
IF prov <> gate_one() AND result <> 0. AND result <> 'Infinity' AND result <> '-Infinity' THEN
result := result/probability_evaluate(prov, method, arguments);
END IF;
RETURN CAST(result AS DOUBLE PRECISION);
RETURN result;
END
$$ LANGUAGE plpgsql PARALLEL SAFE;

Expand Down
2 changes: 1 addition & 1 deletion test/sql/expected.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GROUP BY CITY;

SELECT remove_provenance('expected_result');

SELECT city, ROUND(c1::numeric,2) AS c1, ROUND(c2::numeric,2) AS c2, ROUND(s::numeric,2) AS s, ROUND(min::numeric,2) AS min, ROUND(max::numeric,2) AS max
SELECT city, ROUND(c1::numeric,2) AS c1, ROUND(c2::numeric,2) AS c2, ROUND(s::numeric,2) AS s, min, max
FROM expected_result
ORDER BY city;

Expand Down

0 comments on commit ad50b66

Please sign in to comment.