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 16:32:32 -0700

Hello, James,

as you suggested, I tried to modify source code in both DBD::Sybase and freetds. I have modified struct imp_dbh_st in dbdimp.h (DBD::Sybase level) by adding one more field there, int directConn, and also updated dbdimp.c file correspondingly.

at freetds level, I may need to modify struct CS_CONNECTION, which is very important as the bridge connecting sybase and freetds, and also need to add one more definition, CS_DIRECT_CONN, to the list of existing CS_XXXXXX, such as CS_HOSTNAME, CS_USERNAME, etc. However, I just could not find the place defining the struct and those CS_XXXXX. I searched all source code files of DBD:Sybase and freetds, and not luck.

Could you please give me some hints which file I should look for?

Thank you very much and have a good weekend.


Andy Qian




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