mirror of
https://github.com/postgres/postgres.git
synced 2025-11-01 21:31:19 +03:00
this file in interfaces/ It will all need to be checked in. I used the char *rcsid[] method for cvs ids so it can be strings | grep'd to find version numbers. The new version for the library is 3.0. Run configure from src/ to create the Makefile and it should be good to go. I did minimal documentation references in the README, I'll see if I can get something to Tom Lockhart rather quickly. Vince.
72 lines
1.9 KiB
C++
72 lines
1.9 KiB
C++
/*-------------------------------------------------------------------------
|
|
*
|
|
* pgconnection.h
|
|
*
|
|
*
|
|
* DESCRIPTION
|
|
* Postgres Connection Class:
|
|
* Manage Postgres backend connection
|
|
*
|
|
* NOTES
|
|
* Currently under construction.
|
|
*
|
|
* Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* $Id: pgconnection.h,v 1.2 1999/05/23 01:04:00 momjian Exp $
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
#ifndef PGCONN_H
|
|
#define PGCONN_H
|
|
|
|
#include <stdio.h>
|
|
#include <string>
|
|
|
|
extern "C" {
|
|
#include "libpq-fe.h"
|
|
}
|
|
|
|
|
|
// ****************************************************************
|
|
//
|
|
// PgConnection - a connection made to a postgres backend
|
|
//
|
|
// ****************************************************************
|
|
// This class contains all the information about the connection
|
|
// to the backend process. All the database classes should be
|
|
// derived from this class to obtain the connection interface.
|
|
class PgConnection {
|
|
protected:
|
|
PGconn* pgConn; // Connection Structures
|
|
PGresult* pgResult; // Query Result
|
|
int pgCloseConnection; // Flag indicating whether the connection should be closed or not
|
|
|
|
public:
|
|
PgConnection(const char* conninfo); // use reasonable & environment defaults
|
|
~PgConnection(); // close connection and clean up
|
|
|
|
// Connection status and error messages
|
|
ConnStatusType Status();
|
|
int ConnectionBad();
|
|
const char* ErrorMessage();
|
|
|
|
// returns the database name of the connection
|
|
const char* DBName();
|
|
|
|
// Query Execution interface
|
|
ExecStatusType Exec(const char* query); // send a query to the backend
|
|
int ExecCommandOk(const char* query); // send a command and check if it's OK
|
|
int ExecTuplesOk(const char* query); // send a command and check if tuples are returned
|
|
PGnotify* Notifies();
|
|
|
|
protected:
|
|
ConnStatusType Connect(const char* conninfo);
|
|
string IntToString(int);
|
|
|
|
protected:
|
|
PgConnection();
|
|
};
|
|
|
|
#endif // PGCONN_H
|