[freetds] bcp CHAR behavior
James K. Lowden
jklowden at schemamania.org
Thu Apr 15 22:41:11 EDT 2004
src/dblib/bcp.c:1107:
if (desttype == SYBVARCHAR) {
bcpcol->data_size =
_bcp_rtrim_varchar((char *) bcpcol->data, converted_data_size);
} else {
bcpcol->data_size = converted_data_size;
}
I ran across what might be a little bug in the above code today. I was
loading a tab-delimited file; column two in the table was a char(2).
freebcp was complaining. (The actual message was bogus iirc, something
about inserting a NULL into a non-null column.) The real problem was that
the field contained a trailing blank:
'AR '
You can imagine it took a bit of hunting, because the error file didn't
exactly highlight the space before the tab.
Microsoft's bcp.exe loaded the file fine, after I DOSified it. So they
trim the trailing blank for char & varchar fields. Maybe for everything?
I wonder how Sybase's utility behaves. I think I may change the above to
call _bcp_rtrim_varchar() every time.
Any insights?
--jkl
More information about the FreeTDS
mailing list