[freetds] Patch for freebcp -h processing

Konrad J Hambrick konrad at jax01.payplus.com
Sun May 14 10:27:13 EDT 2006


All --

I mucked about in the freebcp.c source code to make the
freebcp -h (hints) work

see my previous post 're: freebcp -h TABLOCK syntax'.

A .patch file against freetds-0.65.dev.20060512 is attached.

I found if I moved the call to bcp_options() out of the
login_to_database() function and copied it into each of

    file_character(),
    file_native() and
    file_formatted()

just after the bcp_init() calls in each function, the hints
were accepted by SQL Server 2000.

IOW, these changes eliminated the

    Msg 20076, Level 7
    bcp_init must be called before any other bcp routines
    db-lib: Unable to set hint "TABLOCK"
    bcp reports error 1

Errors when trying to pass hints to SQL Server via freebcp.

I also noticed that the

    if (erc != SUCCEED)

block inside the if (pdata->hint){ } block seemed to be
missing a curly brace ...

I added that to each of the bcp_options(){ } blocks in the
file_character(), file_native() and file_formatted() procs.

Finally, just because I like immediate gratification <G>,
I changed

    printf("\nStarting copy...\n\n")          to

    fprintf(stderr, "\nStarting copy...\n\n")

and

    printf("%d rows copied.\n", li_rowsread)  to

    fprintf(stderr, "%d rows copied.\n", li_rowsread)

so that the messages are dumped immediately to stderr rather
than being buffered to stdout.

Do these changes seem reasonable ?

Thanks for freetds guys !  I would be stuck trying to script
my data warehouse loads on Win2005 without it !

-- kjh

-------------- next part --------------
A non-text attachment was scrubbed...
Name: freetds-0.65.dev.20060512-diff-c.patch
Type: text/x-patch
Size: 4827 bytes
Desc: not available
Url : http://lists.ibiblio.org/pipermail/freetds/attachments/20060514/5dafa29d/attachment.bin 


More information about the FreeTDS mailing list