types-decimal.td 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. #
  10. # Test mysql DECIMAL / NUMERIC type
  11. #
  12. > CREATE SECRET mysqlpass AS '${arg.mysql-root-password}'
  13. > CREATE CONNECTION mysqc TO MYSQL (
  14. HOST mysql,
  15. USER root,
  16. PASSWORD SECRET mysqlpass
  17. )
  18. $ mysql-connect name=mysql url=mysql://root@mysql password=${arg.mysql-root-password}
  19. # Insert data pre-snapshot
  20. # We insert values with both default precision (0) and a value of 6 where allowed
  21. $ mysql-execute name=mysql
  22. DROP DATABASE IF EXISTS public;
  23. CREATE DATABASE public;
  24. USE public;
  25. CREATE TABLE t1 (f1 DECIMAL(20, 0), f2 DECIMAL(20, 20), f3 DECIMAL(20,10), f4 NUMERIC(20,5));
  26. INSERT INTO t1 VALUES ('99999999999999999999', '0.99999999999999999999', '9999999999.9999999999', '9999999999.1111111111');
  27. INSERT INTO t1 VALUES ('-99999999999999999999', '-0.99999999999999999999', '-9999999999.9999999999', '-9999999999.1111111111');
  28. > CREATE SOURCE da FROM MYSQL CONNECTION mysqc;
  29. > CREATE TABLE t1 FROM SOURCE da (REFERENCE public.t1);
  30. > SELECT * FROM t1;
  31. 99999999999999999999 0.99999999999999999999 9999999999.9999999999 9999999999.11111
  32. -99999999999999999999 -0.99999999999999999999 -9999999999.9999999999 -9999999999.11111
  33. # Insert the same data post-snapshot
  34. $ mysql-execute name=mysql
  35. INSERT INTO t1 SELECT * FROM t1;
  36. > SELECT pg_typeof(f1), pg_typeof(f2), pg_typeof(f3), pg_typeof(f4) FROM t1 LIMIT 1;
  37. numeric numeric numeric numeric
  38. > SELECT * FROM t1;
  39. 99999999999999999999 0.99999999999999999999 9999999999.9999999999 9999999999.11111
  40. -99999999999999999999 -0.99999999999999999999 -9999999999.9999999999 -9999999999.11111
  41. 99999999999999999999 0.99999999999999999999 9999999999.9999999999 9999999999.11111
  42. -99999999999999999999 -0.99999999999999999999 -9999999999.9999999999 -9999999999.11111