Skip to Content.
Sympa Menu

freetds - [freetds] freetds + odbc + qt problems

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Stephen Schaub <sschaub AT gmail.com>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] freetds + odbc + qt problems
  • Date: Fri, 7 Oct 2005 08:25:18 -0400

I'm having some difficulty getting freetds, odbc, and the qt database
API's to work together. The segfault occurs in the freetds layer, so I
thought I would post here to see if anyone has any feedback.

First, the platform:
* Fedora Core 4
* unixODBC 2.2.11-1
* qt 3.3.4-15.1
* freetds-0.63 (built and installed from source)

My odbcinst.ini:

[FreeTDS]
Driver = /usr/local/lib/libtdsodbc.so

My ~/.odbc.ini:

[Sim86]
DRIVER=FreeTDS
DATABASE=Sim86
SERVER=blahblah
PORT=1433
TDS_Version=8.0

A small qt database test app:

#include <qapplication.h>
#include <qsqldatabase.h>
#include <iostream>

using namespace std;

int main( int argc, char *argv[] )
{
QApplication app( argc, argv, FALSE );

QSqlDatabase *defaultDB = QSqlDatabase::addDatabase( "QODBC3" );
defaultDB->setDatabaseName( "Sim86" );
defaultDB->setUserName( "username" );
defaultDB->setPassword( "secret" );


if ( defaultDB->open() ) {
cout << "Connect succeeded!" << endl;
} else {
cout << "Problem!" << endl;
}

return 0;
}

Now, compile the app:

gcc -g dbtest.cpp -odbtest -lqt-mt -I/usr/lib/qt-3.3/include
-L/usr/lib/qt-3.3/lib

Run:

Segmentation fault

Run in gdb:

[sschaub@csunix odbc]$ gdb dbtest
GNU gdb 6.2.1
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...Using host
libthread_db library "/lib/libthread_db.so.1".

(gdb) r
Starting program: /home/sschaub/software/odbc/dbtest
[Thread debugging using libthread_db enabled]
[New Thread -1208124960 (LWP 30126)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208124960 (LWP 30126)]
0x001f8061 in _SQLGetDiagRec (handleType=Variable "handleType" is not
available.
) at error.c:457
457 odbc_ver = ((TDS_DBC *)
handle)->env->attr.odbc_version;
Current language: auto; currently c
(gdb) print ((TDS_DBC *) handle)->env
$1 = (struct _henv *) 0x0
(gdb)

It appears the env is NULL. I also tested the latest nightly build --
the seg fault occurred in the same _SQLGetDiagRec function in error.c
(line 525).

When I commented out that line and rebuilt freetds 0.63, I didn't get
a seg fault, but the connect failed, with the following program
output:

QODBCDriver::checkDriver: Cannot get list of supported functions Error:
Problem!
QODBCDriver::cleanup: Unable to free connection handle Error:
QODBCDriver::cleanup: Unable to free environment handle Error:

It appears that the freetds, odbc, and the qt database API's don't
play well together. I just wanted to verify my analysis (I sure would
like to use them together!).

--
Stephen Schaub



  • [freetds] freetds + odbc + qt problems, Stephen Schaub, 10/07/2005

Archive powered by MHonArc 2.6.24.

Top of Page