Re: PostgreSQL 19 Beta 2: COPY HEADER N exceeds file length - test observation
Re: PostgreSQL 19 Beta 2: COPY HEADER N exceeds file length - test observation
On Thu, 13 Aug 2026 at 21:12, Mariyan Clement S wrote: > > 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 So, it's not really a CSV file, or at least not compliant with the relevant RFC 4180? > Could someone please confirm whether this is the expected/intended behavior for HEADER ? The docs are clear: "HEADER [...] On input, [i]f set to a non-negative integer, that number of lines are discarded." Unless you suggest we raise an error when the input file doesn't contain at least as many lines as indicated by the user's integer input to HEADER, the behaviour of ignoring lines indicated by the user to be headers is fully expected. Kind regards, Matthias van de Meent Databricks (https://www.databricks.com)
Re: PostgreSQL 19 Beta 2: COPY HEADER N exceeds file length - test observation
Hi Matthias,
Thank you for the clarification.
Yes, I agree with your interpretation. My intention was not to suggest that the current behavior is necessarily a bug.
The test file was intentionally constructed with metadata lines before the CSV header to simulate a real-world batch/export file. I understand that such a file is not a conventional RFC 4180-compliant CSV file.
My main observation was about the case where the configured HEADER value is greater than the number of available input lines.
As you pointed out, the documentation clearly states that when HEADER is specified with a non-negative integer, that number of lines are discarded. Therefore, consuming the available input and returning COPY 0 is consistent with the documented behavior.
I wanted to validate this edge case during PostgreSQL 19 Beta testing, particularly from an ETL perspective where the HEADER value could potentially be supplied through external configuration and could be incorrect.
Thanks again for taking the time to clarify this.
Regards,
Mariyan Clement
Database Architect | PostgreSQL | Oracle
LinkedIn: https://www.linkedin.com/in/mariyanclement/
On Thu, 13 Aug 2026 at 21:12, Mariyan Clement S <softclement@gmail.com> wrote:
>
> 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
So, it's not really a CSV file, or at least not compliant with the
relevant RFC 4180?
> Could someone please confirm whether this is the expected/intended behavior for HEADER ?
The docs are clear: "HEADER [...] On input, [i]f set to a non-negative
integer, that number of lines are discarded."
Unless you suggest we raise an error when the input file doesn't
contain at least as many lines as indicated by the user's integer
input to HEADER, the behaviour of ignoring lines indicated by the user
to be headers is fully expected.
Kind regards,
Matthias van de Meent
Databricks (https://www.databricks.com)