Skip to Content.
Sympa Menu

freetds - Re: [freetds] The next two issues with FreeTDS

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Brian Bruns <brian.bruns AT gmail.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] The next two issues with FreeTDS
  • Date: Tue, 2 Nov 2004 09:15:15 -0500

I would say that BBBB is caused by AAAA. If you have no data, can't
have a row count.

Are you able to call SQLNumResultCols after a previous call returns
SQL_NO_DATA under MS ODBC? I believe it would do the same thing, and
fixing(?) AAAA will fix the other.


On Tue, 2 Nov 2004 16:59:27 +0300, Michael Kochetkov
<michael.kochetkov AT synartra.com> wrote:
> Hello,
> I am terribly sorry for reposting it but could anyone from FreeTDS
> development team to comment on BBBB issue if it is considered to be a bug or
> feature. The main problem is that the existing MS ODBC code stopped working.
> I have already patched that problematic third-party library so it is more a
> kind of academic interest.
>
> Thank you in advance,
> -
> Michael Kochetkov.
>
>
>
> > I have found the next two issues with FreeTDS. The first one is
> > informational (marked as AAAA in the code below) the second
> > one (BBBB) may
> > appear to be a bug.
> > 1. At AAAA below MS ODBC driver return 0 (SQL_SUCCESS) and
> > FreeTDS returns
> > 100 (SQL_NO_DATA).
> > 2. At BBBB below MS ODBC driver return 0 (SQL_SUCCESS) and
> > FreeTDS returns
> > -1 (SQL_ERROR) - function sequence error.
> >
> > -
> > Michael Kochetkov.
> >
> > P.S. Test case code:
> > #ifdef WIN32
> > #include <windows.h>
> > #endif
> > #include <stdio.h>
> > #include <string.h>
> > #include <sql.h>
> > #include <sqlext.h>
> >
> > #define MAXBUFLEN 255
> >
> > SQLHENV henv = SQL_NULL_HENV;
> > SQLHDBC hdbc1 = SQL_NULL_HDBC;
> > SQLHSTMT hstmt1 = SQL_NULL_HSTMT;
> >
> > void Cleanup();
> >
> > int main() {
> > RETCODE retcode;
> > // SQLBindParameter variables.
> > SWORD sParm1=0, sParm2=1;
> > SDWORD cbParm1=SQL_NTS, cbParm2=SQL_NTS;
> > SQLSMALLINT columnCount = 0;
> >
> > // Allocate the ODBC environment and save handle.
> > retcode = SQLAllocHandle (SQL_HANDLE_ENV, NULL, &henv);
> > if( (retcode != SQL_SUCCESS_WITH_INFO) &&
> > (retcode != SQL_SUCCESS)) {
> > printf("SQLAllocHandle(Env) Failed\n\n");
> > Cleanup();
> > return(9);
> > }
> >
> > // Notify ODBC that this is an ODBC 3.0 app.
> > retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION,
> > (SQLPOINTER) SQL_OV_ODBC3, SQL_IS_INTEGER);
> > if( (retcode != SQL_SUCCESS_WITH_INFO) &&
> > (retcode != SQL_SUCCESS)) {
> > printf("SQLSetEnvAttr(ODBC version) Failed\n\n");
> > Cleanup();
> > return(9);
> > }
> >
> > // Allocate ODBC connection handle and connect.
> > retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc1);
> > if( (retcode != SQL_SUCCESS_WITH_INFO) &&
> > (retcode != SQL_SUCCESS)) {
> > printf("SQLAllocHandle(hdbc1) Failed\n\n");
> > Cleanup();
> > return(9);
> > }
> >
> > retcode = SQLConnect(hdbc1, (UCHAR*)"Server", SQL_NTS,
> > (UCHAR*)"user",SQL_NTS, (UCHAR*)"password", SQL_NTS);
> >
> > if( (retcode != SQL_SUCCESS) &&
> > (retcode != SQL_SUCCESS_WITH_INFO) ) {
> > printf("SQLConnect() Failed\n\n");
> > Cleanup();
> > return(9);
> > }
> >
> > retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc1, &hstmt1);
> > if( (retcode != SQL_SUCCESS) &&
> > (retcode != SQL_SUCCESS_WITH_INFO) ) {
> > printf("SQLAllocHandle(hstmt1) Failed\n\n");
> > Cleanup();
> > return(9);
> > }
> >
> > // Execute the command.
> > retcode = SQLExecDirect(hstmt1, (UCHAR*)"if exists (select 1 from
> > sysusers where name = 'TestRole')\n"
> > "exec sp_droprole TestRole",
> > SQL_NTS); /* AAAA */
> > if( (retcode != SQL_SUCCESS) &&
> > (retcode != SQL_SUCCESS_WITH_INFO) &&
> > (retcode != SQL_NO_DATA)
> > )
> > {
> > printf("SQLExecDirect Failed\n\n");
> > Cleanup();
> > return(9);
> > }
> >
> > retcode = SQLNumResultCols(hstmt1,&columnCount); /* BBBB */
> > if( (retcode != SQL_SUCCESS) &&
> > (retcode != SQL_SUCCESS_WITH_INFO)
> > )
> > {
> > printf("SQLNumResultCols Failed\n\n");
> > Cleanup();
> > return(9);
> > }
> >
> > while ( ( retcode = SQLMoreResults(hstmt1) ) != SQL_NO_DATA );
> >
> > // Clean up.
> > SQLFreeHandle(SQL_HANDLE_STMT, hstmt1);
> > SQLDisconnect(hdbc1);
> > SQLFreeHandle(SQL_HANDLE_DBC, hdbc1);
> > SQLFreeHandle(SQL_HANDLE_ENV, henv);
> > return(0);
> > }
> >
> > void Cleanup()
> > {
> > if (hstmt1 != SQL_NULL_HSTMT)
> > SQLFreeHandle(SQL_HANDLE_STMT, hstmt1);
> > if (hdbc1 != SQL_NULL_HDBC)
> > {
> > SQLDisconnect(hdbc1);
> > SQLFreeHandle(SQL_HANDLE_DBC, hdbc1);
> > }
> > if (henv != SQL_NULL_HENV)
> > SQLFreeHandle(SQL_HANDLE_ENV, henv);
> > }
> >
> > _______________________________________________
> > FreeTDS mailing list
> > FreeTDS AT lists.ibiblio.org
> > http://lists.ibiblio.org/mailman/listinfo/freetds
> >
>
> _______________________________________________
> 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