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
