Re: Extend COPY FROM with HEADER <integer> to skip multiple lines

Shinya Kato <shinya11.kato@gmail.com>

From: Shinya Kato <shinya11.kato@gmail.com>
To: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Cc: Andrew Dunstan <andrew@dunslane.net>, Fujii Masao <masao.fujii@oss.nttdata.com>, pgsql-hackers@postgresql.org
Date: 2025-06-26T05:35:34Z
Lists: pgsql-hackers

Attachments

> > So it seems better for you to implement the patch at first and then
> > check the performance overhead etc if necessary.
>
> Thank you for your advice. I will create a patch.

I created a patch.

As you can see from the patch, I believe the performance impact is
negligible. The only changes were to modify how the HEADER option is stored
and to add a loop that skips the specified number of header lines when
parsing the options.

The design is such that if a HEADER value larger than the number of lines
in the file is specified, the command will complete with zero rows loaded
and will not return an error. This is the same behavior as specifying
HEADER true for a CSV file that has zero rows.

And I will add this patch for the next CF.

Thoughts?

-- 
Best regards,
Shinya Kato
NTT OSS Center

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Support multi-line headers in COPY FROM command.