[freetds] dblib bcp, t0017 broken

Thompson, Bill D (London) bill_d_thompson at ml.com
Fri Jan 27 08:56:15 EST 2006


Hi Freddy,

I don't understand code in bcp.c lines 1240 onwards.
This is yours and james' code...

what is this byte its reading ?
I don't understand what the program is expecting to find here...

code used to read (long time ago) ...

} else { /* unterminated field */
    if (collen) 
       if (fread(coldata, collen, 1, hostfile) != 1) {
          _bcp_err_handler(dbproc, SYBEBCRE);
          return (FAIL);
       }
    }
}

Bill

-----Original Message-----
From: freetds-bounces at lists.ibiblio.org
[mailto:freetds-bounces at lists.ibiblio.org] On Behalf Of ZIGLIO,
Frediano, VF-IT
Sent: 27 January 2006 13:29
To: FreeTDS Development Group
Subject: Re: [freetds] dblib bcp, t0017 broken


> 
> Freddy
> 
> $ od -x t0017.in
> 
> 0000000 0411 2233 4445 0000 0070 726f 7661 2064
> 0000020 6920 7465 7374 6f20 7175 6573 746f 2074
> 0000040 6573 746f 2064 6f76 7265 6262 6520 616e
> 
> so in the file there is a one byte prefix-len for the integer 
> but we're telling bcp there is no prefix (because column is 
> not null on
> database)
> 
> 11:56:31.013669 parsing host column 1
> 11:56:31.013725 prefix_len = 0 collen = 0
> 11:56:31.013765 Reading 4 bytes from hostfile.
> 
> remove that 1st byte form the file and things go much better...
> 
> "strange" data...
> 
> 0030 00 30 00 30 00 31 00 37-00 02 63 00 32 00 d1 44 
> |.0.0.1.7 ..c.2..D|
> 0040 33 22 11 10 ff ff ff ff-ff ff ff ff ff ff ff ff 
> |3"...... ........|
> 0050 ff ff ff ff ff ff ff ff-ff ff ff ff 45 00 00 00 
> |........ ....E...|
> 0060 70 72 6f 76 61 20 64 69-20 74 65 73 74 6f 20 71 |prova 
> di  testo q|
> 0070 75 65 73 74 6f 20 74 65-73 74 6f 20 64 6f 76 72 |uesto 
> te sto dovr|
> 0080 65 62 62 65 20 61 6e 64-61 72 65 20 61 20 66 69 |ebbe 
> and are a fi|
> 0090 6e 69 72 65 20 69 6e 20-75 6e 20 63 61 6d 70 6f |nire in 
>  un campo|
> 00a0 20 74 65 78 74         -                        | text|
> 
> d1           = row marker
> 44 33 22 11  = int data
> 
> 0x10         = 16
> followed by 16 * 0xff
> 
> This is the dummy textptr 
> 
> followed by 8 * 0xff
> 
> this is Dummy timestamp
> 
> 45 00 00 00 length of text data to follow = 69
> 
> followed by 69 bytes of (italian) text
> 
> HTH,
> 
> Bill
> 

Ok, so mainly table creation is broken. However trying to analyze the
problem I did this
- create table (null int, text instead of int, text)
- insert data
- bulk out
- bulk in the same file (output was a byte to byte copy of t0017.in)
I caused the nightmare... doing bulk in what happen for nullable int ??
- row 1099 (bcp.c) we read the prefix from file, collen == 4
- row 1171 there is no terminator, skip
- row 1240 nullable, so we read a byte to set collen, now collen = 17
(0x11) and we read an unwanted bye
- row 1288 we read 17 bytes for an integer
- row 1315 and following we set bcp_column_data->data and related
- we loose sync so we read an invalid length for text, malloc return
NULL and we return error
So we are not able to load data we dumped...

freddy77
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
--------------------------------------------------------

If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Click here for important additional terms relating to this e-mail.     http://www.ml.com/email_terms/
--------------------------------------------------------


More information about the FreeTDS mailing list