[freetds] blk_init fails by the even number times execution

ZIGLIO, Frediano, VF-IT Frediano.Ziglio at vodafone.com
Fri Mar 9 08:14:51 EST 2007


> 
> Hello at beginning. 
> PLEASE HELP.
> 
> I want to execute blk_init two or more times as follows. 
> 
> It fails when it is 0.64 though it is possible to execute in 
> FreeTDS 0.63 without trouble. 
> Besides, the following error messages are returned by the 
> success only as for blk_init of 
> first time, the 3rd times, and the 6th times. 
> 
>  layer=2, no=5, len=84, msg=blk_init: blk layer: intl library 
> error: Failed when processing results from server.
> 
> Is there something insufficient in the procedure?
> 
> Judging from examining it here, it is anxious that neither 
> the transmission of the packet
> nor the reception are done in ct_cancel and the reception is 
> not done only by the transmission in blk_done. 
> 
> The environment is ..
> ・SUA on MS WindowsServer 2003 R2
> ・MS SQLServer 2005
> ・FreeTds 0.63/0.64
> 
> My best regards. 
> 
.....
> 
> dump
> | blk.c:232:blk_done()
> | net.c:673:Sending packet
> | 0000 07 01 00 26 00 00 01 00-81 01 00 00 00 0b 00 af 
> |...&.... ........|
> | 0010 0a 00 11 04 00 12 00 03-63 00 6f 00 6c 00 d1 05 
> |........ c.o.l...|
> | 0020 00 31 31 31 31 31      -                        |.11111|
> | 
> | util.c:119:Changing query state from IDLE to PENDING


Try this small patch

Index: src/ctlib/blk.c
===================================================================
RCS file: /cvsroot/freetds/freetds/src/ctlib/blk.c,v
retrieving revision 1.32
diff -u -1 -0 -r1.32 blk.c
--- src/ctlib/blk.c     20 Jul 2005 10:58:44 -0000      1.32
+++ src/ctlib/blk.c     9 Mar 2007 13:10:10 -0000
@@ -797,20 +797,21 @@
        blkdesc->insert_stmt = query;

        /*
         * In TDS 5 we get the column information as a result set from the "insert bulk" command.
         * We're going to ignore it.
         */
        if (tds_process_simple_query(tds) != TDS_SUCCEED) {
                _ctclient_msg(blkdesc->con, "blk_rowxfer", 2, 5, 1, 140, "");
                return CS_FAIL;
        }
+       tds_set_state(tds, TDS_QUERYING);

        /*
         * Work out the number of "variable" columns.  These are either nullable or of
         * varying length type e.g. varchar.
         */
        blkdesc->var_cols = 0;

        if (IS_TDS50(tds)) {
                for (i = 0; i < blkdesc->bindinfo->num_cols; i++) {



It's illegal to switch from IDLE to PENDING so you have to go to QUERYING. This is also logically correct. You shouldn't expect data if you don't send a request. Also issuing a "insert bulk" means that you want to send data!

freddy77



More information about the FreeTDS mailing list