PostgreSQL 19 Beta 2: COPY HEADER N exceeds file length - test observation

From: Mariyan Clement S <softclement(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: PostgreSQL 19 Beta 2: COPY HEADER N exceeds file length - test observation
Date: 2026-08-12 20:10:31
Message-ID: CAA3hCqgEQrAS=if0BC4CerscfHyR4JbYi=hoP9NEP21phvMqbA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi PostgreSQL community,

I have been testing the new integer form of the COPY FROM HEADER option in
PostgreSQL 19 Beta 2 and wanted to share an edge-case observation for
confirmation.

I tested a CSV file containing only 5 lines:

-

3 metadata lines
-

1 CSV column-header line
-

1 data row

Then executed:

TRUNCATE employees;

COPY employees (emp_id, emp_name, dept)
FROM '/tmp/employees_header_overflow.csv'
WITH (FORMAT csv, HEADER 10);

Result:

COPY 0

The table remained empty:

emp_id | emp_name | dept
--------+----------+------
(0 rows)

So, when HEADER N is greater than the total number of lines available in
the file, PostgreSQL 19 Beta 2 does not raise an error. It consumes the
available input as header lines and returns COPY 0.

From an ETL perspective, this caught my attention because if the HEADER
value is externally configured and is incorrect, data rows could
potentially be skipped without an explicit error.

Could someone please confirm whether this is the expected/intended behavior
for HEADER ?

I am sharing this as a Beta 2 test observation so that it can be reviewed
before the PostgreSQL 19 final release, if any change or documentation
clarification is appropriate.

I have also documented the complete hands-on PoC, including the test cases
and results:

https://github.com/softclement/PostgreSQL-19-COPY-HEADER-PoC

Test environment:

-

PostgreSQL 19 Beta 2
-

Podman
-

WSL2 / Ubuntu
-

COPY FROM CSV

Regards,
Mariyan Clement
Database Architectect | PostgreSQL | Oracle

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2026-08-12 20:13:13 Re: Clarify or fix SIGINT handling in data checksums launcher
Previous Message Nathan Bossart 2026-08-12 20:10:11 Re: pgbench --continue-on-error: clarify TPS and failure reporting