[freetds] varbinary(MAX) and DBCOL.MaxLength

Frediano Ziglio freddy77 at gmail.com
Mon Mar 2 08:13:33 EST 2015


Il 02/Mar/2015 10:01 "LacaK" <lacak at zoznam.sk> ha scritto:
>
> Hi *,
> I have table with columns with these types:
>   XML,
>   varchar(MAX),
>   nvarchar(MAX),
>   varbinary(MAX)
> When I use dbtablecolinfo() I receive DBCOL structure with these
MaxLength (or dbcollen()):
>   2147483647 (=2^31-1)
>   2147483647
>   2147483647
>   1073741823 (=2^30-1)
> I am wondering about varbinary(MAX), I would expect 2147483647 for them
also.
> (as SQL Server documentation says, that maximum storage size is 2^31-1
bytes)
> Why is there 2^30-1 , is it okay?
>

Quite odd indeed. I would expect XML and nvarchar could be half not
varbinary. Could be the conversion from hexadecimal to binary? I don't
remember where these constants came. From server or just code I don't know.

> Thanks
> -Laco.
>
> Here is part of tds dump:
>
> token.c:1537:tds7_get_data_info:
>     colname = xml_field
>     type = 241 (xml)
>     server's type = 241 (xml)
>     column_varint_size = 8
>     column_size = 2147483647 (2147483647 on server)
>
> token.c:3148:adjust_character_column_size:
>     Server charset: CP1250
>     Server column_size: 1073741823
>     Client charset: UTF-8
>     Client column_size: 2147483647
> token.c:1537:tds7_get_data_info:
>     colname = varcharmax_field
>     type = 39 (varchar)
>     server's type = 167 (xvarchar)
>     column_varint_size = 8
>     column_size = 2147483647 (1073741823 on server)
>
> token.c:3148:adjust_character_column_size:
>     Server charset: UCS-2LE
>     Server column_size: 1073741823
>     Client charset: UTF-8
>     Client column_size: 2147483647
> token.c:1537:tds7_get_data_info:
>     colname = nvarcharmax_field
>     type = 39 (varchar)
>     server's type = 231 (x UCS-2 varchar)
>     column_varint_size = 8
>     column_size = 2147483647 (1073741823 on server)
>
> token.c:1537:tds7_get_data_info:
>     colname = varbinarymax_field
>     type = 37 (varbinary)
>     server's type = 165 (xvarbinary)
>     column_varint_size = 8
>     column_size = 1073741823 (1073741823 on server)
>
> token.c:1609: name                 size/wsize      type/wtype utype
> token.c:1610: -------------------- --------------- --------------- -------
> token.c:1615: xml_field            2147483647/2147483647 241/241
 0
> token.c:1615: varcharmax_field     2147483647/1073741823 39/167
 0
> token.c:1615: nvarcharmax_field    2147483647/1073741823 39/231
 0
> token.c:1615: varbinarymax_field   1073741823/1073741823 37/165
 0
>

Frediano


More information about the FreeTDS mailing list