60-concurrent-insert-same.td 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 inserts into the same table
  11. #
  12. $ postgres-execute connection=postgres://postgres:postgres@postgres
  13. CREATE TABLE insert_same_table (f1 INTEGER, PRIMARY KEY (f1));
  14. ALTER TABLE insert_same_table REPLICA IDENTITY FULL;
  15. INSERT INTO insert_same_table VALUES (0);
  16. $ schema-registry-wait topic=postgres.public.insert_same_table
  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_same_table
  22. FROM KAFKA CONNECTION kafka_conn (TOPIC 'postgres.public.insert_same_table');
  23. > CREATE TABLE insert_same_table_tbl FROM SOURCE insert_same_table (REFERENCE "postgres.public.insert_same_table")
  24. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  25. ENVELOPE DEBEZIUM;
  26. $ postgres-connect name=conn1 url=postgres://postgres:postgres@postgres
  27. $ postgres-connect name=conn2 url=postgres://postgres:postgres@postgres
  28. $ postgres-execute connection=conn1
  29. BEGIN;
  30. INSERT INTO insert_same_table VALUES (1);
  31. $ postgres-execute connection=conn2
  32. BEGIN;
  33. INSERT INTO insert_same_table VALUES (2);
  34. $ postgres-execute connection=conn1
  35. INSERT INTO insert_same_table VALUES (3);
  36. COMMIT;
  37. $ postgres-execute connection=conn2
  38. INSERT INTO insert_same_table VALUES (4);
  39. COMMIT;
  40. > SELECT * FROM insert_same_table_tbl;
  41. 0
  42. 1
  43. 2
  44. 3
  45. 4