Hi everybody again,
on our production servers I have quite some errors due to excessively long varchar-values which application-code tries to insert into tables and which don't fit.
The tables have many columns, the statements are not readable and many columns happen to have the same length. Powers of 2 most often for some odd reason ...
I fired up gdb and saw that the error message is generated during the preprocessing of the query where some kind of the constant-folding/constant-elimination happens on the parse-tree. I went ahead and added a try/catch at some point upwards in the call-stack where at least i have the contact of the T_TargetEntry. That has a field resname which gives me exactly the information i need... The column which was overflown. With that info i can fix the application code much more easily. Relation name was out of reach for me, there is a void* passed transparently to the constant-mutator but that is not checkable at the point. That context contains the original top-level statement node however.
The patch just adds a bit of hinting to the error message and goes on.. That is all but really helpful to me and potentially also others.
Attached Patch has more Infos and comments.

Regards from Germany,
Stepan
Stepan Rutz
Phone: +49 (0) 178 654 9284
Email: stepan.rutz@gmx.de
Earth: Brunnenallee 25a, 50226 Frechen, Germany