CREATE TABLE test_numeric_mul_rscale
(
    var1ndigits integer,
    var2ndigits integer,
    var1dscale integer,
    var2dscale integer,
    rscale_adjustment integer,
    var1 numeric,
    var2 numeric,
    expected numeric
);

\copy test_numeric_mul_rscale (var1ndigits,var2ndigits,var1dscale,var2dscale,rscale_adjustment) from plausible_rscale_adjustments.csv with csv;

SELECT setseed(0);

UPDATE test_numeric_mul_rscale SET
    var1 = round(random(
        format('1%s',repeat('0',(var1ndigits-1)*4-1))::numeric,
        format('%s',repeat('9',var1ndigits*4))::numeric
    ) / 10::numeric^var1dscale, var1dscale),
    var2 = round(random(
        format('1%s',repeat('0',(var2ndigits-1)*4-1))::numeric,
        format('%s',repeat('9',var2ndigits*4))::numeric
    ) / 10::numeric^var2dscale, var2dscale);

UPDATE test_numeric_mul_rscale SET
    expected = numeric_mul_rscale(var1, var2, rscale_adjustment);

\copy test_numeric_mul_rscale to test_numeric_mul_rscale.dump;
