[freetds] bulk copy and row buffer

Frediano Ziglio freddyz77 at tin.it
Mon Jun 7 13:46:41 EDT 2004

Looking at dblib problem (fixed) I found a bcp_column_data field in
This field is used by ctlib bulk code. More deeply it seems:

- dblib bulk code use BCP_COLINFO to hold bulk information
- ctlib bulk code use TDSCOLUMN to hold bulk information
- ctlib use bcp_column_data to store data buffer instead of current_row

The best solution should be use only TDSCOLUMN (dblib and ctlib) and put
code in libTDS (not that easy however).
About current_row... libTDS use only current_row. This is good for
results (cause you can construct entire row at once using RESULT_INFO
token and so on), however sending data (store procedure/prepared
statement/bulk copy) it's another story. 
- Bill use different code both in bulk library and cursors
- Steve Kirkendall for his server patch used column_offset in a weird
and hard way
I must admit that coding ODBC using current_row was not that easy:
- sometimes you don't know size before, you have to parse parameters one
by one extending current_row
- it's also hard to add fixed parameters (needed to support fixed
parameters in {call()} syntax, see TODO)
- in libTDS there are a lot of is_blob_type just to decide if buffer
it's a structure pointing to data or just a buffer. 
However current_row have also some good things:
- it's easy to buffer rows (there is only a problem with
column_cur_size, it should be store in current_row, not in TDSCOLUMN!!!)
- it save space cause we pack data together (who follow this ML know
that we coded sending data after retrieving so this was the main reason)

I have some ideas to fix this stuff but they are very confused:
- put column_cur_size in current_row to fix buffering problem. Where to
put?? like null (before all data) or with data ?
- perhaps we should use an unique value for column_cur_size to say null
(I propose -1) ??
- add a flag in TDSCOLUMN to say if data in current_row it's a structure
or a binary buffer (and use pointer not just for image/text but even for
- use a structure of [pointer, size] in current_row before all data then
static data (pointed by pointer), remove column_offset and
column_cur_size from TDSCOLUM


More information about the FreeTDS mailing list