github.com/matrixorigin/matrixone@v0.7.0/test/distributed/cases/transaction/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; 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; 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; 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 create TEMPORARY TABLE atomic_temp(a int); 90 begin; 91 insert into atomic_temp values (5); 92 rollback ; 93 select * from atomic_temp; 94 drop table atomic_temp; 95 96 start transaction ; 97 create TEMPORARY TABLE atomic_temp(a int); 98 insert into atomic_temp values (5); 99 select * from atomic_temp; 100 rollback ; 101 select * from atomic_temp; 102 show create table atomic_temp; 103 104 start transaction ; 105 create TEMPORARY TABLE atomic_temp(a int); 106 insert into atomic_temp values (5); 107 commit ; 108 select * from atomic_temp; 109 110 CREATE TABLE `t_code_rule` ( 111 `code_id` bigint(20) NOT NULL AUTO_INCREMENT, 112 `code_no` varchar(50) NOT NULL, 113 `org_no` varchar(50) NOT NULL, 114 `org_name` varchar(50) NOT NULL, 115 `code_type` int(11) NOT NULL DEFAULT '0', 116 PRIMARY KEY (`code_id`), 117 UNIQUE KEY `code_type` (`code_type`), 118 KEY `code_no` (`code_no`), 119 KEY `org_no` (`org_no`) 120 ); 121 start transaction ; 122 insert into t_code_rule values (18373453,'aaaaaa','fffff','ccccc',10); 123 insert into t_code_rule values (18373453,'aaaaaa','fffff','ccccc',20); 124 commit ; 125 select * from t_code_rule; 126 127 begin; 128 -- @bvt:issue#7133 129 insert into t_code_rule values (18373453,'aaaaaa','fffff','ccccc',5); 130 delete from t_code_rule where code_id=18373453; 131 select * from t_code_rule; 132 -- @bvt:issue 133 rollback ; 134 select * from t_code_rule; 135 136 insert into t_code_rule values (18373453,'aaaaaa','fffff','ccccc',5); 137 begin ; 138 -- @bvt:issue#7133 139 delete from t_code_rule where code_id=18373453; 140 commit ; 141 142 begin; 143 insert into t_code_rule(code_no,org_no,org_name,code_type) values ('',null,'ccccc',5); 144 commit ; 145 select * from t_code_rule; 146 147 insert into t_code_rule values (18373453,'aaaaaa','fffff','ccccc',5); 148 begin; 149 update t_code_rule set org_name=NULL where code_id=18373453; 150 commit ; 151 select * from t_code_rule; 152 -- @bvt:issue 153 154 --anormal transaction sql 155 begin ; 156 create account aname admin_name 'admin' identified by '111'; 157 create role role1,role2; 158 grant role1 to role2; 159 grant create table ,drop table on database * to role1; 160 truncate table t_code_rule; 161 drop table t_code_rule; 162 drop database atomic_1; 163 drop role role1,role2; 164 commit; 165 166 167 168 169 170 171 172 173 174 175 176