64-concurrent-delete-same.td 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. # Concurrent deletes over the same table
  11. #
  12. $ postgres-execute connection=postgres://postgres:postgres@postgres
  13. CREATE TABLE concurrent_delete (f1 INTEGER, PRIMARY KEY (f1));
  14. ALTER TABLE concurrent_delete REPLICA IDENTITY FULL;
  15. INSERT INTO concurrent_delete VALUES (1);
  16. INSERT INTO concurrent_delete VALUES (2);
  17. INSERT INTO concurrent_delete VALUES (3);
  18. INSERT INTO concurrent_delete VALUES (4);
  19. INSERT INTO concurrent_delete VALUES (5);
  20. INSERT INTO concurrent_delete VALUES (6);
  21. $ schema-registry-wait topic=postgres.public.concurrent_delete
  22. > CREATE CONNECTION IF NOT EXISTS csr_conn TO CONFLUENT SCHEMA REGISTRY (
  23. URL '${testdrive.schema-registry-url}'
  24. );
  25. > CREATE CONNECTION IF NOT EXISTS kafka_conn TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  26. > CREATE SOURCE concurrent_delete
  27. FROM KAFKA CONNECTION kafka_conn (TOPIC 'postgres.public.concurrent_delete');
  28. > CREATE TABLE concurrent_delete_tbl FROM SOURCE concurrent_delete (REFERENCE "postgres.public.concurrent_delete")
  29. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  30. ENVELOPE DEBEZIUM;
  31. $ postgres-connect name=conn1 url=postgres://postgres:postgres@postgres
  32. $ postgres-connect name=conn2 url=postgres://postgres:postgres@postgres
  33. $ postgres-execute connection=conn1
  34. BEGIN;
  35. DELETE FROM concurrent_delete WHERE f1 = 2;
  36. $ postgres-execute connection=conn2
  37. BEGIN;
  38. DELETE FROM concurrent_delete WHERE f1 = 3;
  39. $ postgres-execute connection=conn1
  40. DELETE FROM concurrent_delete WHERE f1 = 4;
  41. COMMIT;
  42. $ postgres-execute connection=conn2
  43. DELETE FROM concurrent_delete WHERE f1 = 5;
  44. COMMIT;
  45. > SELECT * FROM concurrent_delete_tbl;
  46. 1
  47. 6