blob: 60d073b42f4728123c8bf84a035044ab96a114c1 [file] [log] [blame]
-- Test AOCO XLogging
CREATE TABLE generate_aoco_xlog_table(a INT, b INT) WITH (APPENDONLY=TRUE, ORIENTATION=COLUMN);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Apache Cloudberry data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
-- Store the location of xlog in a temporary table so that we can
-- use it to request walsender to start streaming from this point
CREATE TEMP TABLE tmp(dummy int, dbid int, startpoint pg_lsn) distributed by (dummy);
INSERT INTO tmp SELECT 1, gp_execution_segment(),pg_current_wal_lsn() FROM
gp_dist_random('gp_id');
-- Generate some xlog records for AOCO
INSERT INTO generate_aoco_xlog_table SELECT i,i+3 FROM generate_series(1,15)i;
-- Verify that AO xlog record was received
SELECT gp_segment_id, relname, record_type, segment_filenum, recordlen, file_offset
FROM test_xlog_ao_wrapper(
(SELECT array_agg(startpoint) FROM
(SELECT startpoint from tmp order by dbid) t
)
)
WHERE spcNode = (SELECT oid FROM pg_tablespace WHERE spcname = 'pg_default')
AND dbNode = (SELECT oid FROM pg_database WHERE datname = current_database())
ORDER BY gp_segment_id, xrecoff;
gp_segment_id | relname | record_type | segment_filenum | recordlen | file_offset
---------------+--------------------------+------------------------+-----------------+-----------+-------------
0 | generate_aoco_xlog_table | XLOG_APPENDONLY_INSERT | 1 | 88 | 0
0 | generate_aoco_xlog_table | XLOG_APPENDONLY_INSERT | 129 | 24 | 0
0 | generate_aoco_xlog_table | XLOG_APPENDONLY_INSERT | 1 | 24 | 0
0 | generate_aoco_xlog_table | XLOG_APPENDONLY_INSERT | 129 | 88 | 0
1 | generate_aoco_xlog_table | XLOG_APPENDONLY_INSERT | 1 | 80 | 0
1 | generate_aoco_xlog_table | XLOG_APPENDONLY_INSERT | 129 | 24 | 0
1 | generate_aoco_xlog_table | XLOG_APPENDONLY_INSERT | 1 | 24 | 0
1 | generate_aoco_xlog_table | XLOG_APPENDONLY_INSERT | 129 | 80 | 0
2 | generate_aoco_xlog_table | XLOG_APPENDONLY_INSERT | 1 | 96 | 0
2 | generate_aoco_xlog_table | XLOG_APPENDONLY_INSERT | 129 | 24 | 0
2 | generate_aoco_xlog_table | XLOG_APPENDONLY_INSERT | 1 | 24 | 0
2 | generate_aoco_xlog_table | XLOG_APPENDONLY_INSERT | 129 | 96 | 0
(12 rows)
-- Store the latest xlog offset
DELETE FROM tmp;
INSERT INTO tmp SELECT 1, gp_execution_segment(),pg_current_wal_lsn()
FROM gp_dist_random('gp_id');
-- Generate a truncate XLOG entry for generate_ao_xlog_table.
BEGIN;
INSERT INTO generate_aoco_xlog_table SELECT i,i FROM generate_series(1,10)i;
ABORT;
VACUUM generate_aoco_xlog_table;
-- Verify that truncate AO xlog record was received
SELECT gp_segment_id, relname, record_type, segment_filenum, recordlen, file_offset
FROM test_xlog_ao_wrapper(
(SELECT array_agg(startpoint) FROM
(SELECT startpoint from tmp order by dbid) t
)
)
WHERE spcNode = (SELECT oid FROM pg_tablespace WHERE spcname = 'pg_default')
AND dbNode = (SELECT oid FROM pg_database WHERE datname = current_database())
ORDER BY gp_segment_id, xrecoff;
gp_segment_id | relname | record_type | segment_filenum | recordlen | file_offset
---------------+--------------------------+--------------------------+-----------------+-----------+-------------
0 | generate_aoco_xlog_table | XLOG_APPENDONLY_TRUNCATE | 129 | 24 | 64
0 | generate_aoco_xlog_table | XLOG_APPENDONLY_TRUNCATE | 1 | 24 | 64
0 | generate_aoco_xlog_table | XLOG_APPENDONLY_INSERT | 129 | 88 | 64
0 | generate_aoco_xlog_table | XLOG_APPENDONLY_INSERT | 1 | 88 | 64
1 | generate_aoco_xlog_table | XLOG_APPENDONLY_TRUNCATE | 129 | 24 | 56
1 | generate_aoco_xlog_table | XLOG_APPENDONLY_TRUNCATE | 1 | 24 | 56
1 | generate_aoco_xlog_table | XLOG_APPENDONLY_INSERT | 129 | 72 | 56
1 | generate_aoco_xlog_table | XLOG_APPENDONLY_INSERT | 1 | 72 | 56
2 | generate_aoco_xlog_table | XLOG_APPENDONLY_TRUNCATE | 129 | 24 | 72
2 | generate_aoco_xlog_table | XLOG_APPENDONLY_TRUNCATE | 1 | 24 | 72
2 | generate_aoco_xlog_table | XLOG_APPENDONLY_INSERT | 129 | 80 | 72
2 | generate_aoco_xlog_table | XLOG_APPENDONLY_INSERT | 1 | 80 | 72
(12 rows)