[freetds] tds_connect does too much

James K. Lowden jklowden at freetds.org
Thu Jul 10 11:33:29 EDT 2008


ZIGLIO, Frediano, VF-IT wrote:
> 
> Mmm... tds_send_login is not that fine, perhaps it's better to rename
> tds_login structure to  _tds_login (cause we only use TDSLOGIN) and add
> a tds_login.

Good observation. s/tds_login/tds_login_t/g perhaps? 


> auto as protocol version, now tds_connect connect and disconnect 
> as it wants...

Does the server disconnect if the login fails?  If not, we can keep
re-trying login packets on the same connection.  

Otherwise, I imagine this (simplified):


	if ((conn = tds_connect()) == NULL)
		return tdserror();
	else
		tds_login();

and in tds_login():
	
	if (tdsver == 0) {
		for( i=0; i < maxver; i++ ) {
			tdsver = versions[i];
			int fOK = tds_login(tdsver);
			if( fOK )
				return fOK;

			if ((conn = tds_connect()) == NULL)
				return tdserror();
		}
	}
	if (i == maxver)
		return tdserror();

	/* call tdsX_send/do_login function  ... */

There are other ways, too, of course.  

Regards, 

--jkl



More information about the FreeTDS mailing list