types-decimal.td 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 FOR TABLES (public.t1);
  29. > SELECT * FROM t1;
  30. 99999999999999999999 0.99999999999999999999 9999999999.9999999999 9999999999.11111
  31. -99999999999999999999 -0.99999999999999999999 -9999999999.9999999999 -9999999999.11111
  32. # Insert the same data post-snapshot
  33. $ mysql-execute name=mysql
  34. INSERT INTO t1 SELECT * FROM t1;
  35. > SELECT pg_typeof(f1), pg_typeof(f2), pg_typeof(f3), pg_typeof(f4) FROM t1 LIMIT 1;
  36. numeric numeric numeric numeric
  37. > SELECT * FROM t1;
  38. 99999999999999999999 0.99999999999999999999 9999999999.9999999999 9999999999.11111
  39. -99999999999999999999 -0.99999999999999999999 -9999999999.9999999999 -9999999999.11111
  40. 99999999999999999999 0.99999999999999999999 9999999999.9999999999 9999999999.11111
  41. -99999999999999999999 -0.99999999999999999999 -9999999999.9999999999 -9999999999.11111