replica-identity-default-nothing.td 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source');
  40. > CREATE TABLE identity_default_key_update FROM SOURCE mz_source (REFERENCE identity_default_key_update);
  41. > CREATE TABLE identity_default_nokey_update FROM SOURCE mz_source (REFERENCE identity_default_nokey_update);
  42. > CREATE TABLE identity_default_delete FROM SOURCE mz_source (REFERENCE identity_default_delete);
  43. > CREATE TABLE identity_nothing FROM SOURCE mz_source (REFERENCE identity_nothing);
  44. # Make sure that the above sources are fully instantiated so that the DML statements below
  45. # are sent as actual replication events post-snapshot.
  46. > SELECT COUNT(*) FROM identity_default_key_update;
  47. 0
  48. $ postgres-execute connection=postgres://postgres:postgres@postgres
  49. INSERT INTO identity_default_key_update VALUES (1, 1);
  50. UPDATE identity_default_key_update SET key_col = 2;
  51. INSERT INTO identity_default_nokey_update VALUES (1, 1);
  52. UPDATE identity_default_nokey_update SET nokey_col = 2;
  53. INSERT INTO identity_default_delete VALUES (1, 1);
  54. DELETE FROM identity_default_delete;
  55. INSERT INTO identity_nothing VALUES (1, 1);
  56. > CREATE DEFAULT INDEX ON identity_default_key_update;
  57. > CREATE DEFAULT INDEX ON identity_default_nokey_update;
  58. > CREATE DEFAULT INDEX ON identity_default_delete;
  59. > CREATE DEFAULT INDEX ON identity_nothing;
  60. ! SELECT * FROM identity_default_key_update;
  61. contains:Old row missing from replication stream for table with OID
  62. ! SELECT * FROM identity_default_nokey_update;
  63. contains:Old row missing from replication stream for table with OID
  64. ! SELECT * FROM identity_default_delete;
  65. contains:Old row missing from replication stream for table with OID
  66. ! SELECT * FROM identity_nothing;
  67. contains:Old row missing from replication stream for table with OID