61-concurrent-insert-multi.td 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 multiple tables. Each transaction operates on
  11. # two separate tables.
  12. #
  13. $ postgres-execute connection=postgres://postgres:postgres@postgres
  14. CREATE TABLE insert_multi_table1 (f1 INTEGER, PRIMARY KEY (f1));
  15. ALTER TABLE insert_multi_table1 REPLICA IDENTITY FULL;
  16. INSERT INTO insert_multi_table1 VALUES (0);
  17. CREATE TABLE insert_multi_table2 (f1 INTEGER, PRIMARY KEY (f1));
  18. ALTER TABLE insert_multi_table2 REPLICA IDENTITY FULL;
  19. INSERT INTO insert_multi_table2 VALUES (0);
  20. $ schema-registry-wait topic=postgres.public.insert_multi_table1
  21. $ schema-registry-wait topic=postgres.public.insert_multi_table2
  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 insert_multi_table1
  27. FROM KAFKA CONNECTION kafka_conn (TOPIC 'postgres.public.insert_multi_table1');
  28. > CREATE TABLE insert_multi_table1_tbl FROM SOURCE insert_multi_table1 (REFERENCE "postgres.public.insert_multi_table1")
  29. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  30. ENVELOPE DEBEZIUM;
  31. > CREATE SOURCE insert_multi_table2
  32. FROM KAFKA CONNECTION kafka_conn (TOPIC 'postgres.public.insert_multi_table2');
  33. > CREATE TABLE insert_multi_table2_tbl FROM SOURCE insert_multi_table2 (REFERENCE "postgres.public.insert_multi_table2")
  34. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  35. ENVELOPE DEBEZIUM;
  36. $ postgres-connect name=conn1 url=postgres://postgres:postgres@postgres
  37. $ postgres-connect name=conn2 url=postgres://postgres:postgres@postgres
  38. $ postgres-execute connection=conn1
  39. BEGIN;
  40. INSERT INTO insert_multi_table1 VALUES (1);
  41. $ postgres-execute connection=conn2
  42. BEGIN;
  43. INSERT INTO insert_multi_table2 VALUES (2);
  44. $ postgres-execute connection=conn1
  45. INSERT INTO insert_multi_table1 VALUES (3);
  46. COMMIT;
  47. $ postgres-execute connection=conn2
  48. INSERT INTO insert_multi_table2 VALUES (4);
  49. COMMIT;
  50. > SELECT * FROM insert_multi_table1_tbl;
  51. 0
  52. 1
  53. 3
  54. > SELECT * FROM insert_multi_table2_tbl;
  55. 0
  56. 2
  57. 4