Re: Split copy.c

From: vignesh C <vignesh21(at)gmail(dot)com>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Split copy.c
Date: 2020-11-02 12:32:05
Message-ID: CALDaNm3KXGSsLT2Tc4K81uqF5hymhV8N_OrOtqF_LmOyr2A6QQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Nov 2, 2020 at 2:33 PM Heikki Linnakangas <hlinnaka(at)iki(dot)fi> wrote:
>
> 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.)
>

+1 for having copy from & copy to functionality in separate files.

This is present in both copyfrom.c & copyto.c, can it be removed from
one place & moved to a common header file?
static const char BinarySignature[11] = "PGCOPY\n\377\r\n\0";

CopyDest was changed to:
typedef enum CopySource
{
COPY_FILE, /* from file (or a piped program) */
COPY_OLD_FE, /* from frontend (2.0 protocol) */
COPY_NEW_FE, /* from frontend (3.0 protocol) */
COPY_CALLBACK /* from callback function */
} CopySource;

typedef enum CopyDest
{
COPY_FILE, /* to file (or a piped program) */
COPY_OLD_FE, /* to frontend (2.0 protocol) */
COPY_NEW_FE, /* to frontend (3.0 protocol) */
} CopyDest;

Should we have one enum or both are required, if both are required we
could think of naming like COPY_TO_FILE, COPY_FROM_FILE, it will make
it more clearer.

There is one warning while applying the v2 patch:
Applying: Split copy.c into copyto.c and copyfrom.c.
/home/vignesh/postgres/postgres/.git/rebase-apply/patch:909: trailing
whitespace.
warning: 1 line adds whitespace errors.

There is one compilation error, may be this Assert is not required:
copyto.c: In function ‘BeginCopyTo’:
copyto.c:477:11: error: ‘is_from’ undeclared (first use in this function)
Assert(!is_from);

Regards,
Vignesh
EnterpriseDB: http://www.enterprisedb.com

In response to

  • Split copy.c at 2020-11-02 09:03:29 from Heikki Linnakangas

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey Borodin 2020-11-02 12:45:33 Re: MultiXact\SLRU buffers configuration
Previous Message Erik Rijkers 2020-11-02 12:24:12 Re: Split copy.c