cancel-subscribe.td 945 B

123456789101112131415161718192021222324252627282930313233
  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. $ set-regex match=\d{13,20} replacement=<TIMESTAMP>
  10. $ postgres-connect name=mz2 url=postgres://materialize@${testdrive.materialize-sql-addr}
  11. > DROP TABLE IF EXISTS t
  12. > CREATE TABLE t (c int);
  13. $ set-from-sql var=backend-pid
  14. SELECT CAST(pg_backend_pid() AS text);
  15. > BEGIN
  16. > DECLARE c CURSOR FOR SUBSCRIBE (SELECT * FROM t)
  17. $ postgres-execute connection=mz2
  18. INSERT INTO t VALUES (1);
  19. > FETCH 1 c
  20. <TIMESTAMP> 1 1
  21. $ postgres-execute connection=mz2
  22. SELECT pg_cancel_backend(CAST(${backend-pid} AS int4));
  23. ! FETCH 1 c
  24. contains:canceling statement due to user request