fetch-timeout.td 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. # Check that the timeout value is indeed respected and sleeping happens
  11. # if no rows are available to satify the FETCH immediately
  12. #
  13. #
  14. # FETCH + SUBSCRIBE - sleep happens
  15. #
  16. > CREATE TABLE t1 (f1 INTEGER);
  17. > CREATE TABLE ts_log (ts TIMESTAMP);
  18. > INSERT INTO ts_log VALUES (NOW());
  19. > BEGIN
  20. > DECLARE c CURSOR FOR SUBSCRIBE t1;
  21. > FETCH 1 c WITH (timeout='1.1s');
  22. > COMMIT;
  23. > INSERT INTO ts_log VALUES (NOW());
  24. > SELECT MAX(ts) - MIN(ts) > interval '1 second' FROM ts_log;
  25. true
  26. > DROP TABLE ts_log;
  27. #
  28. # FETCH + SELECT - timeout not observed, sleep does not happen
  29. #
  30. > BEGIN
  31. > DECLARE c CURSOR FOR SELECT * FROM t1;
  32. > FETCH 1 c WITH (timeout='1d');