Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

Issue w/ SQLColumns calling stored procedures: msg#00081

db.tds.freetds

Subject: Issue w/ SQLColumns calling stored procedures

I am attempting to integrate a commercial program and FreeTDS using ODBC. I
think I have come across an issue related to the fact that the ODBC
SQLTables and SQLColumns functions are implemented by calling two built-in
SQL Server procs, "sp_tables" and "sp_columns".

I don't have access to the source code for the program, but I have deduced
that after creating the environment and connecting, it allocates a statement
and calls SQLTables. It then calls SQLFetch successively until it returns
SQL_NO_DATA_FOUND. It then allocates a new statement (without freeing the
previous statement) and calls SQLColumns. This is where the trouble starts.

The call to SQLColumns fails because the previous statement is still in a
pending state. Looking through the log, the SQLFetch function consumed all
the data up until the final DONEINPROC. However, the store procedure also
returned an (implied) return parameter RETURNSTATUS before the final
DONEPROC. Because the return parameter is not consumed, the statement is
still pending.

This wouldn't have been an issue if SQLFreeHandle had been called on the
previous statement before calling SQLColumns, because SQLFreeHandle would
have issued a cancel command and cleared the buffers. It also would not be
an issue if the calling program had called SQLMoreResults, which would have
consumed the RETURNSTATUS. However, I don't think either of these cases is
required in a correct ODBC client implementation, because the ODBC spec says
nothing about the presence of return parameter following the recordset (at
least nowhere I can find).

To be more correct, I think the implementations of these two functions
should be changed so that they either only return a recordset or ignore the
presence of a trailing return parameter. The three options would be:

1. implement the functions as a non-stored procedure SQL query, i.e. copying
the guts of sp_tables into a big SQL statement and then calling it

2. automatically call tds_send_cancel() if a previous statement is still
pending, then proceed with the requested operation

3. record in the statement data structure the fact that sp_tables or
sp_columns has been called, then automatically call SQLMoreReults right
before SQLFetch is about to return with SQL_NO_DATA_FOUND for the statement.

I'm willing to do the work on this one, but I'd like to get some feedback
first on the right way to go. I already implemented option #3 because it
was quickets and dirtiest, but I think #1 is probably the better choice.

I haven't yet set up an environment to perform the same calls on the MS
SQLServer driver to see if it has the same problem (I doubt if it does) or
if it issues a cancel command, but I may do so if I get a little free time.

Opinions?

BTW, I'm calling SQL Server 2000 / TDS 8.0.

Thanks,

Jonathan Monroe


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
hardware.arm.at...    cms.citadel.dev...    video.gstreamer...    java.facelets.u...    misc.basics.qna...    web.wiki.instik...    network.uip.use...    xdg.devel/2003-...    tex.bibtex.bibd...    finance.quotesp...    ietf.zeroconf/2...    redhat.blinux.g...    suse.db2/2003-0...    php.phpesp/2004...    uml.devel/2003-...    gnome.labyrinth...    qnx.openqnx.dev...    boot-loaders.gr...    db.dataperfect....    audio.audacity....    linux.uclinux.m...    editors.j.devel...    os.openbsd.tech...    kde.users.multi...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation