[freetds] tds_get_size_by_type for SYBMSDATE

James K. Lowden jklowden at freetds.org
Wed Apr 9 20:21:45 EDT 2014

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.  



More information about the FreeTDS mailing list