blob: 9d5bbf9cfb15a10c3dca01ba726301a898c6d526 [file]
-- @Description Tests the AO segment file selection policy
--
DROP TABLE IF EXISTS ao;
DROP
CREATE TABLE ao (a INT) USING @amname@;
CREATE
-- Case 1: Both transactions insert initial segment files into aoseg.
1: BEGIN;
BEGIN
2: BEGIN;
BEGIN
1: INSERT INTO AO VALUES (1);
INSERT 1
-- Segment file 1 should be created
3: SELECT segno FROM gp_ao_or_aocs_seg('ao');
segno
-------
1
(1 row)
2: INSERT INTO AO VALUES (1);
INSERT 1
-- Segment file 2 should be created
3: SELECT segno FROM gp_ao_or_aocs_seg('ao');
segno
-------
1
2
(2 rows)
2: COMMIT;
COMMIT
-- Transaction 2 should commit before 1. It validates that
-- transaction 2 chose a different segfile than transaction 1.
1: COMMIT;
COMMIT
3: SELECT segno, tupcount FROM gp_ao_or_aocs_seg('ao');
segno | tupcount
-------+----------
1 | 1
2 | 1
(2 rows)
-- Case 2: Concurrent inserts with existing segment files in aoseg.
1: INSERT INTO AO VALUES (1);
INSERT 1
3: SELECT segno, tupcount FROM gp_ao_or_aocs_seg('ao');
segno | tupcount
-------+----------
1 | 2
2 | 1
(2 rows)
-- 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);
INSERT 1
3: SELECT segno, tupcount FROM gp_ao_or_aocs_seg('ao');
segno | tupcount
-------+----------
1 | 2
2 | 2
(2 rows)
1: BEGIN;
BEGIN
1: INSERT INTO AO VALUES (15);
INSERT 1
2: BEGIN;
BEGIN
2: INSERT INTO AO VALUES (15);
INSERT 1
1: COMMIT;
COMMIT
2: COMMIT;
COMMIT
3: SELECT segno, tupcount FROM gp_ao_or_aocs_seg('ao');
segno | tupcount
-------+----------
1 | 3
2 | 3
(2 rows)
1: insert into ao select generate_series(1,100000);
INSERT 100000
1: INSERT INTO AO VALUES (15);
INSERT 1
3: SELECT segno, case when tupcount = 0 then 'zero' when tupcount <= 5 then 'few' else 'many' end FROM gp_ao_or_aocs_seg('ao');
segno | case
-------+------
1 | many
1 | many
1 | many
2 | few
(4 rows)