On 4/3/18 22:31, Peter Eisentraut wrote:
> The problem I see now is that when we WAL-log a truncate, we include all
> the relids in one record. That seems useful. But during decoding we
> split this into one change per relid. So at the receiving end, truncate
> can only process one relation at a time, which will fail if there are
> foreign keys involved. The solution that had been proposed here was to
> ignore foreign keys on the subscriber, which is clearly problematic.
> I'm going to try to hack up an alternative approach and see how it works
> out.
Done here. I added a separate callback for decoding truncates, which
receives all the relations at once. That information can then be
shipped off together and applied together on the receiving side. So
foreign keys are not a problem anymore. This ended up being a bit
larger than the original patch, but I think it's sound behavior and
future-proof.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services