OK, before I go too much further down this rabbit hole I'd like feedback on the current code. See attached patch
There is one obvious hack where in binary mode I reset the input cursor to allow the binary input to be re-read
From what I can tell the alternative is to convert the data in logicalrep_read_tuple but that would require moving a lot of the logic currently in worker.c to proto.c. This seems minimally invasive.
and thanks Petr for the tip to use pglogical for ideas.