BUG #19642: Include column name in error message when varchar(n) length limit is exceeded

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: killerwzb(at)gmail(dot)com
Subject: BUG #19642: Include column name in error message when varchar(n) length limit is exceeded
Date: 2026-08-28 04:28:42
Message-ID: 19642-5e93d3e409f1387c@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 19642
Logged by: zhibin wang
Email address: killerwzb(at)gmail(dot)com
PostgreSQL version: 18.4
Operating system: centos7
Description:

Dear PostgreSQL Developers,
I am writing to suggest an improvement to the error reporting mechanism for
data type length constraints.
Currently, when an insertion fails due to exceeding the varchar(n) limit,
the error message only states that the value is too long for the type, but
it does not specify which column caused the failure.

1. Current Behavior:
When executing:
CREATE TABLE users (
id SERIAL PRIMARY KEY,
username VARCHAR(10) NOT NULL,
email VARCHAR(255)
);

INSERT INTO users (username) VALUES ('123456789012'); -- 12 chars
The error returned is:
ERROR: value too long for type character varying(10)

2. The Pain Point:
In tables with many columns (e.g., a wide table with 50+ columns), or when
performing bulk inserts via ORM/ETL tools, it is often difficult to
immediately identify which specific column triggered this generic error.
Developers have to manually check the length of every input field against
the schema definition.

3. Suggestion:
It would be extremely helpful if the error message could explicitly include
the column name.
Proposed Error Message Format:
ERROR: value too long for column "username" (type character varying(10))
Or alternatively:
ERROR: value too long for type character varying(10) in column "username"

4. Benefits:
Faster Debugging: Developers can instantly locate the problematic field
without guessing.
Better UX for Tools: GUI clients and ORMs can parse this error more
accurately to highlight the specific field in the UI.
Thank you for considering this suggestion to improve the developer
experience!

Best regards,
Zhibin Wang.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Daniel Gustafsson 2026-08-28 07:13:55 Re: autovacuum: automatically propagate updated parameters
Previous Message PG Bug reporting form 2026-08-28 04:10:09 BUG #19641: Unexpected results on an SP-GiST indexed column with a non-deterministic collation