Files
oceanbase/test/mysql_test/test_suite/trx/t/pg_trans.test
oceanbase-admin cea7de1475 init push
2021-05-31 22:56:52 +08:00

194 lines
5.6 KiB
Plaintext

--disable_query_log
set @@session.explicit_defaults_for_timestamp=off;
--enable_query_log
connect (obsys,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connect (conn1,$OBMYSQL_MS0,$OBMYSQL_USR,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connection obsys;
##修改配置
--disable_abort_on_error
connection conn1;
use test;
--disable_warnings
drop table if exists pg_trans_test;
--enable_warnings
#############非分区表##########
create tablegroup tg1 binding true;
create table pg_trans_test1_1(id1 int, id2 int) tablegroup tg1;
create table pg_trans_test1_2(id1 int, id2 int) tablegroup tg1;
create index i1 on pg_trans_test1_1(id2) local;
desc pg_trans_test1_1;
desc pg_trans_test1_2;
insert into pg_trans_test1_1 values(1, 1);
insert into pg_trans_test1_2 values(2, 2);
begin;
insert into pg_trans_test1_1 values(3, 3);
insert into pg_trans_test1_2 values(4, 4);
commit;
select * from pg_trans_test1_1;
select * from pg_trans_test1_2;
######### HASH分区 ########
create tablegroup tg2 binding true partition by hash partitions 2;
create table pg_trans_test2_1(id1 int, id2 int) tablegroup tg2 partition by hash(id1 % 2) partitions 2;
create index i1 on pg_trans_test2_1(id2) local;
create table pg_trans_test2_2(id1 int, id2 int) tablegroup tg2 partition by hash(id1 % 2) partitions 2;
desc pg_trans_test2_1;
desc pg_trans_test2_2;
insert into pg_trans_test2_1 values(5, 5);
insert into pg_trans_test2_2 values(6, 6);
select * from pg_trans_test2_1;
select * from pg_trans_test2_2;
#单pg事务
begin;
insert into pg_trans_test2_1 values(7, 7);
insert into pg_trans_test2_2 values(8, 8);
commit;
select * from pg_trans_test2_1;
select * from pg_trans_test2_2;
#多pg事务
begin;
insert into pg_trans_test2_1 values(7, 7);
insert into pg_trans_test2_1 values(8, 8);
insert into pg_trans_test2_2 values(9, 9);
insert into pg_trans_test2_2 values(10, 10);
commit;
select * from pg_trans_test2_1;
select * from pg_trans_test2_2;
########### RANGE分区 ############
create tablegroup tg3 binding true partition by range columns 1 (partition p0 values less than (10), partition p1 values less than(20));
create table pg_trans_test3_1(id1 int, id2 int) tablegroup tg3 partition by range columns(id1) (partition p0 values less than (10), partition p1 values less than(20));
create table pg_trans_test3_2(id1 int, id2 int) tablegroup tg3 partition by range columns(id1) (partition p0 values less than (10), partition p1 values less than(20));
desc pg_trans_test3_1;
desc pg_trans_test3_2;
insert into pg_trans_test3_1 values(5, 5);
insert into pg_trans_test3_2 values(15, 15);
select * from pg_trans_test3_1;
select * from pg_trans_test3_2;
#单pg事务
begin;
insert into pg_trans_test3_1 values(6, 6);
insert into pg_trans_test3_2 values(8, 8);
commit;
begin;
insert into pg_trans_test3_1 values(11, 11);
insert into pg_trans_test3_2 values(12, 12);
commit;
select * from pg_trans_test3_1;
select * from pg_trans_test3_2;
#多pg事务
begin;
insert into pg_trans_test3_1 values(1, 1);
insert into pg_trans_test3_1 values(13, 13);
insert into pg_trans_test3_2 values(2, 2);
insert into pg_trans_test3_2 values(14, 14);
commit;
select * from pg_trans_test3_1;
select * from pg_trans_test3_2;
########### LIST分区 ############
create tablegroup tg4 binding true partition by list columns 1 (
partition p0 values in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
partition p1 values in (11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
);
create table pg_trans_test4_1(id1 int, id2 int) tablegroup tg4 partition by list columns(id1) (
partition p0 values in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
partition p1 values in (11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
);
create table pg_trans_test4_2(id1 int, id2 int) tablegroup tg4 partition by list columns(id1) (
partition p0 values in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
partition p1 values in (11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
);
desc pg_trans_test4_1;
desc pg_trans_test4_2;
insert into pg_trans_test4_1 values(5, 5);
insert into pg_trans_test4_2 values(15, 15);
select * from pg_trans_test4_1;
select * from pg_trans_test4_2;
#单pg事务
begin;
insert into pg_trans_test4_1 values(6, 6);
insert into pg_trans_test4_2 values(8, 8);
commit;
begin;
insert into pg_trans_test4_1 values(11, 11);
insert into pg_trans_test4_2 values(12, 12);
commit;
select * from pg_trans_test4_1;
select * from pg_trans_test4_2;
#多pg事务
begin;
insert into pg_trans_test4_1 values(1, 1);
insert into pg_trans_test4_1 values(13, 13);
insert into pg_trans_test4_2 values(2, 2);
insert into pg_trans_test4_2 values(14, 14);
commit;
select * from pg_trans_test4_1;
select * from pg_trans_test4_2;
###############################################################
# 验证单个PG,多个分区场景
create tablegroup tg5 binding true;
create table pg_trans_test5_1 (pk int) tablegroup tg5;
create table pg_trans_test5_2 (pk int) tablegroup tg5;
insert into pg_trans_test5_1 values (1), (2), (3), (4);
insert into pg_trans_test5_2 values (1), (2), (3), (4);
select * from pg_trans_test5_1 as l join pg_trans_test5_2 as r where l.pk = r.pk;
###############################################################
##删除table
drop table if exists pg_trans_test1_1;
drop table if exists pg_trans_test1_2;
drop table if exists pg_trans_test2_1;
drop table if exists pg_trans_test2_2;
drop table if exists pg_trans_test3_1;
drop table if exists pg_trans_test3_2;
drop table if exists pg_trans_test4_1;
drop table if exists pg_trans_test4_2;
drop table if exists pg_trans_test5_1;
drop table if exists pg_trans_test5_2;
#删除table group
purge recyclebin;
drop tablegroup tg1;
drop tablegroup tg2;
drop tablegroup tg3;
drop tablegroup tg4;
drop tablegroup tg5;
connection obsys;
##还原配置
--enable_abort_on_error