CopyFrom() has become way too complicated - Mailing list pgsql-hackers

From Andres Freund
Subject CopyFrom() has become way too complicated
Date
Msg-id 20181012181337.b43fka3y64wlbvx4@alap3.anarazel.de
Whole thread Raw
Responses Re: CopyFrom() has become way too complicated  (Corey Huinker <corey.huinker@gmail.com>)
List pgsql-hackers
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


pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Multi-insert into a partitioned table with before insert rowtrigger causes server crash on latest HEAD
Next
From: Tom Lane
Date:
Subject: Re: AllocSetContextCreate changes breake extensions