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

     1  # LogicTest: !3node-tenant
     2  # This test exercises the presence of an explanatory hint when a transaction
     3  # ends up partially committed and partially aborted.
     4  
     5  statement ok
     6  CREATE TABLE t (x INT); INSERT INTO t (x) VALUES (0);
     7  
     8  statement ok
     9  BEGIN
    10  
    11  statement ok
    12  ALTER TABLE t ADD COLUMN z INT DEFAULT 123
    13  
    14  statement ok
    15  INSERT INTO t (x) VALUES (1)
    16  
    17  statement ok
    18  ALTER TABLE t ADD COLUMN y FLOAT AS (1::FLOAT / x::FLOAT) STORED
    19  
    20  statement error pgcode XXA00 division by zero.*\nHINT:.*\nManual inspection may be required
    21  COMMIT
    22  
    23  # Verify that the txn was indeed partially committed: the INSERT succeeded.
    24  query I rowsort
    25  SELECT * FROM t
    26  ----
    27  0
    28  1
    29  
    30  # Verify that the txn was indeed partially aborted: the first ALTER failed.
    31  query TT
    32  SHOW CREATE t
    33  ----
    34  t  CREATE TABLE t (
    35     x INT8 NULL,
    36     FAMILY "primary" (x, rowid)
    37  )