
CREATE TABLE test_numeric_mul_rscale
(
    var1 numeric,
    var2 numeric,
    rscale_adjustment integer,
    expected numeric
);

\copy test_numeric_mul_rscale from test_numeric_mul_rscale.dump;

\x on

SELECT
    *,
    numeric_mul_rscale - expected AS diff
FROM
    test_numeric_mul_rscale,
    numeric_mul_rscale(var1, var2, rscale_adjustment)
WHERE numeric_mul_rscale IS DISTINCT FROM expected
ORDER BY rscale_adjustment DESC
LIMIT 1;

\x off

SELECT
    to_char(numeric_mul_rscale - expected,'0.000EEEE') AS diff,
    COUNT(*)
FROM
    test_numeric_mul_rscale,
    numeric_mul_rscale(var1, var2, rscale_adjustment)
GROUP BY diff
ORDER BY diff;
