ct_snapshot.slt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. # Set up a scenario where a table has a non-zero since and some data written
  11. # before that since. We advance the since in response to the upper advancing, so
  12. # sleeping for a few seconds should be enough to get this data before the table
  13. # since.
  14. #
  15. # This is to test the following:
  16. # - Data is inserted (write_ts = W)
  17. # - The ct starts (as_of = A)
  18. # - The ct is read (read_ts = R)
  19. #
  20. # The as_of for the ct is selected as the first time the inputs are readable.
  21. # This means that, even under strict serializable, we could get A < W < R. (In
  22. # fact, that's exactly what happens without the sleep). But the above sets us up
  23. # to test W < A < R here.
  24. statement ok
  25. CREATE TABLE input (key INT)
  26. statement ok
  27. INSERT INTO input VALUES (1)
  28. statement ok
  29. INSERT INTO input VALUES (2)
  30. statement ok
  31. SELECT mz_unsafe.mz_sleep(3)
  32. statement ok
  33. CREATE CONTINUAL TASK ct ON INPUT input AS (
  34. INSERT INTO ct SELECT * FROM input;
  35. )
  36. statement ok
  37. INSERT INTO input VALUES (3)
  38. query I rowsort
  39. SELECT * FROM ct
  40. ----
  41. 1
  42. 2
  43. 3