From 3357eea46b330e301342778a6f7e45c45a88f52f Mon Sep 17 00:00:00 2001 From: Ahmet Gedemenli Date: Tue, 29 Sep 2020 11:38:19 +0300 Subject: [PATCH] Add regression tests for PG13 WAL --- src/test/regress/expected/pg13.out | 68 +++++++++++++++++++++++++----- src/test/regress/sql/pg13.sql | 11 +++++ 2 files changed, 68 insertions(+), 11 deletions(-) diff --git a/src/test/regress/expected/pg13.out b/src/test/regress/expected/pg13.out index 938604788..4908360f8 100644 --- a/src/test/regress/expected/pg13.out +++ b/src/test/regress/expected/pg13.out @@ -170,15 +170,61 @@ SELECT create_distributed_table('test_table', 'a'); -- we currently don't support this CREATE INDEX test_table_index ON test_table USING gist (b tsvector_ops(siglen = 100)); ERROR: citus currently doesn't support operator class parameters in indexes +-- testing WAL +CREATE TABLE test_wal(a int, b int); +-- test WAL without ANALYZE, this should raise an error +EXPLAIN (WAL) INSERT INTO test_wal VALUES(1,11); +ERROR: EXPLAIN option WAL requires ANALYZE +-- test WAL working properly +EXPLAIN (ANALYZE TRUE, WAL TRUE, COSTS FALSE, SUMMARY FALSE, BUFFERS FALSE, TIMING FALSE) INSERT INTO test_wal VALUES(1,11); + QUERY PLAN +--------------------------------------------------------------------- + Insert on test_wal (actual rows=0 loops=1) + WAL: records=1 bytes=63 + -> Result (actual rows=1 loops=1) +(3 rows) + +SELECT create_distributed_table('test_wal', 'a'); +NOTICE: Copying data from local table... +NOTICE: copying the data has completed +DETAIL: The local data in the table is no longer visible, but is still on disk. +HINT: To remove the local data, run: SELECT truncate_local_data_after_distributing_table($$test_pg13.test_wal$$) + create_distributed_table +--------------------------------------------------------------------- + +(1 row) + +EXPLAIN (ANALYZE TRUE, WAL TRUE, COSTS FALSE, SUMMARY FALSE, BUFFERS FALSE, TIMING FALSE) INSERT INTO test_wal VALUES(2,22); + QUERY PLAN +--------------------------------------------------------------------- + Custom Scan (Citus Adaptive) (actual rows=0 loops=1) + Task Count: 1 + Tasks Shown: All + -> Task + Node: host=localhost port=xxxxx dbname=regression + -> Insert on test_wal_65013 (actual rows=0 loops=1) + WAL: records=1 bytes=63 + -> Result (actual rows=1 loops=1) +(8 rows) + +EXPLAIN (ANALYZE TRUE, WAL TRUE, COSTS FALSE, SUMMARY FALSE, BUFFERS FALSE, TIMING FALSE) WITH cte_1 AS (DELETE FROM test_wal WHERE a=2 RETURNING *) SELECT * FROM cte_1; + QUERY PLAN +--------------------------------------------------------------------- + Custom Scan (Citus Adaptive) (actual rows=1 loops=1) + Task Count: 1 + Tuple data received from nodes: 3 bytes + Tasks Shown: All + -> Task + Tuple data received from node: 3 bytes + Node: host=localhost port=xxxxx dbname=regression + -> CTE Scan on cte_1 (actual rows=1 loops=1) + WAL: records=1 bytes=54 + CTE cte_1 + -> Delete on test_wal_65013 test_wal (actual rows=1 loops=1) + WAL: records=1 bytes=54 + -> Seq Scan on test_wal_65013 test_wal (actual rows=1 loops=1) + Filter: (a = 2) +(14 rows) + +SET client_min_messages TO WARNING; drop schema test_pg13 cascade; -NOTICE: drop cascades to 10 other objects -DETAIL: drop cascades to table dist_table -drop cascades to table generated_col_table -drop cascades to view v -drop cascades to table ab -drop cascades to table text_table -drop cascades to function myvarcharout(myvarchar) -drop cascades to type myvarchar -drop cascades to function myvarcharin(cstring,oid,integer) -drop cascades to table my_table -drop cascades to table test_table diff --git a/src/test/regress/sql/pg13.sql b/src/test/regress/sql/pg13.sql index 3c423c96e..b9197761f 100644 --- a/src/test/regress/sql/pg13.sql +++ b/src/test/regress/sql/pg13.sql @@ -94,4 +94,15 @@ SELECT create_distributed_table('test_table', 'a'); -- we currently don't support this CREATE INDEX test_table_index ON test_table USING gist (b tsvector_ops(siglen = 100)); +-- testing WAL +CREATE TABLE test_wal(a int, b int); +-- test WAL without ANALYZE, this should raise an error +EXPLAIN (WAL) INSERT INTO test_wal VALUES(1,11); +-- test WAL working properly +EXPLAIN (ANALYZE TRUE, WAL TRUE, COSTS FALSE, SUMMARY FALSE, BUFFERS FALSE, TIMING FALSE) INSERT INTO test_wal VALUES(1,11); +SELECT create_distributed_table('test_wal', 'a'); +EXPLAIN (ANALYZE TRUE, WAL TRUE, COSTS FALSE, SUMMARY FALSE, BUFFERS FALSE, TIMING FALSE) INSERT INTO test_wal VALUES(2,22); +EXPLAIN (ANALYZE TRUE, WAL TRUE, COSTS FALSE, SUMMARY FALSE, BUFFERS FALSE, TIMING FALSE) WITH cte_1 AS (DELETE FROM test_wal WHERE a=2 RETURNING *) SELECT * FROM cte_1; +SET client_min_messages TO WARNING; + drop schema test_pg13 cascade;