types-integer.td 1.6 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. $ set-sql-timeout duration=1s
  10. #
  11. # Test various variants of integer types
  12. > CREATE SECRET mysqlpass AS '${arg.mysql-root-password}'
  13. > CREATE CONNECTION mysql_conn 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. $ mysql-execute name=mysql
  20. DROP DATABASE IF EXISTS public;
  21. CREATE DATABASE public;
  22. USE public;
  23. # Insert data pre-snapshot
  24. CREATE TABLE t1 (f1 SMALLINT, f2 INTEGER, f3 BIGINT, f4 TINYINT);
  25. INSERT INTO t1 VALUES (-32768, -2147483648, -9223372036854775808, -128);
  26. INSERT INTO t1 VALUES (32767, 2147483647, 9223372036854775807, 127);
  27. > CREATE SOURCE mz_source FROM MYSQL CONNECTION mysql_conn;
  28. > CREATE TABLE t1 FROM SOURCE mz_source (REFERENCE public.t1);
  29. > SELECT COUNT(*) > 0 FROM t1;
  30. true
  31. # Insert the same data post-snapshot
  32. $ mysql-execute name=mysql
  33. INSERT INTO t1 SELECT * FROM t1;
  34. > SELECT pg_typeof(f1), pg_typeof(f2), pg_typeof(f3), pg_typeof(f4) FROM t1 LIMIT 1;
  35. smallint integer bigint smallint
  36. > SELECT * FROM t1;
  37. -32768 -2147483648 -9223372036854775808 -128
  38. 32767 2147483647 9223372036854775807 127
  39. -32768 -2147483648 -9223372036854775808 -128
  40. 32767 2147483647 9223372036854775807 127