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
This commit is contained in:
parent
d6e33c8b07
commit
86dacdb74c
@ -316,7 +316,7 @@ char *PQoptions(PGconn *conn)
|
|||||||
Returns the status of the connection.
|
Returns the status of the connection.
|
||||||
The status can be CONNECTION_OK or CONNECTION_BAD.
|
The status can be CONNECTION_OK or CONNECTION_BAD.
|
||||||
<synopsis>
|
<synopsis>
|
||||||
ConnStatusType *PQstatus(PGconn *conn)
|
ConnStatusType PQstatus(PGconn *conn)
|
||||||
</synopsis>
|
</synopsis>
|
||||||
</Para>
|
</Para>
|
||||||
|
|
||||||
|
@ -10,13 +10,14 @@
|
|||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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 <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <strstream>
|
||||||
#include "pgconnection.h"
|
#include "pgconnection.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -88,21 +89,18 @@ ConnStatusType PgConnection::Connect(const char* dbName)
|
|||||||
PQtrace(pgConn, debug);
|
PQtrace(pgConn, debug);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set Host Authentication service
|
|
||||||
char errorMessage[ERROR_MSG_LENGTH];
|
|
||||||
memset(errorMessage, 0, sizeof(errorMessage));
|
|
||||||
fe_setauthsvc(pgEnv.Auth(), errorMessage);
|
|
||||||
|
|
||||||
// Connect to the database
|
// 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(ConnectionBad()) {
|
||||||
if (errorMessage) {
|
SetErrorMessage( PQerrorMessage(pgConn) );
|
||||||
SetErrorMessage( errorMessage );
|
|
||||||
return CONNECTION_BAD;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return Status();
|
return Status();
|
||||||
}
|
}
|
||||||
|
|
||||||
// PgConnection::status -- return connection or result status
|
// PgConnection::status -- return connection or result status
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pgenv.cc,v 1.3 1997/02/13 10:00:33 scrappy Exp $
|
* $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pgenv.cc,v 1.4 1999/05/10 15:27:19 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -66,3 +66,19 @@ string PgEnv::getenv(const char* name)
|
|||||||
char* env = ::getenv(name);
|
char* env = ::getenv(name);
|
||||||
return (env ? env : "");
|
return (env ? env : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Extract the PgEnv contents into a form suitable for PQconnectdb
|
||||||
|
// which happens to be readable, hence choice of <<
|
||||||
|
ostream& operator << (ostream &s, const PgEnv& a)
|
||||||
|
{
|
||||||
|
s<<' '; // surround with whitespace, just in case
|
||||||
|
if(a.pgHost.length() !=0)s<<" host=" <<a.pgHost;
|
||||||
|
if(a.pgPort.length() !=0)s<<" port=" <<a.pgPort;
|
||||||
|
// deprecated: if(a.pgAuth.length()!=0)s<<" authtype="<<a.pgAuth;
|
||||||
|
if(a.pgOption.length()!=0)s<<" options="<<a.pgOption;
|
||||||
|
if(a.pgTty.length() !=0)s<<" tty=" <<a.pgTty;
|
||||||
|
s<<' ';
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#define PGENV_H
|
#define PGENV_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#ifdef __sun__
|
#ifdef __sun__
|
||||||
#ifndef __GNUC__
|
#ifndef __GNUC__
|
||||||
@ -79,6 +80,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
string getenv(const char*);
|
string getenv(const char*);
|
||||||
|
friend ostream& operator << (ostream &, const PgEnv&);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PGENV_H
|
#endif // PGENV_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user