Split copy.c
От | Heikki Linnakangas |
---|---|
Тема | Split copy.c |
Дата | |
Msg-id | 8e15b560-f387-7acc-ac90-763986617bfb@iki.fi обсуждение исходный текст |
Ответы |
Re: Split copy.c
Re: Split copy.c Re: Split copy.c |
Список | pgsql-hackers |
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. - Heikki
Вложения
В списке pgsql-hackers по дате отправления: