types-integer.td 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 various variants of integer types
  11. > CREATE SECRET pgpass AS 'postgres'
  12. > CREATE CONNECTION pg TO POSTGRES (
  13. HOST postgres,
  14. DATABASE postgres,
  15. USER postgres,
  16. PASSWORD SECRET pgpass
  17. )
  18. # Insert data pre-snapshot
  19. $ postgres-execute connection=postgres://postgres:postgres@postgres
  20. ALTER USER postgres WITH replication;
  21. DROP SCHEMA IF EXISTS public CASCADE;
  22. DROP PUBLICATION IF EXISTS mz_source;
  23. CREATE SCHEMA public;
  24. CREATE TABLE t1 (f1 SMALLINT, f2 INTEGER, f3 BIGINT, f4 _int4, f5 int2);
  25. ALTER TABLE t1 REPLICA IDENTITY FULL;
  26. INSERT INTO t1 VALUES (-32768, -2147483648, -9223372036854775808, null, 0);
  27. INSERT INTO t1 VALUES (32767, 2147483647, 9223372036854775807, null, 1);
  28. CREATE PUBLICATION mz_source FOR ALL TABLES;
  29. > CREATE SOURCE mz_source
  30. FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source')
  31. FOR ALL TABLES;
  32. > SELECT COUNT(*) > 0 FROM t1;
  33. true
  34. # Insert the same data post-snapshot
  35. $ postgres-execute connection=postgres://postgres:postgres@postgres
  36. INSERT INTO t1 SELECT * FROM t1;
  37. > SELECT pg_typeof(f1), pg_typeof(f2), pg_typeof(f3), pg_typeof(f4), pg_typeof(f5) FROM t1 LIMIT 1;
  38. smallint integer bigint integer[] smallint
  39. > SELECT * FROM t1;
  40. -32768 -2147483648 -9223372036854775808 <null> 0
  41. 32767 2147483647 9223372036854775807 <null> 1
  42. -32768 -2147483648 -9223372036854775808 <null> 0
  43. 32767 2147483647 9223372036854775807 <null> 1