|From:||Heikki Linnakangas <hlinnaka(at)iki(dot)fi>|
|Cc:||vignesh C <vignesh21(at)gmail(dot)com>|
|Views:||Raw Message | Whole Thread | Download mbox | Resend email|
While looking at the parallel copy patches, it started to annoy me how
large copy.c is. It confuses my little head. (Ok, it's annoyed me many
times in the past, but I haven't done anything about it.)
There isn't much common code between COPY FROM and COPY TO, so I propose
that we split copy.c into two: copyfrom.c and copyto.c. See attached. I
thin that's much nicer.
Usually when I'm looking at COPY, I'm specifically looking at COPY FROM
or COPY TO. There is symmetry between the two, like SendCopyBegin() and
ReceiveCopyBegin(), but more often I drill into the details of either
COPY FROM or TO. And when I need to look at those symmetric cases, I
want to open the two functions side-by-side anyway, so they might as
well be in different files.
There is some code duplication now. BeginCopy() was called by both
BeginCopyFrom() and BeginCopyTo(). I copied the common parts of it to
BeginCopyFrom and BeginCopyTo(), but some of the code was only
applicable to FROM or TO.
I also split/duplicated the CopyStateData struct into CopyFromStateData
and CopyToStateData. Many of the fields were common, but many were not,
and I think some duplication is nicer than a struct where you use some
fields and others are unused. I put the common formatting options into a
new CopyFormatOptions struct.
Moving code around always makes backpatching bug fixes harder, but I
think we should bit the bullet. If the parallel COPY work is committed,
it's going to move things around a lot anyway.
|Next Message||Jinbao Chen||2020-11-02 09:16:26||Add table AM 'tid_visible'|
|Previous Message||Ashutosh Bapat||2020-11-02 08:53:57||Re: Enumize logical replication message actions|