Richard Hughes | 16 Apr 20:12 2014

MS query notifications patch

Hi all,

I needed support for SQL Server 2005's Query Notifications feature, so
here's a patch against tip.

I've only given the patch a light sprinkling of testing so far, but
could I ask somebody to review it and confirm that I'm on the right
track so that I can create a v2 patch that is (hopefully) mergeable?
Both the Microsoft API and the TDS implementation feel extremely
kludgy to me and hence some of that kludginess needed to be reflected
in the patch; sorry about that, but don't shoot the messenger.

About Query Notifications:

Query Notifications are designed to support client-side caching of
datasets by providing a mechanism to allow the application to be
notified whenever its cache may have become out of date (i.e. because
somebody updated the underlying table(s)). Fundamentally the feature
works by delivering a query to the server and, rather than executing
it, the server does internal magic to register that query and a
user-specified cookie. When the result set that the query would have
returned (had it actually been executed) changes, the cookie is
delivered back to the caller through a WAITFOR/RECEIVE statement.

User-level doc:
Protocol doc:

Only the registering of the query and cookie with the server needs
FreeTDS changes. The WAITFOR statement is just executed as a normal
statement with a normal result set.
(Continue reading)

LacaK | 16 Apr 13:44 2014

db-lib: support for new MS SQL 2008 data types - part 3

Hi again,
Now I am personally happy with patched db-lib in regards of support new 
DATE - TIME data types.
But there are still missing some parts, which may be interesting to 
somebody else.
I meant dbbind() family of API with corresponding *BIND constants and 
binary structure used to store this types.

How to handle binding of new date, time types ?

- introduce new DBDATETIMEALLBIND (or DBDATETIME2BIND) constant in sybdb.h ?
- introduce new DBDATETIMEALL struct (==TDS_DATETIMEALL struct) in 
sybdb.h  ?
- add support to copy_data_to_host_var() function in dblib.c ?

If you give me direction I can prepare patch ...
(if it is good idea add support for BINDing ?)
Geoff Montee | 8 Apr 14:39 2014

Microsoft SQL Server versions and FreeTDS

I wrote an open source TDS foreign data wrapper for PostgreSQL using your
implementation of DB-Library:

I mainly wrote it to connect to Sybase databases, but its compatibility
with Microsoft SQL Server is a nice added benefit.

Your TDS protocol page hasn't been updated in a while:

It's missing MS SQL Server 2008 R2, MS SQL Server 2012, and MS SQL Server
2014. I'm curious, does your implementation of DB-Library support these
newer versions of MS SQL Server? I ask because Microsoft's own
documentation says that they may drop DB-Library support in the future:

"While the DB-Library API is still supported in Microsoft SQL Server 2000,
no future versions of SQL Server will include the files needed to do
programming work on applications that use this API. Connections from
existing applications written using DB-Library will still be supported in
the next version of SQL Server, but this support will also be dropped in a
future release. When writing new applications, avoid using DB-Library. When
modifying existing applications, you are strongly encouraged to remove
dependencies on DB-Library."


(Continue reading)

LacaK | 8 Apr 12:08 2014

tds_get_size_by_type for SYBMSDATE

when I look into tds_types.h (which is build on misc/types.csv) there is 
function tds_get_size_by_type() used f.e. by dbconvert()
And for SYBMSDATE it returns 4 (IMO it is wrong set size=4 in types.csv)
Is it correct ?
(as far as I understand it should be size if struct which holds this 
data type i.e.:
there should be:
     return sizeof(TDS_DATETIMEALL);

When I change it this way, it works as expected for me.
PrasannaLakshmi.Kandula | 8 Apr 08:56 2014



We got a 64 bit Linux with both 32 bit and 64 bit libraries. We have our 32 bit  application running in same box.
We want to connect to SQL server 2008 from our application using FreeTDS drivers. Problem is how to compile
and install freetds in 32 bit mode. By default, we followed the process of installation as per the FreeTDS
documentation in our 64 bit Linux, it is installing as 64 bit drivers.

Can you please suggest some way so that we can compile and use it in 32 bit mode under 64 bit Linux.


This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may
contain confidential and privileged information. If you are not the intended recipient(s), please
reply to the sender and destroy all copies of the original message. Any unauthorized review, use,
disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in
reliance on the contents of this e-mail is strictly prohibited and may be unlawful.
LacaK | 3 Apr 13:48 2014

db-lib: support for new MS SQL 2008 data types

I start with first, very small, steps to add support for DATE, TIME and 
DATETIME2 data types to db-lib.
I attach patches for:
- src/dblib/dblib.c
- src/tds/token.c
let me please know if you can accept (and commit) them.
Then I will try do further steps.
--- token.c.ori	Thu Apr 03 13:32:02 2014
+++ token.c	Thu Apr 03 11:04:48 2014
 <at>  <at>  -3016,6 +3016,7  <at>  <at>  tds_prtype(int type)
 		TYPE(XSYBVARCHAR, "xvarchar");
 		TYPE(SYBMSDATE, "date");
 		TYPE(SYBMSTIME, "time");
+		TYPE(SYBMSDATETIME2, "datetime2");
--- dblib.c.ori	Mon Mar 31 22:34:14 2014
+++ dblib.c	Thu Apr 03 13:39:42 2014
 <at>  <at>  -224,6 +224,9  <at>  <at>  DBVERSION_71;
 #ifdef TDS72
(Continue reading)

LacaK | 2 Apr 16:08 2014

Compiling db-lib using Visual C++ 2005 Express

I am trying compile dblib.dll using Microsoft Visual C++ 2005 Express
I use freetds-master/FreeTDS.sln as starting point (after time I have 
added some missing files)
But I still can not resolve these errors:
tds.lib(mem.obj) : error LNK2001: unresolved external symbol 
tds.lib(config.obj) : error LNK2001: unresolved external symbol 
tds.lib(mem.obj) : error LNK2001: unresolved external symbol _tds_socketpair
tds.lib(config.obj) : error LNK2001: unresolved external symbol 
tds.lib(net.obj) : error LNK2001: unresolved external symbol 
replacements.lib(win_mutex.obj) : error LNK2001: unresolved external 
symbol _TryEnterCriticalSection
Any suggestions?
Frediano Ziglio | 1 Apr 10:53 2014

Current snapshot broken

  there are actually two problems with current snapshot

1. freetds-current.tgz points to the oldest snapshot, not the last one

2. I changed (
quite recently the directories used for reference and userguide.
Instead of doc/doc/freetds-VERSION/SUBDIR (where SUBDIR is either
reference or userguide) to just doc/SUBDIR. On my local machine it
works. There were a small problem with previous directories fixed (or
believed to be fixed) by
Today however I downloaded the new snapshot and somethings went wrong:
- userguide is empty with just a single web page pointing to (expected if userguide fails to compile or openjade is
not present);
- reference is still a link (to doc/freetds-dev.0.92.695/reference
which is an old directory not packaged)

James, what do logs say?

sales | 29 Mar 19:12 2014

Re: FreeTDS Digest, Vol 134, Issue 5

I noticed that the only way to pass and receive parameters is using TDS 4.1.
How do we do this using newer TDS versions? I have failed to do that.
I use unixODBC with FreeTDS underneath.

--------- Original Message --------- Subject: FreeTDS Digest, Vol 134, Issue 5
From: freetds-request <at>
Date: 3/29/14 12:00 pm
To: freetds <at>

Send FreeTDS mailing list submissions to
 freetds <at>

 To subscribe or unsubscribe via the World Wide Web, visit
 or, via email, send a message with subject or body 'help' to
 freetds-request <at>

 You can reach the person managing the list at
 freetds-owner <at>

 When replying, please edit your Subject line so it is more specific
 than "Re: Contents of FreeTDS digest..."

 Today's Topics:

 1. Re: dblib and output parameters of stored procedures
 (James K. Lowden)

(Continue reading)

LacaK | 27 Mar 13:09 2014

dblib and output parameters of stored procedures

Hi list,
I am trying work with output parameters of stored procedures using 
FreeTDS dblib
I am calling stored procedure using:
  "declare  <at> p int; EXEC pokus 1,  <at> p OUTPUT"
after that call I am trying read count of output parametres using:
but it still returns 0
(same example tested with Microsoft ntwdblib returns 1)

Please see attached log file.
As you can see there is line:
  dblib.c:4742:..\..\src\dblib\dblib.c 4743: logic error: 
tds_process_tokens result_type 4043

Deos it explain reason why it does not work?


write.c:140:tds_put_string converting 39 bytes of "declare  <at> p int; EXEC 
pokus 1,  <at> p OUTPUT"
write.c:168:tds_put_string wrote 78 bytes
util.c:156:Changed query state from QUERYING to PENDING
net.c:741:Sending packet
0000 01 01 00 56 00 00 01 00-64 00 65 00 63 00 6c 00 |...V.... d.e.c.l.|
0010 61 00 72 00 65 00 20 00-40 00 70 00 20 00 69 00 |a.r.e. .  <at> .p. .i.|
0020 6e 00 74 00 3b 00 20 00-45 00 58 00 45 00 43 00 |n.t.;. . E.X.E.C.|
0030 20 00 70 00 6f 00 6b 00-75 00 73 00 20 00 31 00 | .p.o.k. u.s. .1.|
0040 2c 00 20 00 40 00 70 00-20 00 4f 00 55 00 54 00 |,. . <at> .p.  .O.U.T.|
(Continue reading)

Marc Abramowitz | 1 Mar 19:27 2014

Fwd: [Still Failing] FreeTDS/freetds#61 (master - 03b8a23)

Not sure if folks are seeing the test failures or not. 

Should I set the Travis CI email to this list?

Hmm. That might be too spammy. Maybe create a separate mailing list like FreeTDS-builds or FreeTDS-dev
which people can opt into and then I can have Travis send emails to that?

Sent from my iPhone 4S

Begin forwarded message:

> From: Travis CI <notifications <at>>
> Date: March 1, 2014, 10:08:36 AM PST
> To: <msabramo+freetds_travis_ci <at>>
> Subject: [Still Failing] FreeTDS/freetds#61 (master - 03b8a23)
>  FreeTDS / freetds (master)
> Build #61 is still failing.	 2 minutes and 41 seconds
> 	Frediano Ziglio	03b8a23 Changeset →
>  	Generate random data with GnuTLS if available
> This increase security if GnuTLS is used.
> Signed-off-by: Frediano Ziglio <freddy77 <at>>
>            	Documentation about Travis CI
> For help please join our IRC channel
(Continue reading)