Skip to Content.
Sympa Menu

freetds - Re: [freetds] issue with connecting ms sql azure

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Andy Qian <andyq AT intapp.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] issue with connecting ms sql azure
  • Date: Fri, 30 Sep 2011 10:40:11 -0700

James,

thank you very much for your explanation and suggestions.

I will read ct-lib and corresponding code in DBD Sybase, and try the way you suggested.


Andy





On 09/29/2011 07:30 PM, James K. Lowden wrote:
On Thu, 29 Sep 2011 17:46:30 -0700
Andy Qian<andyq AT intapp.com> wrote:

By tracing TDSDUMP info of connecting to other version ms sql server,
I found it looks like that DBD::Sybase always logins to master
database firstly, and then switches to the database specified in the
dsn string by executing "use $database" statement.
To use Azure in Perl, you have to do one of two things:

1. use DBD::ODBC, or
2. hack FreeTDS's ct-lib& DBD::Sybase

As you may know, DBD::Sybase uses Client-Library, a/k/a ct-lib.
ct-lib's ct_connect() function takes a server name only, no database
name. As you found out, the server initially connects the user
to the master database, then changes to the user's database, as
determined by the user's default database on that server. If another
is wanted, the client application can change it. AFAIK there's no
ct-lib connection setting or function to change the default database;
the application simply sends "use<dbname>".

For those following along at home: "use<dbname>" comes too late for
Azure. Azure has no (or, at least, denies logins to) the master
database. The client must specify the database name at the time
when logging in.

How does ODBC do it? ODBC sets the dbname in the login packet, which
the server honors.

When someone else wanted to use db-lib with Azure, I added a feature to
the LOGINREC structure that lets the user set the dbname before calling
dbopen(). The effect is to set the dbname in the login packet,
something db-lib wouldn't otherwise do.

To make it work in ct-lib, you'll have to do something similar. Then,
once there's a way to set the dbname in a ct-lib login packet, you'll
have to modify DBD::Sybase to DTRT when the dbname appears in the
connection string.

Just a small matter of programming.

--jkl
_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds





Archive powered by MHonArc 2.6.24.

Top of Page