Re: tds_get_size_by_type for SYBMSDATE

"James K. Lowden" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
On Wed, 9 Apr 2014 12:41:53 +0100
Frediano Ziglio <[email protected]> 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
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.