
SELECT setseed(0);
CREATE TABLE n_10 AS
  SELECT random(1e10,9e10) var1,
         random(1e10,9e10) var2
  FROM generate_series(1, 1e8);

CREATE TABLE n_100 AS
  SELECT random(1e100,9e100) var1,
         random(1e100,9e100) var2
  FROM generate_series(1, 1e7);

CREATE TABLE n_1000 AS
  SELECT random(1e1000,9e1000) var1,
         random(1e1000,9e1000) var2
  FROM generate_series(1, 1e6);

CREATE TABLE n_mixed AS
WITH x AS (
    SELECT
        random(1,16384) AS var1ndigits,
        random(1,16384) AS var2ndigits,
        random(0,16384) AS var1dscale,
        random(0,16384) AS var2dscale
    FROM generate_series(1, 10000)
)
SELECT
    round(random(
        format('1%s',repeat('0',(var1ndigits-1)*4-1))::numeric,
        format('%s',repeat('9',var1ndigits*4))::numeric
    ) / 10::numeric^var1dscale, var1dscale)
    * CASE WHEN random() > 0.5 THEN 1::numeric ELSE -1::numeric END
    AS var1,
    round(random(
        format('1%s',repeat('0',(var2ndigits-1)*4-1))::numeric,
        format('%s',repeat('9',var2ndigits*4))::numeric
    ) / 10::numeric^var2dscale, var2dscale)
    * CASE WHEN random() > 0.5 THEN 1::numeric ELSE -1::numeric END
    AS var2
FROM x;

CREATE TABLE n_max AS
  SELECT random(1e65534,9e65534) var1,
         random(1e65534,9e65534) var2
  FROM generate_series(1, 100);

ALTER TABLE n_10 ADD product numeric;
ALTER TABLE n_100 ADD product numeric;
ALTER TABLE n_1000 ADD product numeric;
ALTER TABLE n_mixed ADD product numeric;
ALTER TABLE n_max ADD product numeric;

UPDATE n_10 SET product = var1 * var2;
UPDATE n_100 SET product = var1 * var2;
UPDATE n_1000 SET product = var1 * var2;
UPDATE n_mixed SET product = var1 * var2;
UPDATE n_max SET product = var1 * var2;
