strong_session_serializable.slt 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. simple conn=mz_system,user=mz_system
  11. ALTER SYSTEM SET enable_session_timelines = true;
  12. ----
  13. COMPLETE 0
  14. # Use explicit conn names to guarantee that the same session is used for all queries.
  15. simple conn=materialize,user=materialize
  16. SET TRANSACTION_ISOLATION TO "strong session serializable";
  17. ----
  18. COMPLETE 0
  19. simple conn=materialize,user=materialize
  20. CREATE CLUSTER stuck SIZE '1';
  21. ----
  22. COMPLETE 0
  23. # TODO(jkosh44) Read mz_clusters once DDL is working
  24. simple conn=materialize,user=materialize
  25. CREATE TABLE t (a INT);
  26. ----
  27. COMPLETE 0
  28. # TODO(jkosh44) Read mz_tables once DDL is working
  29. simple conn=materialize,user=materialize
  30. CREATE MATERIALIZED VIEW mv IN CLUSTER stuck AS SELECT SUM(a) FROM t;
  31. ----
  32. COMPLETE 0
  33. # TODO(jkosh44) Read mz_materialized_views once DDL is working
  34. simple conn=materialize,user=materialize
  35. INSERT INTO t VALUES (1);
  36. ----
  37. COMPLETE 1
  38. simple conn=materialize,user=materialize
  39. SELECT * FROM mv;
  40. ----
  41. 1
  42. COMPLETE 1
  43. simple conn=materialize,user=materialize
  44. INSERT INTO t VALUES (1);
  45. ----
  46. COMPLETE 1
  47. simple conn=materialize,user=materialize
  48. SELECT * FROM mv
  49. ----
  50. 2
  51. COMPLETE 1
  52. simple conn=materialize,user=materialize
  53. ALTER CLUSTER stuck SET (REPLICATION FACTOR = 0);
  54. ----
  55. COMPLETE 0
  56. simple conn=materialize,user=materialize
  57. SELECT * FROM mv;
  58. ----
  59. 2
  60. COMPLETE 1
  61. simple conn=materialize,user=materialize
  62. INSERT INTO t VALUES (1);
  63. ----
  64. COMPLETE 1
  65. # TODO(jkosh44) It would be nice to assert that a SELECT would block indefinitely.
  66. simple conn=materialize,user=materialize
  67. ALTER CLUSTER stuck SET (REPLICATION FACTOR = 1);
  68. ----
  69. COMPLETE 0
  70. simple conn=materialize,user=materialize
  71. SELECT * FROM mv;
  72. ----
  73. 3
  74. COMPLETE 1
  75. # Test that reading from a constant materialized view doesn't send our session timeline too far
  76. # into the future.
  77. simple conn=materialize,user=materialize
  78. CREATE MATERIALIZED VIEW const_mv AS SELECT 1;
  79. ----
  80. COMPLETE 0
  81. simple conn=materialize,user=materialize
  82. SELECT * FROM const_mv;
  83. ----
  84. 1
  85. COMPLETE 1
  86. simple conn=materialize,user=materialize
  87. SELECT * FROM mv;
  88. ----
  89. 3
  90. COMPLETE 1
  91. # Test that reading from a constant materialized view with a temporal filter doesn't send our
  92. # session timeline too far into the future.
  93. # This test will break in the year 10000. Please update the year 10000 in the view days to a much
  94. # larger year.
  95. simple conn=materialize,user=materialize
  96. CREATE VIEW days AS
  97. SELECT generate_series(
  98. CAST('1970-08-06' AS timestamp),
  99. CAST('1970-08-07' AS timestamp),
  100. CAST('1 day' AS interval)
  101. ) AS day
  102. UNION ALL
  103. SELECT generate_series(
  104. CAST('10000-08-06' AS timestamp),
  105. CAST('10000-08-07' AS timestamp),
  106. CAST('1 day' AS interval)
  107. ) AS day;
  108. ----
  109. COMPLETE 0
  110. simple conn=materialize,user=materialize
  111. CREATE MATERIALIZED VIEW days_mv AS SELECT day FROM days WHERE mz_now() <= day;
  112. ----
  113. COMPLETE 0
  114. simple conn=materialize,user=materialize
  115. SELECT * FROM days_mv;
  116. ----
  117. 10000-08-06 00:00:00
  118. 10000-08-07 00:00:00
  119. COMPLETE 2
  120. simple conn=materialize,user=materialize
  121. SELECT * FROM mv;
  122. ----
  123. 3
  124. COMPLETE 1