[freetds] Adding NVARCHAR columns causes ct_cancel (ctlib) to hang

Gregory Holtorf gregory.holtorf at gmail.com
Fri Jan 16 17:17:04 EST 2015

When calling ct_cancel in the freetds library, on unix, ct_cancel()
sometimes takes several minutes to run. This is bad because it usually
takes a few milliseconds to run. This bug works on freetds-0.91 and
freetds-0.64 In order to reproduce the bug, I needed to:

1. Run a select statement on a large table

2. The table has to contain nvarchar columns. varchar columns do not
trigger the bug.

3. The select statement must contain an order by clause

  select <nvarchar columns>

  from <table name>

  order by <nvarchar column>

After completing the select statement, call ct_cancel(). For instance,
before you make another select statement or when you log out.

  ct_cancel(m_pCtConnection, NULL, CS_CANCEL_ALL);

When I turn on logging I can see that after I call ct_cancel() for the last
time, it is followed by an absolutely huge number of packets received.  I
attached a log file, but I had to force quit the program or else the log
file ends up being several thousand megabytes long.

Is there a way to fix this issue? Is freetds unable to make select
statements on nvarchar columns or is it something I did in my code?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: freetds.log
Type: application/octet-stream
Size: 260375 bytes
Desc: not available
URL: <http://lists.ibiblio.org/pipermail/freetds/attachments/20150116/3f0ff5eb/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: slowdowntest.cpp
Type: text/x-c++src
Size: 13985 bytes
Desc: not available
URL: <http://lists.ibiblio.org/pipermail/freetds/attachments/20150116/3f0ff5eb/attachment-0001.bin>

More information about the FreeTDS mailing list