From 3b0f40ac76e61793d80aa6fe92791726d7c925d3 Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Mon, 10 Jan 2022 15:14:54 +0100 Subject: [PATCH] Add PGXS "make installcheck" support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This enables running PG's standard testsuite with a PG server configured for decoderbufs. Example on Debian: ``` $ sudo apt install postgresql-14-decoderbufs $ pg_virtualenv -o shared_preload_libraries=decoderbufs -o wal_level=logical Creating new PostgreSQL cluster 14/regress ... $ make installcheck /usr/lib/postgresql/14/lib/pgxs/src/makefiles/../../src/test/regress/pg_regress --inputdir=./ --bindir='/usr/lib/postgresql/14/bin' --dbname=contrib_regression decoderbufs (using postmaster on localhost, port 5433) ============== dropping database "contrib_regression" ============== HINWEIS: Datenbank »contrib_regression« existiert nicht, wird übersprungen DROP DATABASE ============== creating database "contrib_regression" ============== CREATE DATABASE ALTER DATABASE ============== running regression test queries ============== test decoderbufs ... ok 30 ms ===================== All 1 tests passed. ===================== $ exit Dropping cluster 14/regress ... ``` --- Makefile | 1 + expected/decoderbufs.out | 27 +++++++++++++++++++++++++++ sql/decoderbufs.sql | 7 +++++++ 3 files changed, 35 insertions(+) create mode 100644 expected/decoderbufs.out create mode 100644 sql/decoderbufs.sql diff --git a/Makefile b/Makefile index f68855c..d4ea1d2 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ MODULE_big = decoderbufs EXTENSION = decoderbufs +REGRESS = decoderbufs PROTOBUF_C_CFLAGS = $(shell pkg-config --cflags 'libprotobuf-c >= 1.0.0') PROTOBUF_C_LDFLAGS = $(shell pkg-config --libs 'libprotobuf-c >= 1.0.0') diff --git a/expected/decoderbufs.out b/expected/decoderbufs.out new file mode 100644 index 0000000..cf1bb7a --- /dev/null +++ b/expected/decoderbufs.out @@ -0,0 +1,27 @@ +select slot_name from pg_create_logical_replication_slot('decoderbufs_demo', 'decoderbufs'); +INFO: Exiting startup callback + slot_name +------------------ + decoderbufs_demo +(1 row) + +create table foo (id int primary key, data text); +insert into foo values (1, 'Important stuff'); +select regexp_replace(data, '(txid|commit_time)\[\d+\]', '\1[***]', 'g') as data +from pg_logical_slot_peek_changes('decoderbufs_demo', NULL, NULL, 'debug-mode', '1'); +NOTICE: Decoderbufs DEBUG MODE is ON. +INFO: Exiting startup callback + data +------------------------------------------------------------ + txid[***], commit_time[***], op[3] + txid[***], commit_time[***], op[4] + txid[***], commit_time[***], op[3] + txid[***], commit_time[***], table[public.foo], op[0] + + NEW TUPLE: + + column_name[id], column_type[23], datum[1] + + column_name[data], column_type[25], datum[Important stuff]+ + + + + txid[***], commit_time[***], op[4] +(5 rows) + diff --git a/sql/decoderbufs.sql b/sql/decoderbufs.sql new file mode 100644 index 0000000..3043f8a --- /dev/null +++ b/sql/decoderbufs.sql @@ -0,0 +1,7 @@ +select slot_name from pg_create_logical_replication_slot('decoderbufs_demo', 'decoderbufs'); + +create table foo (id int primary key, data text); +insert into foo values (1, 'Important stuff'); + +select regexp_replace(data, '(txid|commit_time)\[\d+\]', '\1[***]', 'g') as data +from pg_logical_slot_peek_changes('decoderbufs_demo', NULL, NULL, 'debug-mode', '1');