Fix the misuse of origin filter across multiple pg_logical_slot_get_changes() calls.
authorAmit Kapila
Wed, 27 Sep 2023 08:50:57 +0000 (14:20 +0530)
committerAmit Kapila
Wed, 27 Sep 2023 08:50:57 +0000 (14:20 +0530)
commit8d05be93197cd37ef232bd367bb46fa932a557b9
treeb2fd37e9fb31153cd97c7aadda123df7226ab56b
parent641db601b72fc501b10e02ce1a018d9d103d355c
Fix the misuse of origin filter across multiple pg_logical_slot_get_changes() calls.

The pgoutput module uses a global variable (publish_no_origin) to cache
the action for the origin filter, but we didn't reset the flag when
shutting down the output plugin, so subsequent retries may access the
previous publish_no_origin value.

We fix this by storing the flag in the output plugin's private data.
Additionally, the patch removes the currently unused origin string from the
structure.

For the back branch, to avoid changing the exposed structure, we eliminated the
global variable and instead directly used the origin string for change
filtering.

Author: Hou Zhijie
Reviewed-by: Amit Kapila, Michael Paquier
Backpatch-through: 16
Discussion: http://postgr.es/m/OS0PR01MB571690EF24F51F51EFFCBB0E94FAA@OS0PR01MB5716.jpnprd01.prod.outlook.com
contrib/test_decoding/expected/replorigin.out
contrib/test_decoding/sql/replorigin.sql
src/backend/replication/pgoutput/pgoutput.c