SQLSTATE 42601 ERROR Class 42: Syntax Error or Access Rule Violation

syntax_error VALUES lists must all be the same length — 42601

PostgreSQL error "VALUES lists must all be the same length" (SQLSTATE 42601): what it means, common causes, and how to fix it.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Diagnostic Queries

Symptoms

A multi-row VALUES clause had rows with differing numbers of expressions. Every row must have the same length, so PostgreSQL raises SQLSTATE 42601 (syntax_error).

  • One row in the VALUES list has more/fewer values than the others.
  • Common in multi-row INSERTs.
  • Often a missing comma or value in one row.

What the server log shows

ERROR:  VALUES lists must all be the same length

Why PostgreSQL raises this — what the manual says

Section 7.7 VALUES Lists:

“Each parenthesized list of expressions generates a row in the table.”

A VALUES list forms a table where every row must have the same column count. A row of different length cannot fit the implied table shape, so PostgreSQL reports 42601.

Common causes

  • A row with a missing or extra value.
  • A misplaced comma splitting or merging values.
  • Generated multi-row INSERTs with inconsistent row widths.

How to fix it

  1. Ensure every VALUES row has the same number of expressions.
  2. Check for missing commas or stray values in the offending row.
  3. Validate generated INSERT SQL produces uniform rows.

Related & next steps

Reference: PostgreSQL 18 Section 7.7 “VALUES Lists”.

Was this helpful?