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

Started by PG Bug reporting form24 days ago2 messagesbugs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following bug has been logged on the website:

Bug reference: 19642
Logged by: zhibin wang
Email address: killerwzb@gmail.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.

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: PG Bug reporting form (#1)
Re: BUG #19642: Include column name in error message when varchar(n) length limit is exceeded

On Fri, Aug 28, 2026 at 8:57 AM PG Bug reporting form <
noreply@postgresql.org> wrote:

The following bug has been logged on the website:

Bug reference: 19642
Logged by: zhibin wang
Email address: killerwzb@gmail.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.

This is not a bug; and it is a frequent feature request you should be able
to find prior discussions for in the mailing list archives.

If you think you can contribute to moving efforts forward on getting
something like this implemented you should peruse the archives to figure
out why it hasn't been accomplished yet. Otherwise, just know that your
voice has been heard and it may or may not be something that gets
implemented in the future.

David J.