diff options
author | Bruce Momjian <bruce@momjian.us> | 1999-05-10 15:27:19 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 1999-05-10 15:27:19 +0000 |
commit | 86dacdb74c20d8af6ec900b7cd163df031ab90e4 (patch) | |
tree | 5b71bf3eda1c45edcdca8a1c3d5be5178f863674 /src/interfaces/libpq++/pgconnection.cc | |
parent | d6e33c8b07aeef995d7d4d200d6667383ec849ba (diff) | |
download | postgresql-86dacdb74c20d8af6ec900b7cd163df031ab90e4.tar.gz postgresql-86dacdb74c20d8af6ec900b7cd163df031ab90e4.zip |
libpq++ uses fe_setauthsvc which is deprecated and results in an error
on connection. This patch changes it to use PQconnectdb rather than
{fe_setauthsvc,PQsetdb}. This still isn't the complete solution, as
there
is no provision for user,password in class PgEnv, but it does get rid of
the error message. Tested with gcc version egcs-2.91.60 19981201
(egcs-1.1.1 release) under NetBSD-1.3K/i386.
Cheers,
Patrick Welche
Diffstat (limited to 'src/interfaces/libpq++/pgconnection.cc')
-rw-r--r-- | src/interfaces/libpq++/pgconnection.cc | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/interfaces/libpq++/pgconnection.cc b/src/interfaces/libpq++/pgconnection.cc index 96ef215700f..9cbdd896171 100644 --- a/src/interfaces/libpq++/pgconnection.cc +++ b/src/interfaces/libpq++/pgconnection.cc @@ -10,13 +10,14 @@ * Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pgconnection.cc,v 1.2 1997/02/13 10:00:27 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pgconnection.cc,v 1.3 1999/05/10 15:27:18 momjian Exp $ * *------------------------------------------------------------------------- */ #include <stdlib.h> #include <string.h> +#include <strstream> #include "pgconnection.h" extern "C" { @@ -88,21 +89,18 @@ ConnStatusType PgConnection::Connect(const char* dbName) PQtrace(pgConn, debug); #endif - // Set Host Authentication service - char errorMessage[ERROR_MSG_LENGTH]; - memset(errorMessage, 0, sizeof(errorMessage)); - fe_setauthsvc(pgEnv.Auth(), errorMessage); - // Connect to the database - pgConn = PQsetdb(pgEnv.Host(), pgEnv.Port(), pgEnv.Option(), pgEnv.TTY(), dbName); + ostrstream conninfo; + conninfo << "dbname="<<dbName; + conninfo << pgEnv; + pgConn=PQconnectdb(conninfo.str()); + conninfo.freeze(0); - // Return the connection status - if (errorMessage) { - SetErrorMessage( errorMessage ); - return CONNECTION_BAD; + if(ConnectionBad()) { + SetErrorMessage( PQerrorMessage(pgConn) ); } - else - return Status(); + + return Status(); } // PgConnection::status -- return connection or result status |