[freetds] SQL_NO_DATA or SQL_SUCCESS

Frediano Ziglio freddy77 at gmail.com
Sun Feb 24 13:28:21 EST 2008


Hi,
  often many people let me note that our ODBC driver returns SQL_NO_DATA
from SQLExecDirect/SQLExecute instead of SQL_SUCCESS. I always replied
that SQL_NO_DATA it's documented and normal.
Some days ago however I ask me what the behavior of MS ODBC SQL Server
driver... I changed a bit our tests (just in my working directory) in
order to print any SQLExecDirect/SQLExecute results and I noted that MS
driver NEVER returns SQL_NO_DATA !!!
And I have to say that our tests works changing our driver returning
SQL_SUCCESS instead of SQL_NO_DATA.
So actually I'm thinking about merging this patch.

diff -U10 -r1.464.2.5 odbc.c
--- src/odbc/odbc.c     29 Jan 2008 10:14:29 -0000      1.464.2.5
+++ src/odbc/odbc.c     24 Feb 2008 18:22:17 -0000
@@ -3172,23 +3172,20 @@
                ++stmt->curr_param_row;
                if (stmt->ipd->header.sql_desc_rows_processed_ptr)
                        *stmt->ipd->header.sql_desc_rows_processed_ptr =
stmt->curr_param_row;
        }

        odbc_populate_ird(stmt);
        switch (result_type) {
        case TDS_CMD_DONE:
                if (stmt->dbc->current_statement == stmt)
                        stmt->dbc->current_statement = NULL;
-               if (stmt->errs.lastrc == SQL_SUCCESS &&
stmt->dbc->env->attr.odbc_version == SQL_OV_ODBC3
-                   && stmt->row_count == TDS_NO_COUNT && !stmt->cursor)
-                       ODBC_RETURN(stmt, SQL_NO_DATA);
                break;

        case TDS_CMD_FAIL:
                /* TODO test what happened, report correct error to
client */
                tdsdump_log(TDS_DBG_INFO1, "SQLExecute: bad results\n");
                ODBC_RETURN(stmt, SQL_ERROR);
        }
        ODBC_RETURN_(stmt);
 }

(as you can note it remove 3 lines which change SQL_SUCCESS to
SQL_NO_DATA if no rows are returned)

If nobody complaints I'll merge in a couple of days.

freddy77





More information about the FreeTDS mailing list