[unixODBC-dev] Problem in SQLRowCount

Nimish Bhargava nimish.bhargava at gmail.com
Tue Feb 24 12:55:06 GMT 2009


Hi Nick

I am still facing problem in the SQLRowCount function.
I have build all components of odbc with BUILD_LEGACY_64_BIT_MODE defined.

Following is the part of the code I am executing and gdb trace.
The same piece of code is working fine on 32 bit and causing trouble on 64
bit.

class A
{
    public:
        A(const char* fname, const char* flname, int line): funcName(fname),
fileName(flname), lineNum(line) {}
        ~A() {}

    private:
        int lineNum;
        const char* funcName;
        const char* fileName;
};


int ODBCSession::getRowCount()
{
    A tempft("getRowCount", "ODBCSession", 309);

    SQLINTEGER RowCount;

    SQLRETURN ret = SQLRowCount(m_stmt, &RowCount);

    ....
}

GDB trace

Breakpoint 1, ODBCSession::getRowCount (this=0x402f4578)
    at ../../../src/odbc/ODBCSession.cxx:309
(gdb) p &tempft
$1 = (A *) 0x402f43f0
(gdb) p &RowCount
$2 = (SQLINTEGER *) 0x402f43ec
(gdb) p sizeof(tempft)
$3 = 24
(gdb) p tempft.line
$4 = 309
(gdb) p &tempft.line
$5 = (int *) 0x402f43f0
(gdb) p *(0x402f43f0)
$6 = 309
(gdb)
316             SQLRETURN ret=SQLRowCount(m_stmt,&RowCount);
(gdb) s
SQLRowCount (statement_handle=0x110c7f00, rowcount=0x402f43ec)
    at SQLRowCount.c:133
133     {
Current language:  auto; currently c
(gdb) ptype rowcount
type = int *
(gdb) n
142         if ( !__validate_stmt( statement ))
(gdb)
158         function_entry( statement );
(gdb)
160         if ( log_info.log_flag )
(gdb)
175         thread_protect( SQL_HANDLE_STMT, statement );
(gdb)
180         if ( statement -> state == STATE_S1 ||
(gdb)
207         if ( !CHECK_SQLROWCOUNT( statement -> connection ))
(gdb)
227             ret = DEF_SQLROWCOUNT(statement -> connection, statement ->
driver_stmt, rowcount);
(gdb) p *(0x402f43f0)
$7 = 0

Please share your views for the unexpected behavior.

Also can you share a way to know which function is actually being called by
the macro so that I can cross verify the value of SQLLEN in that function.
Though I doubt that will be a problem as I exported
CPPFLAGS="-DBUILD_LEGACY_64_BIT_MODE" during the configuration and ensured
during the compilation that the flag is defined for all the files.

Regards
Nimish

On Mon, Feb 23, 2009 at 7:17 PM, Nick Gorham <nick at lurcher.org> wrote:

> Nimish Bhargava wrote:
>
>  Hi
>>
>> I am using the odbc library on CentOS 5.2 x86_64.
>> I am facing a problem in SQLRowCount(SQLHSTMT , SQLLEN*) function in
>> DriverManager/SQLRowCount.c.
>>
>> I have build the odbc library and my code with BUILD_LEGACY_64_BIT_MODE
>> flag
>> defined. Hence SQLLEN become "int" according to the definition in
>> sqltypes.h.
>>
>> The problem occurs after the execution of macro DEF_SQLROWCOUNT (line
>> 227).
>> Instead of writing on 4 bytes (int) on rowcount it writes 8 bytes thus
>> corrupting 4 bytes of the stack.
>>
>> Could you please look in this function or let me know if I have made some
>> mistake with the odbc compilation.
>>
>> Thanks and Regards
>> Nimish
>>
>>
>>
> That macro just calls the function in the current driver, so I guess you
> have a driver built with sizeof( SQLLEN ) == 8
>
> --
> Nick
> _______________________________________________
> unixODBC-dev mailing list
> unixODBC-dev at mailman.unixodbc.org
> http://mailman.unixodbc.org/mailman/listinfo/unixodbc-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.unixodbc.org/pipermail/unixodbc-dev/attachments/20090224/bf22397c/attachment.html>


More information about the unixODBC-dev mailing list