Re: varbinary(MAX) and DBCOL.MaxLength

Frediano Ziglio <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <CAHt6W4fO0qwx54P2U7uySUCofWXwEXQj-+hJL5CkB9O7PJQgjA@mail.gmail.com>
Il 02/Mar/2015 10:01 "LacaK" <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.