[freetds] db-lib: support for new MS SQL 2008 data types - part 2

Frediano Ziglio freddy77 at gmail.com
Sat Apr 5 12:25:24 EDT 2014

2014-04-04 11:00 GMT+01:00 LacaK <lacak at zoznam.sk>:
> Now I can read successfuly:
> - dbcoltype() returning SYBMSDATE, SYBMSTIME, SYBMSDATETIME2
> I am trying do next small step.
> As far as I understand dbdata() function for SYBMSDATE, SYBMSTIME,
> SYBMSDATETIME2 return pointer to TDS_DATETIMEALL struct.
> (dbdata() internally uses: return (BYTE *) colinfo->column_data)

Well.... dbdata returns any possible column_data stored. This does not
exactly means that is correct for these types. All other types are
coded as wire data while these type use an internal encoding defined
by our library.

> If it is so I need some way how to convert TDS_DATETIMEALL struct to
> DBDATEREC struct.
> (which is good readable)
> There is already function:
>  dbdatecrack(DBPROCESS * dbproc, DBDATEREC * output, DBDATETIME * datetime)
> but it takes as 3rd parameter DBDATETIME struct, which is struct used by old
> "datetime" data type SYBDATETIME)
> So my idea is introduce new API function:
>  tdsdbdatecrack(DBPROCESS * dbproc, INT datetype, DBDATEREC * output, const
> void *datetime)
> (like we have tdsdbopen() vs dbopen())
> Where datetime can be pointer to either old DBDATETIME or new
> TDS_DATETIMEALL, depending on datetype supplied

Could work. You can use tds_datecrack to help you.

> What is your opinion on that?
> I am asking for sure about every step, because I am not so familiar with
> internals.
> Thanks
> -Laco.

Here the problem is not internals but dblib. There is no definition on
how to extend this library. There's also a problem on the precision of
DBDATEREC which do not take into account fraction of seconds beside


More information about the FreeTDS mailing list