@@ -168,38 +168,34 @@ pglogical_write_begin(StringInfo out, PGLogicalOutputData *data,
168168 }
169169}
170170
171- static void pglogical_broadcast_table (StringInfo out , PGLogicalOutputData * data , MtmCopyRequest * copy )
171+ static void pglogical_broadcast_table (StringInfo out , LogicalDecodingContext * ctx , MtmCopyRequest * copy )
172172{
173173 if (BIT_CHECK (copy -> targetNodes , MtmReplicationNodeId - 1 )) {
174174 HeapScanDesc scandesc ;
175175 HeapTuple tuple ;
176176 Relation rel ;
177177
178- StartTransactionCommand ();
179-
180178 rel = heap_open (copy -> sourceTable , ShareLock );
181179
182- pq_sendbyte (out , 'M' );
183- pq_sendbyte (out , 'B' );
184- pq_sendint (out , sizeof (* copy ), 4 );
185- pq_sendbytes (out , (char * )copy , sizeof (* copy ));
186-
187- pglogical_write_rel (out , data , rel );
180+ pglogical_write_rel (out , ctx -> output_plugin_private , rel );
181+
182+ pq_sendbyte (out , '0' );
188183
189184 scandesc = heap_beginscan (rel , GetTransactionSnapshot (), 0 , NULL );
190185 while ((tuple = heap_getnext (scandesc , ForwardScanDirection )) != NULL )
191186 {
192- pglogical_write_tuple (out , data , rel , tuple );
187+ MtmOutputPluginPrepareWrite (ctx , false, false);
188+ pq_sendbyte (out , 'I' ); /* action INSERT */
189+ pglogical_write_tuple (out , ctx -> output_plugin_private , rel , tuple );
190+ MtmOutputPluginWrite (ctx , false, false);
193191 }
194192 heap_endscan (scandesc );
195193 heap_close (rel , ShareLock );
196-
197- CommitTransactionCommand ();
198194 }
199195}
200196
201197static void
202- pglogical_write_message (StringInfo out , PGLogicalOutputData * data ,
198+ pglogical_write_message (StringInfo out , LogicalDecodingContext * ctx ,
203199 const char * prefix , Size sz , const char * message )
204200{
205201 MtmLastRelId = InvalidOid ;
@@ -231,7 +227,7 @@ pglogical_write_message(StringInfo out, PGLogicalOutputData *data,
231227 */
232228 return ;
233229 case 'B' :
234- pglogical_broadcast_table (out , data , (MtmCopyRequest * )message );
230+ pglogical_broadcast_table (out , ctx , (MtmCopyRequest * )message );
235231 return ;
236232 }
237233 pq_sendbyte (out , 'M' );
0 commit comments