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
- Ensure every VALUES row has the same number of expressions.
- Check for missing commas or stray values in the offending row.
- Validate generated INSERT SQL produces uniform rows.
Related & next steps
Reference: PostgreSQL 18 Section 7.7 “VALUES Lists”.
Thanks — noted. This helps keep the database accurate.