70-insert-delete.td 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. # INSERT + DELETE in same transaction should not be visible to Mz
  11. #
  12. $ postgres-execute connection=postgres://postgres:postgres@postgres
  13. CREATE TABLE insert_delete (f1 INTEGER, PRIMARY KEY (f1));
  14. ALTER TABLE insert_delete REPLICA IDENTITY FULL;
  15. INSERT INTO insert_delete VALUES (1);
  16. $ schema-registry-wait topic=postgres.public.insert_delete
  17. > CREATE CONNECTION IF NOT EXISTS csr_conn TO CONFLUENT SCHEMA REGISTRY (
  18. URL '${testdrive.schema-registry-url}'
  19. );
  20. > CREATE CONNECTION IF NOT EXISTS kafka_conn TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  21. > CREATE SOURCE insert_delete
  22. FROM KAFKA CONNECTION kafka_conn (TOPIC 'postgres.public.insert_delete');
  23. > CREATE TABLE insert_delete_tbl FROM SOURCE insert_delete (REFERENCE "postgres.public.insert_delete")
  24. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  25. ENVELOPE DEBEZIUM;
  26. $ postgres-execute connection=postgres://postgres:postgres@postgres
  27. BEGIN;
  28. INSERT INTO insert_delete VALUES (2);
  29. DELETE FROM insert_delete WHERE f1 = 2;
  30. COMMIT;
  31. > SELECT * FROM insert_delete_tbl;
  32. 1