Created attachment 473945 [details]
Test program demonstrating the error
Description of problem:
Executing a parameterless ODBC prepared statement which is >= 505 bytes long against SQL Server results in a protocol error that causes SQL Server to drop the connection, which causes freetds to report "Unexpected EOF from the server".
Version-Release number of selected component (if applicable):
freetds-0.82 as packaged with Fedora 11+
Steps to Reproduce:
1. SQL[Driver]Connect() to a SQL Server database
2. SQLPrepare() a query >= 505 bytes long
See attached test program.
Error: [FreeTDS][SQL Server]Unexpected EOF from the server
Query executes successfully
This seems to be the result of the freetds 0.82 package shipped with all current Fedora releases not including a change that was checked into the upstream repository over two years ago: See http://freetds.cvs.sourceforge.net/viewvc/freetds/freetds/src/tds/query.c?view=log&pathrev=BRANCH0_82;
the current packages appear to contain revision 184.108.40.206; the change in question is revision 220.127.116.11 "fix tds_send_emulated_execute if no parameters".
Applying this simple, one-line change allows long queries to be executed successfully.
Created attachment 473946 [details]
Proposed patch against freetds-0.82
Proposed patch (taken from http://freetds.cvs.sourceforge.net/viewvc/freetds/freetds/src/tds/query.c?r1=18.104.22.168&r2=22.214.171.124&pathrev=BRANCH0_82)
It seems that the error can be avoided if the TDS_Version parameter is included in the connection string and set to either 7.0 or 8.0 (assuming, of course, that the server supports these versions). This is because a slightly different path is taken through the statement execution code which avoids the problematic line.
freetds-0.82.1-0.1.20100810dev.fc14 has been submitted as an update for Fedora 14.
freetds-0.82.1-0.1.20100810dev.fc13 has been submitted as an update for Fedora 13.
freetds-0.82.1-0.1.20100810dev.fc14 has been pushed to the Fedora 14 testing repository. If problems still persist, please make note of it in this bug report.
If you want to test the update, you can install it with
su -c 'yum --enablerepo=updates-testing update freetds'. You can provide feedback for this update here: https://admin.fedoraproject.org/updates/freetds-0.82.1-0.1.20100810dev.fc14
freetds-0.82.1-0.2.20100810dev.fc15 has been submitted as an update for Fedora 15.
freetds-0.82.1-0.2.20100810dev.fc14 has been submitted as an update for Fedora 14.
freetds-0.82.1-0.2.20100810dev.fc13 has been submitted as an update for Fedora 13.
freetds-0.82.1-0.3.20110306dev.fc15 has been submitted as an update for Fedora 15.
freetds-0.82.1-0.3.20110306dev.fc14 has been submitted as an update for Fedora 14.
freetds-0.82.1-0.3.20110306dev.fc15 has been pushed to the Fedora 15 stable repository. If problems still persist, please make note of it in this bug report.
freetds-0.82.1-0.3.20110306dev.fc14 has been pushed to the Fedora 14 stable repository. If problems still persist, please make note of it in this bug report.