[unixODBC-support] pthread and unixODBC problem

José M. Puyal josemaria.puyal at dialcom.com
Thu Oct 13 11:03:04 BST 2005


Hi Nick,

The thread works fine with the database if we pass it a connection
already created, but it faults if is the thread who creates the
connection.


Here you are the ldd command result

[root at JOSEMARI usr]# cd /usr/local/lib
[root at JOSEMARI lib]# ldd libodbc.so
        libdl.so.2 => /lib/libdl.so.2 (0x00ddf000)
        libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00d80000)
        libc.so.6 => /lib/tls/libc.so.6 (0x00e28000)
        /lib/ld-linux.so.2 (0x00266000)


here you are the sql.log file. All the queries are succesfully done from
a created connection and passed to the thread, but in the end of the
file you can see [ODBC][10691][SQLSetConnectAttr.c][295]Error:
SQL_INVALID_HANDLE. that seems to be when the thread tries to create a
database connection.



[ODBC][10691][__handles.c][444]
		Exit:[SQL_SUCCESS]
			Environment = 0x81cd870
[ODBC][10691][SQLSetEnvAttr.c][182]
		Entry:            
			Environment = 0x81cd870            
			Attribute = SQL_ATTR_ODBC_VERSION            
			Value = 0x3            
			StrLen = 0
[ODBC][10691][SQLSetEnvAttr.c][349]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLAllocHandle.c][345]
		Entry:
			Handle Type = 2
			Input Handle = 0x81cd870
[ODBC][10691][SQLAllocHandle.c][463]
		Exit:[SQL_SUCCESS]
			Output Handle = 0x81d1318
[ODBC][10691][SQLSetConnectAttr.c][295]Error: SQL_INVALID_HANDLE
[ODBC][10691][SQLConnect.c][3549]
		Entry:            
			Connection = 0x81d1318            
			Server Name = [WebConferenceDB][length = 15 (SQL_NTS)]            
			User Name = [root][length = 4 (SQL_NTS)]            
			Authentication = [][length = 0 (SQL_NTS)]
		UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE'

[ODBC][10691][SQLConnect.c][4123]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLAllocHandle.c][510]
		Entry:
			Handle Type = 3
			Input Handle = 0x81d1318
[ODBC][10691][SQLAllocHandle.c][872]
		Exit:[SQL_SUCCESS]
			Output Handle = 0x81ee210
[ODBC][10691][SQLExecDirect.c][233]
		Entry:            
			Statement = 0x81ee210            
			SQL = [Update cdr set fecha_final='2005-10-13 11:54:43' where
fecha_final='0'][length = 70 (SQL_NTS)]
[ODBC][10691][SQLExecDirect.c][496]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLRowCount.c][166]
		Entry:            
			Statement = 0x81ee210            
			Row Count = 0xbfff46e8
[ODBC][10691][SQLRowCount.c][237]
		Exit:[SQL_SUCCESS]                
			Row Count = 0xbfff46e8 -> 0
[ODBC][10691][SQLFreeHandle.c][365]
		Entry:
			Handle Type = 3
			Input Handle = 0x81ee210
[ODBC][10691][SQLFreeHandle.c][462]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLAllocHandle.c][510]
		Entry:
			Handle Type = 3
			Input Handle = 0x81d1318
[ODBC][10691][SQLAllocHandle.c][872]
		Exit:[SQL_SUCCESS]
			Output Handle = 0x81ee210
[ODBC][10691][SQLExecDirect.c][233]
		Entry:            
			Statement = 0x81ee210            
			SQL = [Update sesion_usuario set final_sesion='2005-10-13 11:54:43'
where final_sesion='0'][length = 83 (SQL_NTS)]
[ODBC][10691][SQLExecDirect.c][496]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLRowCount.c][166]
		Entry:            
			Statement = 0x81ee210            
			Row Count = 0xbfff46e8
[ODBC][10691][SQLRowCount.c][237]
		Exit:[SQL_SUCCESS]                
			Row Count = 0xbfff46e8 -> 0
[ODBC][10691][SQLFreeHandle.c][365]
		Entry:
			Handle Type = 3
			Input Handle = 0x81ee210
[ODBC][10691][SQLFreeHandle.c][462]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLAllocHandle.c][510]
		Entry:
			Handle Type = 3
			Input Handle = 0x81d1318
[ODBC][10691][SQLAllocHandle.c][872]
		Exit:[SQL_SUCCESS]
			Output Handle = 0x81eefe0
[ODBC][10691][SQLExecDirect.c][233]
		Entry:            
			Statement = 0x81eefe0            
			SQL = [Update cdr set fecha_final='2005-10-13 11:54:43' where
fecha_final='0'][length = 70 (SQL_NTS)]
[ODBC][10691][SQLExecDirect.c][496]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLRowCount.c][166]
		Entry:            
			Statement = 0x81eefe0            
			Row Count = 0xbfff46d8
[ODBC][10691][SQLRowCount.c][237]
		Exit:[SQL_SUCCESS]                
			Row Count = 0xbfff46d8 -> 0
[ODBC][10691][SQLFreeHandle.c][365]
		Entry:
			Handle Type = 3
			Input Handle = 0x81eefe0
[ODBC][10691][SQLFreeHandle.c][462]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLAllocHandle.c][510]
		Entry:
			Handle Type = 3
			Input Handle = 0x81d1318
[ODBC][10691][SQLAllocHandle.c][872]
		Exit:[SQL_SUCCESS]
			Output Handle = 0x81eefe0
[ODBC][10691][SQLExecDirect.c][233]
		Entry:            
			Statement = 0x81eefe0            
			SQL = [Update sesion_usuario set final_sesion='2005-10-13 11:54:43'
where final_sesion='0'][length = 83 (SQL_NTS)]
[ODBC][10691][SQLExecDirect.c][496]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLRowCount.c][166]
		Entry:            
			Statement = 0x81eefe0            
			Row Count = 0xbfff46d8
[ODBC][10691][SQLRowCount.c][237]
		Exit:[SQL_SUCCESS]                
			Row Count = 0xbfff46d8 -> 0
[ODBC][10691][SQLFreeHandle.c][365]
		Entry:
			Handle Type = 3
			Input Handle = 0x81eefe0
[ODBC][10691][SQLFreeHandle.c][462]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLAllocHandle.c][510]
		Entry:
			Handle Type = 3
			Input Handle = 0x81d1318
[ODBC][10691][SQLAllocHandle.c][872]
		Exit:[SQL_SUCCESS]
			Output Handle = 0x81eefe0
[ODBC][10691][SQLExecDirect.c][233]
		Entry:            
			Statement = 0x81eefe0            
			SQL = [Update cdr set fecha_final='2005-10-13 11:54:43' where
fecha_final='0'][length = 70 (SQL_NTS)]
[ODBC][10691][SQLExecDirect.c][496]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLRowCount.c][166]
		Entry:            
			Statement = 0x81eefe0            
			Row Count = 0x138068
[ODBC][10691][SQLRowCount.c][237]
		Exit:[SQL_SUCCESS]                
			Row Count = 0x138068 -> 0
[ODBC][10691][SQLFreeHandle.c][365]
		Entry:
			Handle Type = 3
			Input Handle = 0x81eefe0
[ODBC][10691][SQLFreeHandle.c][462]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLAllocHandle.c][510]
		Entry:
			Handle Type = 3
			Input Handle = 0x81d1318
[ODBC][10691][SQLAllocHandle.c][872]
		Exit:[SQL_SUCCESS]
			Output Handle = 0x81eefe0
[ODBC][10691][SQLExecDirect.c][233]
		Entry:            
			Statement = 0x81eefe0            
			SQL = [Update sesion_usuario set final_sesion='2005-10-13 11:54:43'
where final_sesion='0'][length = 83 (SQL_NTS)]
[ODBC][10691][SQLExecDirect.c][496]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLRowCount.c][166]
		Entry:            
			Statement = 0x81eefe0            
			Row Count = 0x138068
[ODBC][10691][SQLRowCount.c][237]
		Exit:[SQL_SUCCESS]                
			Row Count = 0x138068 -> 0
[ODBC][10691][SQLFreeHandle.c][365]
		Entry:
			Handle Type = 3
			Input Handle = 0x81eefe0
[ODBC][10691][SQLFreeHandle.c][462]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLAllocHandle.c][510]
		Entry:
			Handle Type = 3
			Input Handle = 0x81d1318
[ODBC][10691][SQLAllocHandle.c][872]
		Exit:[SQL_SUCCESS]
			Output Handle = 0x81f05d8
[ODBC][10691][SQLBindCol.c][165]
		Entry:            
			Statement = 0x81f05d8            
			Column Number = 1            
			Target Type = -18 SQL_C_ULONG            
			Target Value = 0xb4b254            
			Buffer Length = 4            
			StrLen Or Ind = 0xb4b258
[ODBC][10691][SQLBindCol.c][251]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLBindCol.c][165]
		Entry:            
			Statement = 0x81f05d8            
			Column Number = 2            
			Target Type = -18 SQL_C_ULONG            
			Target Value = 0xb4b250            
			Buffer Length = 4            
			StrLen Or Ind = 0xb4b258
[ODBC][10691][SQLBindCol.c][251]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLBindCol.c][165]
		Entry:            
			Statement = 0x81f05d8            
			Column Number = 3            
			Target Type = -18 SQL_C_ULONG            
			Target Value = 0xb4b24c            
			Buffer Length = 4            
			StrLen Or Ind = 0xb4b258
[ODBC][10691][SQLBindCol.c][251]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLExecDirect.c][233]
		Entry:            
			Statement = 0x81f05d8            
			SQL = [Select sesion.id, sesion.id_entidad, sesion.tipo_sesion from
sesion, entidad where sesion.nombre = 'WEBCONFERENCE' and
sesion.id...][length = 190 (SQL_NTS)]
[ODBC][10691][SQLExecDirect.c][496]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLFetch.c][158]
		Entry:            
			Statement = 0x81f05d8
[ODBC][10691][SQLFetch.c][340]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLFreeHandle.c][365]
		Entry:
			Handle Type = 3
			Input Handle = 0x81f05d8
[ODBC][10691][SQLFreeHandle.c][462]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLAllocHandle.c][510]
		Entry:
			Handle Type = 3
			Input Handle = 0x81d1318
[ODBC][10691][SQLAllocHandle.c][872]
		Exit:[SQL_SUCCESS]
			Output Handle = 0x81f05d8
[ODBC][10691][SQLBindCol.c][165]
		Entry:            
			Statement = 0x81f05d8            
			Column Number = 1            
			Target Type = -18 SQL_C_ULONG            
			Target Value = 0xb4b254            
			Buffer Length = 4            
			StrLen Or Ind = 0xb4b258
[ODBC][10691][SQLBindCol.c][251]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLExecDirect.c][233]
		Entry:            
			Statement = 0x81f05d8            
			SQL = [Select puede_moderar from usuario where id_entidad = 1 and
login = 'SIM 000' and password = ''][length = 95 (SQL_NTS)]
[ODBC][10691][SQLExecDirect.c][496]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLFetch.c][158]
		Entry:            
			Statement = 0x81f05d8
[ODBC][10691][SQLFetch.c][340]
		Exit:[SQL_NO_DATA]
[ODBC][10691][SQLFreeHandle.c][365]
		Entry:
			Handle Type = 3
			Input Handle = 0x81f05d8
[ODBC][10691][SQLFreeHandle.c][462]
		Exit:[SQL_SUCCESS]
[ODBC][10691][SQLAllocHandle.c][345]
		Entry:
			Handle Type = 2
			Input Handle = 0x81cd870
[ODBC][10691][SQLAllocHandle.c][463]
		Exit:[SQL_SUCCESS]
			Output Handle = 0x81f05d8
[ODBC][10691][SQLSetConnectAttr.c][295]Error: SQL_INVALID_HANDLE
[ODBC][10691][SQLConnect.c][3549]
		Entry:            
			Connection = 0x81f05d8            
			Server Name = [WebConferenceDB][length = 15 (SQL_NTS)]            
			User Name = [root][length = 4 (SQL_NTS)]            
			Authentication = [][length = 0 (SQL_NTS)]



El jue, 13-10-2005 a las 10:44 +0100, Nick Gorham escribió:
> José M. Puyal wrote:
> 
> >Hi,
> >
> >We have built unixODBC with the default params, ¿Does this include
> >thread support?.
> >
> >  
> >
> It depends if it found a thread lib, do a ldd on libodbc.so and see if 
> it is dependent on pthreads.
> 
> >Thanks in advance and regards.
> >
> >Josemari
> >
> >El jue, 13-10-2005 a las 11:07 +0200, José M. Puyal escribió:
> >  
> >
> >>Hi,
> >>
> >>The segmentation fault happens when we try to create a connection to the
> >>database in the first instruction in the run() method of a thread class.
> >>    
> >>
> Yes, but under a debugger where is the fault. Turn tracing on (in 
> odbcinst.ini)
> 
> [ODBC]
> Trace = yes
> TraceFile = /tmp/sql.log
> 
> 
> and see if it fails inside a ODBC function
> 





More information about the unixODBC-support mailing list