On Fri, Jan 13, 2012 at 03:09:10PM -0500, Jack Lloyd wrote:
> Hi,
>
> I've noticed a difference in behavior in FreeTDS between 0.82 and 0.91
> when using it via iODBC 3.52.7. I'm using FreeTDS on Linux, talking to
> a SQL Server 2008 R2 instance. In 0.82, calling SQLRowCount when the
> statement was something that does not produce a result (for instance
> "set lock_timeout 1000", "create table ..." or "drop table ..."), the
> call returns SQL_SUCCESS, setting the output parameter to -1. This
> behavior matches that seen running on Windows using the Microsoft ODBC
> driver. In contrast in 0.91 (as well as the 0.92 snapshot I tried,
> dated 20120105), SQLRowCount will return SQL_ERROR and does not set
> the output parameter. GetDiagRec returns "Function sequence error".
Bug. :-(
http://msdn.microsoft.com/en-us/library/windows/desktop/ms711835%28v=vs.85%29.aspx
The 24000 diagnostic is not a valid return code for SQLRowCount().
HY010 (Function sequence error) is a DM error, and is not caused by the
situation you describe.
Here is the code:
SQLRETURN
_SQLRowCount(SQLHSTMT hstmt, SQLLEN FAR * pcrow)
{
TDSSOCKET *tds;
ODBC_ENTER_HSTMT;
tdsdump_log(TDS_DBG_FUNC, "_SQLRowCount(%p, %p)\n",
hstmt, pcrow);
tds = stmt->dbc->tds_socket;
if (stmt->row_status == NOT_IN_ROW) {
odbc_errs_add(&stmt->errs, "24000", NULL);
ODBC_EXIT_(stmt);
}
*pcrow = -1;
if (stmt->row_count != TDS_NO_COUNT)
*pcrow = stmt->row_count;
ODBC_EXIT_(stmt);
}
Looking over the possible return codes for SQLRowCount(), I think the error
checking can be removed, yielding:
SQLRETURN
_SQLRowCount(SQLHSTMT hstmt, SQLLEN FAR * pcrow)
{
ODBC_ENTER_HSTMT;
tdsdump_log(TDS_DBG_FUNC, "_SQLRowCount(%p, %p)\n", hstmt, pcrow);
assert(TDS_NO_COUNT == -1);
*pcrow = stmt->row_count;
ODBC_EXIT_(stmt);
}
Please try that. I'll commit it if it works and no one objects.
> SQLNumResultCols will also fail in 0.91 in this situation
The code that would do that is removed in CVS HEAD with "#if 0".
--jkl
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.