alexbrainman / odbc

odbc driver written in go
BSD 3-Clause "New" or "Revised" License
352 stars 140 forks source link

Discard bad connections before Begin and Prepare, and improve cleanup in Close. #59

Closed ChrisHines closed 9 years ago

ChrisHines commented 9 years ago

Note that I also added connection tracking in the test code. That invaded the other tests, for which I apologize. Please suggest a better approach if you have one.

Fixes #58.

alexbrainman commented 9 years ago

New test fails in on both my linux:

=== RUN TestMSSQLRecoverFromCommitBadConn
--- FAIL: TestMSSQLRecoverFromCommitBadConn (0.01s)
mssql_test.go:1598: unexpected error return: should=driver: bad connection, is=SQLEndTran: {01000} [FreeTDS][SQL Server]Unexpected EOF from the server
mssql_test.go:1605: unexpected error return: should=driver: bad connection, is=already in a transaction
mssql_test.go:129: error closing DB: driver: bad connection
FAIL

and some windows environment:

--- FAIL: TestMSSQLRecoverFromCommitBadConn (0.03s) mssql_test.go:1605: unexpected error return: should=driver: bad connection, is=SQLDriverConnect: {08001} [Microsoft][SQL Server Native Client 10.0]Client unable to establish connection because an error was encountered during handshakes before login. Common causes include client attempting to connect to an unsupported version of SQL Server, server too busy to accept new connections or a resource limitation (memory or maximum allowed connections) on the server. {08001} [Microsoft][SQL Server Native Client 10.0]TCP Provider: An existing connection was forcibly closed by the remote host.

            {08001} [Microsoft][SQL Server Native Client 10.0]Client unableto establish connection
            {08001} [Microsoft][SQL Server Native Client 10.0]Client unableto establish connection due to prelogin failure
    mssql_test.go:132: unexpected ConnCount: should <= 0, is=1

=== RUN TestFoxPro --- PASS: TestFoxPro (0.06s) FAIL exit status 1 FAIL github.com/alexbrainman/odbc 1.359s

Alex

ChrisHines commented 9 years ago

I will try to test on Linux and work on tightening up the test code.

ChrisHines commented 9 years ago

@alexbrainman I simplified by testing directly against the driver interfaces instead of indirectly through the database/sql API. This version passes on for me on Windows 7 (against SQL Server 10 & 11) and CentOS 6 (against SQL Server 11).

alexbrainman commented 9 years ago

Thanks again.

Alex