Don't use %s-with-precision format spec to truncate data being displayed
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 18 Jan 2004 02:15:57 +0000 (02:15 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 18 Jan 2004 02:15:57 +0000 (02:15 +0000)
commit598a57fb84b10d1d632b6fe6615027724ba66d95
tree270ea75418044bfcdb8572b4ce8b96eef1870a66
parent226257b3a5fea7cae78480f159fcb1c1f704ddf1
Don't use %s-with-precision format spec to truncate data being displayed
in a COPY error message.  It seems that glibc gets indigestion if it is
asked to truncate strings that contain invalid UTF-8 encoding sequences.
vsnprintf will return -1 in such cases, leading to looping and eventual
memory overflow in elog.c.  Instead use our own, more robust pg_mbcliplen
routine.  I believe this problem accounts for several recent reports of
unexpected 'out of memory' errors during COPY IN.
src/backend/commands/copy.c