[PATCH TEST] Fix logical replication setup in subscription test `t/009_matviews.pl`

From: Грем Снорт <grem(dot)snoort(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: [PATCH TEST] Fix logical replication setup in subscription test `t/009_matviews.pl`
Date: 2025-10-09 12:37:25
Message-ID: CANV9Qw5HD7=Fp4nox2O7DoVctHoabRRVW9Soo4A=QipqW5B=Tg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello!
I've found a simple problem in one of subscription tests
(`src/test/subscription/t/009_matviews.pl`).
When running this test, it completes successfully (All tests successful.
Result: PASS) but there is an error in subscriber's logs:
```
logical replication apply worker[1865731] ERROR: logical replication
target relation "public.test1" does not exist
```

How do I run the test:
```
# configure
./configure --enable-debug --enable-cassert --enable-tap-tests --with-icu
--prefix=$PG_PREFIX
# make ...
cd src/test/subscription
make installcheck PG_TEST_INITDB_EXTRA_OPTS="--locale=C" PROVE_TESTS="t/
009_matviews.pl"
```

The main purpose of this test is to check materialized views behavior,
which are not supported by logical replication, but logical decoding does
produce change information for them, so we need to make sure they are
properly ignored.

The problem I found is about incorrect setup for logical replication:
publisher performs INSERT to a table that has not yet been created on
subscriber, and this causes an error `target relation does not exist`.

According to docs:
https://www.postgresql.org/docs/17/logical-replication-subscription.html :
> The schema definitions are not replicated, and the published tables must
exist on the subscriber. Only regular tables may be the target of
replication. For example, you can't replicate to a view.

Also, the sequence of actions in subscription test does not match the
correct example in documentation (
https://www.postgresql.org/docs/17/logical-replication-subscription.html#LOGICAL-REPLICATION-SUBSCRIPTION-EXAMPLES
).

Therefore, I would like to propose a patch with trivial fix for logical
replication in subscription test `t/009_matviews.pl`.

The patch is in attachments to this letter.
The patch was created via: `git format-patch master --base master`.

Attachment Content-Type Size
0001-Fix-logical-replication-setup-in-subscription-test-t.patch text/x-patch 1.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabrice Chapuis 2025-10-09 12:56:28 Re: Issue with logical replication slot during switchover
Previous Message Robert Haas 2025-10-09 12:34:56 Re: plan shape work