replica-identity-default-nothing.td 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 that tables with REPLICA IDENTITY DEFAULT or NOTHING will error
  11. # out the source rather than cause wrong data or panics
  12. #
  13. # IDENTITY DEFAULT is the same as USING INDEX (t1_pkey)
  14. #
  15. # TODO: Reenable when database-issues#4231 is fixed
  16. $ skip-if
  17. SELECT true
  18. > CREATE SECRET pgpass AS 'postgres'
  19. > CREATE CONNECTION pg TO POSTGRES (
  20. HOST postgres,
  21. DATABASE postgres,
  22. USER postgres,
  23. PASSWORD SECRET pgpass
  24. )
  25. $ postgres-execute connection=postgres://postgres:postgres@postgres
  26. ALTER USER postgres WITH replication;
  27. DROP SCHEMA IF EXISTS public CASCADE;
  28. DROP PUBLICATION IF EXISTS mz_source;
  29. CREATE SCHEMA public;
  30. CREATE TABLE identity_default_key_update (key_col INTEGER PRIMARY KEY, nokey_col INTEGER);
  31. ALTER TABLE identity_default_key_update REPLICA IDENTITY DEFAULT;
  32. CREATE TABLE identity_default_nokey_update (key_col INTEGER PRIMARY KEY, nokey_col INTEGER);
  33. ALTER TABLE identity_default_nokey_update REPLICA IDENTITY DEFAULT;
  34. CREATE TABLE identity_default_delete (key_col INTEGER PRIMARY KEY, nokey_col INTEGER);
  35. ALTER TABLE identity_default_delete REPLICA IDENTITY DEFAULT;
  36. CREATE TABLE identity_nothing (key_col INTEGER PRIMARY KEY, nokey_col INTEGER);
  37. ALTER TABLE identity_nothing REPLICA IDENTITY NOTHING;
  38. CREATE PUBLICATION mz_source FOR ALL TABLES;
  39. > CREATE SOURCE mz_source
  40. FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source')
  41. FOR ALL TABLES;
  42. # Make sure that the above sources are fully instantiated so that the DML statements below
  43. # are sent as actual replication events post-snapshot.
  44. > SELECT COUNT(*) FROM identity_default_key_update;
  45. 0
  46. $ postgres-execute connection=postgres://postgres:postgres@postgres
  47. INSERT INTO identity_default_key_update VALUES (1, 1);
  48. UPDATE identity_default_key_update SET key_col = 2;
  49. INSERT INTO identity_default_nokey_update VALUES (1, 1);
  50. UPDATE identity_default_nokey_update SET nokey_col = 2;
  51. INSERT INTO identity_default_delete VALUES (1, 1);
  52. DELETE FROM identity_default_delete;
  53. INSERT INTO identity_nothing VALUES (1, 1);
  54. > CREATE DEFAULT INDEX ON identity_default_key_update;
  55. > CREATE DEFAULT INDEX ON identity_default_nokey_update;
  56. > CREATE DEFAULT INDEX ON identity_default_delete;
  57. > CREATE DEFAULT INDEX ON identity_nothing;
  58. ! SELECT * FROM identity_default_key_update;
  59. contains:Old row missing from replication stream for table with OID
  60. ! SELECT * FROM identity_default_nokey_update;
  61. contains:Old row missing from replication stream for table with OID
  62. ! SELECT * FROM identity_default_delete;
  63. contains:Old row missing from replication stream for table with OID
  64. ! SELECT * FROM identity_nothing;
  65. contains:Old row missing from replication stream for table with OID