Re: VARCHAR(max) in SP output params with TDS>=7.2 and rpc API

Frediano Ziglio <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <CAHt6W4dcoxVXSv9YLG+AC2=D=L00RwsME4Kk3NCGWNvUW8iYAA@mail.gmail.com>
2014-11-23 18:31 GMT+00:00 Ramiro Morales <[email protected]>:
> Hi all,
>
> I've found FreeTDS master can't handle the new in TDS 7.2 ability to
> handle values longer than 8000 chars.
>
> I've opened a merge request which adds tests that show the failure:
>
> https://gitorious.org/freetds/freetds/merge_requests/32
>

I saw the request. However tests should work with every version of Sybase/MSSQL

> I tried to modify the RPC parameter handling rpc API code to get this
> working by following what can be read at
> http://www.freetds.org/tds.html#login7 ('Types' sub-section):
>
> There is a call-out in that table for the XSYBVARBINARY, XSYBVARCHAR
> and XSYBNVARCHAR data types that reads:
>
> "* Under TDS 7.2+ these types allow size to be -1, representing
> varchar(max), varbinary(max) and nvarchar(max)."
>

This is true for protocol however I wouldn't use -1 as maxlen in
dbrpcparam call. maxlen define the buffer length for the pointer too.
I personally would pass the buffer byte length and if does not fit
into a normal (N)VARCHAR a (N)VARCHAR(MAX) should be used
automatically.

> Unfortuately my attemps were unsuccessful. I suspect what is described
> there doesn't apply to the RPC SP API.
>
> Any hints on how these data types need to be represented on the wire
> are welcome. I'd be willing to try to implement the required changes.
>
> Regards,
>
> PS: My use case is about output parameters, but it's possible input
> ones also need work. See https://github.com/pymssql/pymssql/issues/275
>
> --
> Ramiro Morales
> @ramiromorales

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.