[PATCH TEST] Fix logical replication setup in subscription test `t/009_matviews.pl` - Mailing list pgsql-hackers

From Грем Снорт
Subject [PATCH TEST] Fix logical replication setup in subscription test `t/009_matviews.pl`
Date
Msg-id CANV9Qw5HD7=Fp4nox2O7DoVctHoabRRVW9Soo4A=QipqW5B=Tg@mail.gmail.com
Whole thread Raw
Responses Re: [PATCH TEST] Fix logical replication setup in subscription test `t/009_matviews.pl`
List 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

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: plan shape work
Next
From: Fabrice Chapuis
Date:
Subject: Re: Issue with logical replication slot during switchover