CopyFrom() has become way too complicated

Started by Andres Freundover 7 years ago2 messages
#1Andres Freund
andres@anarazel.de

Hi,

I've had to whack CopyFrom() around a couple times due to the pluggable
storage patch, and I found that after
commit 0d5f05cde011512e605bb2688d9b1fbb5b3ae152
Author: Peter Eisentraut <peter_e@gmx.net>
Date: 2018-08-01 10:23:09 +0200

Allow multi-inserts during COPY into a partitioned table

and also the previous partition support changes, the CopyFrom() code
has, for me at least, become very hard to follow.

I think the code needs to be split up so that CopyFrom() in the loop
body calls CopyFromOneTuple(), which then also splits out the tuple
routing into its own CopyFromOneTupleRoute() function (that's 200 LOC on
its own...). I suspect it'd also be good to refactor the
partition-change code out into its own function.

Greetings,

Andres Freund

#2Corey Huinker
corey.huinker@gmail.com
In reply to: Andres Freund (#1)
Re: CopyFrom() has become way too complicated

I think the code needs to be split up so that CopyFrom() in the loop
body calls CopyFromOneTuple(), which then also splits out the tuple
routing into its own CopyFromOneTupleRoute() function (that's 200 LOC on
its own...). I suspect it'd also be good to refactor the
partition-change code out into its own function.

+1
I had a hard time with this when doing my copy_srf() misadventure.