github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/logictest/testdata/logic_test/sequences_distsql (about)

     1  # Test that sequence functions work in DistSQL queries.
     2  
     3  statement ok
     4  CREATE TABLE t (c int PRIMARY KEY)
     5  
     6  statement ok
     7  INSERT INTO t VALUES (1)
     8  
     9  statement ok
    10  CREATE SEQUENCE distsql_test START WITH 10
    11  
    12  statement error pgcode 55000 pq: lastval\(\): lastval is not yet defined in this session
    13  SELECT lastval()
    14  
    15  # TODO(andrei): this error we get sometimes has a prefix of "lastval()" (as above), sometimes doesn't.
    16  # I couldn't figure out where the difference in prefix comes from. The regex
    17  # ignores it.
    18  statement error pgcode 55000 pq: .*lastval is not yet defined in this session
    19  SELECT c, lastval() from t
    20  
    21  query I
    22  SELECT nextval('distsql_test')
    23  ----
    24  10
    25  
    26  query II
    27  SELECT c, lastval() FROM t
    28  ----
    29  1 10
    30  
    31  query II
    32  SELECT c, currval('distsql_test') FROM t
    33  ----
    34  1 10