[unixODBC-support] Segmentation Fault when using isql with IBM DB2 drivers

Brian Schonecker Brian.Schonecker at Xtek.com
Tue Jul 18 14:15:07 BST 2006


I'm pulling out my hair!  I can do some simple queries that don't return _rows_ of data like "select count(*) from sysadm.tmktest", "insert into sysadm.tmktest (select * from sysadm.tmkqot)" but when I try a super simple query that should return rows I get a segmentation fault.  I've included everything that I think I need to provide.

Funny thing:  If I execute the query from the IBM DB2 "client" (ie:non-unixODBC) everything works just fine.  I know that I'm talking to the remote DB2 database and I have the correct permissions.

Is there something that I'm missing?

Thanks, Brian

db2inst1 at opportunity:~> whoami
db2inst1
db2inst1 at opportunity:~> echo $DB2
$DB2DIR       $DB2INSTANCE  
db2inst1 at opportunity:~> echo $DB2DIR 
/usr/IBMdb2/V7.1
db2inst1 at opportunity:~> echo $DB2INSTANCE 
db2inst1
db2inst1 at opportunity:~> 
db2inst1 at opportunity:~> isql --version
unixODBC 2.2.10
db2inst1 at opportunity:~> uname -a
Linux opportunity 2.6.5-7.147-default #1 Thu Jan 27 09:19:29 UTC 2005 i686 i686 i386 GNU/Linux
db2inst1 at opportunity:~> isql -v dsnp
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> select count(*) from sysadm.tmktest
+------------+
|            |
+------------+
| 8          |
+------------+
SQLRowCount returns -1
1 rows fetched
SQL> delete from sysadm.tmktest
SQLRowCount returns 8
SQL> select count(*) from sysadm.tmktest
+------------+
|            |
+------------+
| 0          |
+------------+
SQLRowCount returns -1
1 rows fetched

SQL> insert into sysadm.tmktest (select * from sysadm.tmkqon)
SQLRowCount returns 8
SQL> select * from sysadm.tmkqon
+----------------+------------------+-------------------+-------------------------------------------------------------+
| QON_COMPANY_CDE| QON_QUOTE_DIV_NBR| QON_NEXT_QUOTE_NBR| QON_QUOTE_DIV_NAM                                           |
+----------------+------------------+-------------------+-------------------------------------------------------------+
Segmentation fault
db2inst1 at opportunity:~> cat /etc/unixODBC/odbc.ini
[ODBC Data Sources]
DSNP=IBM DB2 ODBC Driver

[DSNP]
Driver =   /usr/IBMdb2/V7.1/lib/libdb2.so
# Driver=/home/db2inst1/sqllib/lib/libdb2.so

#[DB2]
#Description     = Test to DB2
#Driver=/usr/IBMdb2/V7.1/lib/libdb2.so

#[sample]
#Description     = Test to DB2
#Driver=/usr/IBMdb2/V7.1/lib/libdb2.so
db2inst1 at opportunity:~> cat /etc/unixODBC/odbcinst.ini 
[IBM DB2 ODBC Driver]
Description = IBM DB2 ODBC Driver --- BTS
#Driver=/usr/IBMdb2/V7.1/lib/libdb2.so
Driver=/home/db2inst1/sqllib/lib/libdb2.so
FileUsage = 3
DontDLClose = 1

Trace=yes
TraceFile=/tmp/odbc.log
Debug=yes
DebugFile=/tmp/debug.log


[IBM]
Description = IBM DB2 ODBC Driver --- BTS
Driver=/usr/IBMdb2/V7.1/lib/libdb2.so
#Driver=/home/db2inst1/sqllib/lib/libdb2.so
FileUsage = 3
DontDLClose = 1

Trace=yes
TraceFile=/tmp/odbc.log
Debug=yes



[ODBC]
Trace=yes
TraceFile=/tmp/tracefile.log





Here is the trace file for a failed "select * from sysadm.tmktest" query:



db2inst1 at opportunity:~> isql -v dsnp
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> select * from sysadm.tmktest
+----------------+------------------+-------------------+-------------------------------------------------------------+
| QON_COMPANY_CDE| QON_QUOTE_DIV_NBR| QON_NEXT_QUOTE_NBR| QON_QUOTE_DIV_NAM                                           |
+----------------+------------------+-------------------+-------------------------------------------------------------+
Segmentation fault
db2inst1 at opportunity:~> cat /tmp/tracefile.log
[ODBC][9373][__handles.c][444]
                Exit:[SQL_SUCCESS]
                        Environment = 0x8052658
[ODBC][9373][SQLAllocHandle.c][346]
                Entry:
                        Handle Type = 2
                        Input Handle = 0x8052658
[ODBC][9373][SQLAllocHandle.c][464]
                Exit:[SQL_SUCCESS]
                        Output Handle = 0x8052be8
[ODBC][9373][SQLConnect.c][3527]
                Entry:            
                        Connection = 0x8052be8            
                        Server Name = [dsnp][length = 4 (SQL_NTS)]            
                        User Name = [][length = 0 (SQL_NTS)]            
                        Authentication = [][length = 0 (SQL_NTS)]
                UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE'

[ODBC][9373][SQLConnect.c][4101]
                Exit:[SQL_SUCCESS]
[ODBC][9373][SQLAllocHandle.c][511]
                Entry:
                        Handle Type = 3
                        Input Handle = 0x8052be8
[ODBC][9373][SQLAllocHandle.c][873]
                Exit:[SQL_SUCCESS]
                        Output Handle = 0x80851a0
[ODBC][9373][SQLPrepare.c][180]
                Entry:            
                        Statement = 0x80851a0            
                        SQL = [select * from sysadm.tmktest ][length = 29 (SQL_NTS)]
[ODBC][9373][SQLPrepare.c][355]
                Exit:[SQL_SUCCESS]
[ODBC][9373][SQLExecute.c][183]
                Entry:            
                        Statement = 0x80851a0
[ODBC][9373][SQLExecute.c][344]
                Exit:[SQL_SUCCESS]
[ODBC][9373][SQLNumResultCols.c][149]
                Entry:            
                        Statement = 0x80851a0            
                        Column Count = 0xbfffefda
[ODBC][9373][SQLNumResultCols.c][234]
                Exit:[SQL_SUCCESS]                
                        Count = 0xbfffefda -> 4
[ODBC][9373][SQLNumResultCols.c][149]
                Entry:            
                        Statement = 0x80851a0            
                        Column Count = 0xbfffef8e
[ODBC][9373][SQLNumResultCols.c][234]
                Exit:[SQL_SUCCESS]                
                        Count = 0xbfffef8e -> 4
[ODBC][9373][SQLColAttribute.c][267]
                Entry:            
                        Statement = 0x80851a0            
                        Column Number = 1            
                        Field Identifier = SQL_DESC_DISPLAY_SIZE            
                        Character Attr = (nil)            
                        Buffer Length = 0            
                        String Length = (nil)            
                        Numeric Attribute = 0xbfffeb8c
[ODBC][9373][SQLColAttribute.c][630]
                Exit:[SQL_SUCCESS]
[ODBC][9373][SQLColAttribute.c][267]
                Entry:            
                        Statement = 0x80851a0            
                        Column Number = 1            
                        Field Identifier = SQL_DESC_LABEL            
                        Character Attr = 0xbfffeb90            
                        Buffer Length = 301            
                        String Length = (nil)            
                        Numeric Attribute = (nil)
[ODBC][9373][SQLColAttribute.c][630]
                Exit:[SQL_SUCCESS]
[ODBC][9373][SQLColAttribute.c][267]
                Entry:            
                        Statement = 0x80851a0            
                        Column Number = 1            
                        Field Identifier = SQL_DESC_LABEL            
                        Character Attr = 0xbfffed10            
                        Buffer Length = 301            
                        String Length = (nil)            
                        Numeric Attribute = (nil)
[ODBC][9373][SQLColAttribute.c][630]
                Exit:[SQL_SUCCESS]
[ODBC][9373][SQLColAttribute.c][267]
                Entry:            
                        Statement = 0x80851a0            
                        Column Number = 2            
                        Field Identifier = SQL_DESC_DISPLAY_SIZE            
                        Character Attr = (nil)            
                        Buffer Length = 0            
                        String Length = (nil)            
                        Numeric Attribute = 0xbfffeb8c
[ODBC][9373][SQLColAttribute.c][630]
                Exit:[SQL_SUCCESS]
[ODBC][9373][SQLColAttribute.c][267]
                Entry:            
                        Statement = 0x80851a0            
                        Column Number = 2            
                        Field Identifier = SQL_DESC_LABEL            
                        Character Attr = 0xbfffeb90            
                        Buffer Length = 301            
                        String Length = (nil)            
                        Numeric Attribute = (nil)
[ODBC][9373][SQLColAttribute.c][630]
                Exit:[SQL_SUCCESS]
[ODBC][9373][SQLColAttribute.c][267]
                Entry:            
                        Statement = 0x80851a0            
                        Column Number = 2            
                        Field Identifier = SQL_DESC_LABEL            
                        Character Attr = 0xbfffed10            
                        Buffer Length = 301            
                        String Length = (nil)            
                        Numeric Attribute = (nil)
[ODBC][9373][SQLColAttribute.c][630]
                Exit:[SQL_SUCCESS]
[ODBC][9373][SQLColAttribute.c][267]
                Entry:            
                        Statement = 0x80851a0            
                        Column Number = 3            
                        Field Identifier = SQL_DESC_DISPLAY_SIZE            
                        Character Attr = (nil)            
                        Buffer Length = 0            
                        String Length = (nil)            
                        Numeric Attribute = 0xbfffeb8c
[ODBC][9373][SQLColAttribute.c][630]
                Exit:[SQL_SUCCESS]
[ODBC][9373][SQLColAttribute.c][267]
                Entry:            
                        Statement = 0x80851a0            
                        Column Number = 3            
                        Field Identifier = SQL_DESC_LABEL            
                        Character Attr = 0xbfffeb90            
                        Buffer Length = 301            
                        String Length = (nil)            
                        Numeric Attribute = (nil)
[ODBC][9373][SQLColAttribute.c][630]
                Exit:[SQL_SUCCESS]
[ODBC][9373][SQLColAttribute.c][267]
                Entry:            
                        Statement = 0x80851a0            
                        Column Number = 3            
                        Field Identifier = SQL_DESC_LABEL            
                        Character Attr = 0xbfffed10            
                        Buffer Length = 301            
                        String Length = (nil)            
                        Numeric Attribute = (nil)
[ODBC][9373][SQLColAttribute.c][630]
                Exit:[SQL_SUCCESS]
[ODBC][9373][SQLColAttribute.c][267]
                Entry:            
                        Statement = 0x80851a0            
                        Column Number = 4            
                        Field Identifier = SQL_DESC_DISPLAY_SIZE            
                        Character Attr = (nil)            
                        Buffer Length = 0            
                        String Length = (nil)            
                        Numeric Attribute = 0xbfffeb8c
[ODBC][9373][SQLColAttribute.c][630]
                Exit:[SQL_SUCCESS]
[ODBC][9373][SQLColAttribute.c][267]
                Entry:            
                        Statement = 0x80851a0            
                        Column Number = 4            
                        Field Identifier = SQL_DESC_LABEL            
                        Character Attr = 0xbfffeb90            
                        Buffer Length = 301            
                        String Length = (nil)            
                        Numeric Attribute = (nil)
[ODBC][9373][SQLColAttribute.c][630]
                Exit:[SQL_SUCCESS]
[ODBC][9373][SQLColAttribute.c][267]
                Entry:            
                        Statement = 0x80851a0            
                        Column Number = 4            
                        Field Identifier = SQL_DESC_LABEL            
                        Character Attr = 0xbfffed10            
                        Buffer Length = 301            
                        String Length = (nil)            
                        Numeric Attribute = (nil)
[ODBC][9373][SQLColAttribute.c][630]
                Exit:[SQL_SUCCESS]
[ODBC][9373][SQLNumResultCols.c][149]
                Entry:            
                        Statement = 0x80851a0            
                        Column Count = 0xbfffef8e
[ODBC][9373][SQLNumResultCols.c][234]
                Exit:[SQL_SUCCESS]                
                        Count = 0xbfffef8e -> 4
[ODBC][9373][SQLFetch.c][158]
                Entry:            
                        Statement = 0x80851a0








More information about the unixODBC-support mailing list