# Copyright Materialize, Inc. and contributors. All rights reserved. # # Use of this software is governed by the Business Source License # included in the LICENSE file at the root of this repository. # # As of the Change Date specified in that file, in accordance with # the Business Source License, use of this software will be governed # by the Apache License, Version 2.0. mode cockroach # Set up a scenario where a table has a non-zero since and some data written # before that since. We advance the since in response to the upper advancing, so # sleeping for a few seconds should be enough to get this data before the table # since. # # This is to test the following: # - Data is inserted (write_ts = W) # - The ct starts (as_of = A) # - The ct is read (read_ts = R) # # The as_of for the ct is selected as the first time the inputs are readable. # This means that, even under strict serializable, we could get A < W < R. (In # fact, that's exactly what happens without the sleep). But the above sets us up # to test W < A < R here. statement ok CREATE TABLE input (key INT) statement ok INSERT INTO input VALUES (1) statement ok INSERT INTO input VALUES (2) statement ok SELECT mz_unsafe.mz_sleep(3) statement ok CREATE CONTINUAL TASK ct ON INPUT input AS ( INSERT INTO ct SELECT * FROM input; ) statement ok INSERT INTO input VALUES (3) query I rowsort SELECT * FROM ct ---- 1 2 3