cursor.slt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. mode cockroach
  10. statement ok
  11. BEGIN
  12. statement ok
  13. DECLARE c CURSOR FOR VALUES (1), (2), (3)
  14. query I
  15. FETCH c
  16. ----
  17. 1
  18. query I
  19. FETCH 2 c
  20. ----
  21. 2
  22. 3
  23. query I
  24. FETCH c
  25. ----
  26. query I
  27. FETCH c
  28. ----
  29. statement ok
  30. COMMIT
  31. statement ok
  32. CREATE VIEW v AS VALUES ('a', 'b'), ('c', 'd'), ('e', 'f'), ('g', 'h')
  33. ----
  34. query IITT
  35. SUBSCRIBE v
  36. ----
  37. 18446744073709551615 1 a b
  38. 18446744073709551615 1 c d
  39. 18446744073709551615 1 e f
  40. 18446744073709551615 1 g h
  41. statement ok
  42. BEGIN
  43. statement ok
  44. DECLARE c CURSOR FOR SUBSCRIBE v
  45. query IITT
  46. FETCH c
  47. ----
  48. 18446744073709551615 1 a b
  49. query IITT
  50. FETCH 2 c WITH (TIMEOUT = '10s')
  51. ----
  52. 18446744073709551615 1 c d
  53. 18446744073709551615 1 e f
  54. query IITT
  55. FETCH 2 c WITH (TIMEOUT = '1s')
  56. ----
  57. 18446744073709551615 1 g h
  58. query IITT
  59. FETCH c WITH (TIMEOUT = '1s')
  60. ----
  61. # Test some FETCH timeout errors. The actual timeout functionality is
  62. # tested elsewhere.
  63. statement error invalid TIMEOUT: cannot convert negative interval to duration
  64. FETCH c WITH (TIMEOUT = '-1s')
  65. statement ok
  66. ROLLBACK
  67. statement ok
  68. BEGIN
  69. statement ok
  70. DECLARE c CURSOR FOR SUBSCRIBE v
  71. statement error timeout out of range
  72. FETCH c WITH (TIMEOUT = '25h')