diff --git a/src/modules/Postgres/postgres.c b/src/modules/Postgres/postgres.c
index 01e2f8f76211678c775b6d073df6417b47f76bb5..e80b865d81822125aede3544436c62f2c462e766 100644
--- a/src/modules/Postgres/postgres.c
+++ b/src/modules/Postgres/postgres.c
@@ -328,7 +328,7 @@ static void f_create (INT32 args)
 
 static void f_select_db (INT32 args)
 {
-	char *host, *port, *options, *tty, *db;
+	char *host, *port, *options, *db;
 	PGconn * conn, *newconn;
 	PQ_FETCH();
 
@@ -352,7 +352,7 @@ static void f_select_db (INT32 args)
 	host=PQhost(conn);
 	port=PQport(conn);
 	options=PQoptions(conn);
-	tty=PQtty(conn);
+
 	/* This could be really done calling f_create, but it's more efficient this
 	 * way */
 	/* using newconn is necessary or otherwise the datastructures I use
@@ -360,7 +360,7 @@ static void f_select_db (INT32 args)
 	 * situations (i.e. if the temporary use of _one_ more filedescriptor
 	 * is not possible.
 	 */
-	newconn=PQsetdb(host,port,options,tty,db);
+	newconn=PQsetdb(host,port,options,NULL,db);
 	PQfinish(conn);
 	conn=newconn;
 	PQ_UNLOCK();