github.com/matrixorigin/matrixone@v1.2.0/test/distributed/cases/optimistic/atomicity_1.sql (about) 1 drop table if exists atomic_table_1; 2 drop table if exists atomic_table_2; 3 drop table if exists atomic_table_3; 4 drop table if exists atomic_view_1; 5 drop table if exists atomic_view_2; 6 drop table if exists t_code_rule_2; 7 create table atomic_table_2(a bigint ,b varchar(200),c double); 8 9 -- insert into select from table 10 begin; 11 create table atomic_table_1(a bigint not null,b varchar(200),c double,primary key(a,b)); 12 insert into atomic_table_1 select 1,"gooooooge",8092.9; 13 insert into atomic_table_1 select 2,"caaaaaate",92.09; 14 commit; 15 select * from atomic_table_1; 16 17 start transaction ; 18 insert into atomic_table_2 select * from atomic_table_1; 19 select * from atomic_table_2; 20 rollback ; 21 select * from atomic_table_2; 22 begin; 23 insert into atomic_table_2 select * from atomic_table_1; 24 commit; 25 select * from atomic_table_2; 26 27 -- create view and abnormal 28 begin; 29 create view atomic_view_1 as select * from atomic_table_1; 30 insert into atomic_table_1 select 10,"eeeeee",20.3; 31 commit; 32 select * from atomic_view_1; 33 34 start transaction ; 35 insert into atomic_table_1 select 10,"eeeeee",20.3; 36 insert into atomic_table_1 select 11,"ffff",2.3; 37 commit; 38 select * from atomic_table_1; 39 select * from atomic_view_1; 40 41 begin; 42 create view atomic_view_2 as select * from atomic_table_2; 43 rollback ; 44 select * from atomic_view_2; 45 show create table atomic_view_2; 46 47 begin; 48 drop view atomic_view_2; 49 commit ; 50 drop view atomic_view_2; 51 -- load data 52 create table atomic_table_3a(col1 tinyint,col2 smallint,col3 int,clo4 bigint,col5 tinyint unsigned,col6 smallint unsigned,col7 int unsigned,col8 bigint unsigned,col9 float,col10 double,col11 varchar(255),col12 Date,col13 DateTime,col14 timestamp,col15 bool,col16 decimal(5,2),col17 text,col18 varchar(255),col19 varchar(255),col20 text,primary key(col1))partition by hash(col1)partitions 4; 53 -- @bvt:issue#5941 54 begin; 55 load data infile '$resources/external_table_file/pt_table_data.csv' into table atomic_table_3a fields terminated by ','; 56 select col1,col2 from atomic_table_3a; 57 update atomic_table_3a set col1=400; 58 rollback; 59 select col1 from atomic_table_3a; 60 -- @bvt:issue 61 62 -- @bvt:issue#5941 63 start transaction ; 64 load data infile '$resources/external_table_file/pt_table_data.csv' into table atomic_table_3a fields terminated by ','; 65 select count(*) from atomic_table_3a; 66 update atomic_table_3a set col1=100; 67 commit; 68 select col1 from atomic_table_3a; 69 -- @bvt:issue 70 71 create table atomic_table_3(col1 tinyint,col2 smallint,col3 int,clo4 bigint,col5 tinyint unsigned,col6 smallint unsigned,col7 int unsigned,col8 bigint unsigned,col9 float,col10 double,col11 varchar(255),col12 Date,col13 DateTime,col14 timestamp,col15 bool,col16 decimal(5,2),col17 text,col18 varchar(255),col19 varchar(255),col20 text,primary key(col1))partition by hash(col1)partitions 4; 72 load data infile '$resources/external_table_file/pt_table_data.csv' into table atomic_table_3 fields terminated by ','; 73 start transaction ; 74 update atomic_table_3 set col2=20; 75 select col1,col2 from atomic_table_3; 76 show create table atomic_table_3; 77 rollback ; 78 select col1,col2 from atomic_table_3; 79 80 -- create external/TEMPORARY table 81 begin; 82 create external table atomic_ex_table(num_col1 tinyint,num_col2 smallint,num_col3 int,num_col4 bigint,num_col5 tinyint unsigned,num_col6 smallint unsigned,num_col7 int unsigned,num_col8 bigint unsigned ,num_col9 float(5,3),num_col10 double(6,5),num_col11 decimal(38,19)) infile{"filepath"='$resources/external_table_file/ex_table_number.csv'} fields terminated by ',' enclosed by '\"' lines terminated by '\n'; 83 select num_col1 from atomic_ex_table; 84 rollback ; 85 select num_col1 from atomic_ex_table; 86 show create table atomic_ex_table; 87 desc atomic_ex_table; 88 89 -- @bvt:issue#9124 90 create TEMPORARY TABLE atomic_temp(a int); 91 begin; 92 insert into atomic_temp values (5); 93 rollback ; 94 select * from atomic_temp; 95 drop table atomic_temp; 96 97 start transaction ; 98 create TEMPORARY TABLE atomic_temp(a int); 99 insert into atomic_temp values (5); 100 select * from atomic_temp; 101 rollback ; 102 select * from atomic_temp; 103 show create table atomic_temp; 104 105 start transaction ; 106 create TEMPORARY TABLE atomic_temp(a int); 107 insert into atomic_temp values (5); 108 commit ; 109 select * from atomic_temp; 110 -- @bvt:issue 111 112 CREATE TABLE `t_code_rule` ( 113 `code_id` bigint(20) NOT NULL AUTO_INCREMENT, 114 `code_no` varchar(50) NOT NULL, 115 `org_no` varchar(50) NOT NULL, 116 `org_name` varchar(50) NOT NULL, 117 `code_type` int(11) NOT NULL DEFAULT '0', 118 PRIMARY KEY (`code_id`), 119 UNIQUE KEY `code_type` (`code_type`), 120 KEY `code_no` (`code_no`), 121 KEY `org_no` (`org_no`) 122 ); 123 -- @bvt:issue#6949 124 start transaction ; 125 insert into t_code_rule values (18373453,'aaaaaa','fffff','ccccc',10); 126 insert into t_code_rule values (18373453,'aaaaaa','fffff','ccccc',20); 127 commit ; 128 select * from t_code_rule; 129 -- @bvt:issue 130 131 begin; 132 -- @bvt:issue#7133 133 insert into t_code_rule values (18373453,'aaaaaa','fffff','ccccc',5); 134 delete from t_code_rule where code_id=18373453; 135 select * from t_code_rule; 136 -- @bvt:issue 137 rollback ; 138 select * from t_code_rule; 139 140 insert into t_code_rule values (18373453,'aaaaaa','fffff','ccccc',5); 141 begin ; 142 -- @bvt:issue#7133 143 delete from t_code_rule where code_id=18373453; 144 commit ; 145 146 begin; 147 insert into t_code_rule(code_no,org_no,org_name,code_type) values ('',null,'ccccc',5); 148 commit ; 149 select * from t_code_rule; 150 151 insert into t_code_rule values (18373453,'aaaaaa','fffff','ccccc',5); 152 begin; 153 update t_code_rule set org_name=NULL where code_id=18373453; 154 commit ; 155 select * from t_code_rule; 156 -- @bvt:issue 157 158 --anormal transaction sql 159 begin ; 160 create account aname admin_name 'admin' identified by '111'; 161 create role role1,role2; 162 grant role1 to role2; 163 grant create table ,drop table on database * to role1; 164 truncate table t_code_rule; 165 drop table t_code_rule; 166 drop database atomic_1; 167 drop role role1,role2; 168 commit; 169 170 171 172 173 174 175 176 177 178 179 180