[freetds] ctlib bulk text copy segmentation fault

Patrick Dunnigan patrick.dunnigan at centivia.com
Mon Mar 7 12:16:30 EST 2005


Hi All,
I am attempting to do a bulk copy IN in a SQL Server 2000 table that has two columns, an INT and a TEXT using freeTDS  0.63RC9 on RH 7.3 using TDS 8.

The binds seem to be returning properly. When I call the blk_rowxfer function it produces a "segmentation fault". I have traced it down to the cs_convert call performed inside _blk_get_col_data (as below) in blk.c for the second column in the database table - the TEXT field. Further the segmentation fault occurs because of the 6th parameter: bindcol->bcp_column_data->data. 

result = cs_convert(ctx, &srcfmt, (CS_VOID *) src, &destfmt, (CS_VOID *) bindcol->bcp_column_data->data, &destlen);

Now when I do nothing but change the fieldtype in SQL Server to say VARCHAR, the bulk copy works without modifying my bind parameters (which are set to the Text variety. If I change the database field type back to TEXT, it fails.

I know it's the bindcol->bcp_column_data->data parameter (pointer to the destination data buffer) because I created a stub function with  printf and return statement only inside and removed each parameter until it successfully called the function and returned. 

With this parameter in the cs_convert call, it does a segmentation fault just by simply calling the function. The blk_bind for this column appears to be functioning properly and is returning with a CS_SUCCEED.

Therefore my questions for the community are as such:
- Are bulk text inserts even possible with freeTDS and MSSQL? 
- I've been through the examples and on the web, examples of TEXT bulk copies are sparse. Any guidence?
- What other info can I provide? I can provide the code if needed, I basically took the bulk copy in example from src/ctlib/unittests and modified it for the text operation.

Thanks
Patrick


More information about the FreeTDS mailing list