SQLSTATE 22P04Severity lowLab verified

Incident brief

COPY: extra data after last column

COPY fails when an input row has more fields than the target column list expects; a three-field, tab-separated line loaded into a narrower target raises this bad-copy-format error.

Reproduced on PostgreSQL 18.4Verified 2026-07-24 (isolated lab, PostgreSQL 18.4)Reviewed by Verified against PostgreSQL 18.4 in an isolated lab environment

In 10 seconds

What
COPY: extra data after last column
What triggers it
Run COPY into a table (or column list) with fewer columns than the input row provides.
The fix
Make the column list match the number of fields in each input row.
Proof
Reproduced on PostgreSQL 18.4 → A single COPY reproduces SQLSTATE 22P04; the row with an extra tab-separated field is rejected and the line is echoed in the CONTEXT.

The fix

What to do right now

The immediate, application-level response to this error.

  • Make the column list match the number of fields in each input row.
  • Fix the delimiter or the file so rows have exactly as many fields as target columns; use an explicit COPY (col1, col2, ...) list.
Fix — SQL
-- Match the COPY column list to the number of fields per row.
COPY copy_target (a, b) FROM STDIN;
1	2
\.

Related & next steps

Follow the thread

Everything this error touches — jump straight to the sibling error, term, runbook, or parameter.

Verification

PG 18.4
Last verified
2026-07-24 (isolated lab, PostgreSQL 18.4)
Reviewed by
Verified against PostgreSQL 18.4 in an isolated lab environment
Audit status
reviewed