On Sat, 7 Nov 2026 at 11:43, Mingjie Gao <[email protected]> wrote: > > Hi Peter, Vignesh, > > Thanks for the review. Attached is v3, based on the same master commit: > 77705d1e5a616339c3e92f586bbfa7b6bb562beb. > > Vignesh wrote: > > 1) Can we create the table in publisher and subscriber outside the > > loop instead of doing it twice, similarly the publication can be > > created outside the loop: > > Done. > > > 2) With the first changes, we can truncate the tables instead of dropping > > them: > > Done. The subscription is dropped before truncating the tables between > modes. Each mode still checks initial sync and an incremental insert. > > Peter wrote: > > Saying publish = 'insert' seems overkill. > > Removed. > > > Those could be combined a bit... > > I've combined the cleanup and tidied the comments, spacing and > semicolons as suggested in your attachment. The C code is unchanged > from v2. > > Vignesh wrote: > > 3) Till which branch will this patch be applied? > > I reproduced the text-mode issue on PG10. I haven't reproduced it on > the other versions, but the code appears to have the same problem. > The binary case appears to be affected from PG16, which added binary > initial sync. > > I think we should backpatch to the affected supported branches. I have > only tested the patch on master so far. > > I tested v3 on master with assertions enabled. The regression tests and > the relevant logical replication tests passed.
Thanks for the updated version, the v3 version looks good. One suggestion, can we elaborate the commit message something like below: When a published table has no columns, initial table synchronization passes an empty column list to COPY. COPY cannot distinguish an empty list from an unspecified one, and treats NIL as "all columns of the target table that are neither dropped nor generated". If the subscriber's table has columns, COPY therefore expects input for them even though the publisher sends none. In text mode, the empty line sent for each row is read as a single empty field. As a result, a text-like column receives an empty string instead of its local default, while columns of other types fail in their input functions. In binary mode, the zero field count does not match the expected count, causing synchronization to fail repeatedly with "row field count is 0, expected 1". Fix this by allowing the caller to specify that an empty column list is intentional. Add BeginCopyFromExtended(), which takes a flag indicating that a NIL attnamelist selects no input columns, and use it in tablesync. With no input columns, all subscriber columns are filled from their defaults, just as they are when omitted from an explicit column list. Keep BeginCopyFrom() as a wrapper that passes false, leaving COPY itself and other callers unchanged. Since an empty column list cannot be specified in SQL, only tablesync needs this distinction. Regards, Vignesh
