Skip to Content.
Sympa Menu

freetds - Re: [freetds] tds_get_size_by_type for SYBMSDATE

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] tds_get_size_by_type for SYBMSDATE
  • Date: Wed, 9 Apr 2014 20:21:45 -0400

On Wed, 9 Apr 2014 12:41:53 +0100
Frediano Ziglio <freddy77 AT gmail.com> wrote:

> Is size the size of the network bytes we receive from
> the server or is the size of the structure stored by libTDS for this
> type? Actually the table reply with the first (network bytes) but you
> are changing with the last (structure bytes). The problem is really
> this, the function is used for both purposes :(

Generally in C, we have the sizeof operator to tell us how big
something is. The purpose of tds_get_size_by_type is to map the
type token integer "servertype" to a number of bytes that will be read
off the wire. That's all it should ever do. :-)

When tds_convert gets into the picture, we're no longer working with an
amorphous string of bytes. We have a known type, and we're converting
to a known type. The only "unknown" is in the case of a string target:
how many bytes will be needed to represent the int/float/date/etc.?

That question is answered by tds_willconvert(). Originally it returned
boolean, but I changed it to an output size because the logic
substially overlapped another "how big will it be" function that we
were then able to drop.

HTH.

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page