pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Split copy.c into four files.
Date: Mon, 23 Nov 2020 09:17:03 +0000
Message-ID: <E1kh7y3-0001R6-Dj@gemulon.postgresql.org> (raw)

Split copy.c into four files.

Copy.c has grown really large. Split it into more manageable parts:

- copy.c now contains only a few functions that are common to COPY FROM
  and COPY TO.

- copyto.c contains code for COPY TO.

- copyfrom.c contains code for initializing COPY FROM, and inserting the
  tuples to the correct table.

- copyfromparse.c contains code for reading from the client/file/program,
  and parsing the input text/CSV/binary format into tuples.

All of these parts are fairly complicated, and fairly independent of each
other. There is a patch being discussed to implement parallel COPY FROM,
which will add a lot of new code to the COPY FROM path, and another patch
which would allow INSERTs to use the same multi-insert machinery as COPY
FROM, both of which will require refactoring that code. With those two
patches, there's going to be a lot of code churn in copy.c anyway, so now
seems like a good time to do this refactoring.

The CopyStateData struct is also split. All the formatting options, like
FORMAT, QUOTE, ESCAPE, are put in a new CopyFormatOption struct, which
is used by both COPY FROM and TO. Other state data are kept in separate
CopyFromStateData and CopyToStateData structs.

Reviewed-by: Soumyadeep Chakraborty, Erik Rijkers, Vignesh C, Andres Freund
Discussion: https://www.postgresql.org/message-id/8e15b560-f387-7acc-ac90-763986617bfb%40iki.fi

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c532d15dddff14b01fe9ef1d465013cb8ef186df

Modified Files
--------------
contrib/file_fdw/file_fdw.c                 |   10 +-
src/backend/commands/Makefile               |    3 +
src/backend/commands/copy.c                 | 4603 +--------------------------
src/backend/commands/copyfrom.c             | 1562 +++++++++
src/backend/commands/copyfromparse.c        | 1616 ++++++++++
src/backend/commands/copyto.c               | 1347 ++++++++
src/backend/replication/logical/tablesync.c |    4 +-
src/include/commands/copy.h                 |   61 +-
src/include/commands/copyfrom_internal.h    |  164 +
9 files changed, 4841 insertions(+), 4529 deletions(-)



Message-ID: <E1kh7y3-0001R6-Dj@gemulon.postgresql.org>
Permalink:  ../E1kh7y3-0001R6-Dj@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1kh7y3-0001R6-Dj@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: heikki.linnakangas@iki.fi
  Subject: Re: pgsql: Split copy.c into four files.
  In-Reply-To: <E1kh7y3-0001R6-Dj@gemulon.postgresql.org>
  References: <E1kh7y3-0001R6-Dj@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox