[freetds] varbinary(MAX) and DBCOL.MaxLength

LacaK lacak at zoznam.sk
Mon Mar 2 01:51:19 EST 2015


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?

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


More information about the FreeTDS mailing list