[freetds] [PATCH] bcp columns too small
Craig A. Berry
craigberry at mac.com
Fri Jan 21 23:48:13 EST 2005
I encountered a bug doing a bcp in with RC9's freebcp where a character
column in the client's charset occupies more space than the same column
in the server's charset. In my case, I've set the client charset to
UTF-8 and the server's is ISO-8859-1.
When dbconvert is called from _bcp_read_hostfile, it space fills up to
the length of curcol->column_size, which is determined from the client's
charset, but the data area is only allocated according to the server's
charset (curcol->on_server.column_size). So, for example, a char(6)
field in ISO-8859-1 could take up to 24 bytes in UTF-8. We only allocate
6 bytes (or 6 + 1?), but later space fill all 24 bytes, including 18
bytes that belong to something else. This obviously causes a memory
accesss error if we're lucky, or corrupted data if we're not.
The attached patch deals with the problem by modifying the way column
memory is allocated. It simply allocates based on whichever column size
is larger, server or client.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the FreeTDS