[unixODBC-dev] Buf in Postgre7.1 driver

Constantine Filin cfilin at intermedia.net
Wed Nov 30 12:15:51 GMT 2005

Hello -

I have unixODBC version 2.2.9 with Postgres7.1 driver. Postgres 
version is 8.0.1 running on Linux Fedora 2.

When UnixODBC calls SQLDriverConnect() and from there CC_connect() 
function, unix odbc after a successful socket connection sends an 
empty query to the backend. That query sometimes fails despite the 
fact that the postgres process has successfully started on the backend 
(this is also an issue but not the bug I am reporting)

When the empty query fails Postgres7.1 ODBC driver reports "The 
database does not exist on the server or user authentication failed." 
and returns an error to the caller.

The problem is that in such case ODBC driver does not close the SOCKET 
going to the postgres backend and that socket remains STALE in the 
process without any reference to it and no way to close it. It can be 
seen in lsof command output. The postgres server - meanwhile - keeps 
the postgres process running for the connection until I send it a
SIGTERM signal.

Here's my patch for connection.c:

	if ( res == NULL || QR_get_status(res) != PGRES_EMPTY_QUERY) {
		mylog("got no result from the empty query.  (probably
database does not exist)\n");
		self->errornumber = CONNECTION_NO_SUCH_DATABASE;
		self->errormsg = "The database does not exist on the
server\nor user authentication failed.";
		if (res != NULL)
+                if( self->sock ) {
+                        SOCK_Destructor(self->sock);
+                        self->sock = NULL;
+                }
		return 0;
	if (res)

Please commit is in CVS



More information about the unixODBC-dev mailing list