blob: 3c1de1390aafb82f465960558c5627294fc24df6 [file] [log] [blame]
-- @Description Tests the AO segment file selection policy
--
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT) USING @amname@;
-- Case 1: Both transactions insert initial segment files into aoseg.
1: BEGIN;
2: BEGIN;
1: INSERT INTO AO VALUES (1);
-- Segment file 1 should be created
3: SELECT segno FROM gp_ao_or_aocs_seg('ao');
2: INSERT INTO AO VALUES (1);
-- Segment file 2 should be created
3: SELECT segno FROM gp_ao_or_aocs_seg('ao');
2: COMMIT;
-- Transaction 2 should commit before 1. It validates that
-- transaction 2 chose a different segfile than transaction 1.
1: COMMIT;
3: SELECT segno, tupcount FROM gp_ao_or_aocs_seg('ao');
-- Case 2: Concurrent inserts with existing segment files in aoseg.
1: INSERT INTO AO VALUES (1);
3: SELECT segno, tupcount FROM gp_ao_or_aocs_seg('ao');
-- Here we aim to insert a tuple to the same seg as (1).
-- Under jump jash, (15) and (1) are on the same seg(seg1).
1: INSERT INTO AO VALUES (15);
3: SELECT segno, tupcount FROM gp_ao_or_aocs_seg('ao');
1: BEGIN;
1: INSERT INTO AO VALUES (15);
2: BEGIN;
2: INSERT INTO AO VALUES (15);
1: COMMIT;
2: COMMIT;
3: SELECT segno, tupcount FROM gp_ao_or_aocs_seg('ao');
1: insert into ao select generate_series(1,100000);
1: INSERT INTO AO VALUES (15);
3: SELECT segno, case when tupcount = 0 then 'zero' when tupcount <= 5 then 'few' else 'many' end FROM gp_ao_or_aocs_seg('ao');