github.com/matrixorigin/matrixone@v1.2.0/test/distributed/cases/optimistic/rollback_stmt.sql (about)

     1  drop database if exists rollbacktest;
     2  create database rollbacktest;
     3  
     4  set @@autocommit = 1;
     5  create table t1(a int primary key );
     6  --no error
     7  insert into t1 values(1);
     8  --error. duplicate key
     9  insert into t1 values(1);
    10  --1
    11  select * from t1;
    12  
    13  begin;
    14  delete from t1 where a = 1;
    15  --no error
    16  insert into t1 values(1);
    17  --no error? why? workspace does check duplicate key?
    18  insert into t1 values(1);
    19  --1
    20  --1
    21  select * from t1;
    22  
    23  --no error
    24  insert into t1 values(2);
    25  --no error? why? workspace does check duplicate key?
    26  insert into t1 values(2);
    27  
    28  --1
    29  --1
    30  --2
    31  --2
    32  select * from t1;
    33  --no error
    34  insert into t1 values(3);
    35  --no error
    36  delete from t1 where a = 3;
    37  --error. no column b in t1
    38  delete from t1 where b = 3;
    39  --no error
    40  insert into t1 values(3);
    41  --error. duplicate key
    42  update t1 set a = 2;
    43  ----------------
    44  --why not error?
    45  ----------------
    46  commit ;
    47  --1
    48  --1
    49  --2
    50  --2
    51  --3
    52  select * from t1;
    53  
    54  --issue 13678
    55  create table if not exists t2( id int primary key );
    56  insert into t2 values(1);
    57  select * from t2;
    58  
    59  set autocommit = 1;
    60  begin;
    61  --no error
    62  insert into t2 values(2);
    63  --1
    64  --2
    65  select * from t2;
    66  --no error? why? workspace does check duplicate key?
    67  insert into t2 values(1);
    68  --1
    69  --1
    70  --2
    71  select * from t2;
    72  --duplicate key
    73  commit;
    74  --1
    75  select * from t2;
    76  
    77  drop table t1;
    78  drop table t2;
    79  drop database if exists rollbacktest;