mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
Indent libpq++ as mentioned in email. Format was terrible, and this
will make fixing things easier.
This commit is contained in:
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq++/examples/Attic/testlibpq0.cc,v 1.6 2000/05/29 21:25:04 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq++/examples/Attic/testlibpq0.cc,v 1.7 2002/07/02 16:32:19 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -21,7 +21,8 @@ int main()
|
||||
{
|
||||
// Open the connection to the database and make sure it's OK
|
||||
PgDatabase data("dbname=template1");
|
||||
if ( data.ConnectionBad() ) {
|
||||
if ( data.ConnectionBad() )
|
||||
{
|
||||
cout << "Connection was unsuccessful..." << endl
|
||||
<< "Error message returned: " << data.ErrorMessage() << endl;
|
||||
return 1;
|
||||
|
@ -20,26 +20,30 @@ int main()
|
||||
PgDatabase data(dbName);
|
||||
|
||||
// check to see that the backend connection was successfully made
|
||||
if ( data.ConnectionBad() ) {
|
||||
if ( data.ConnectionBad() )
|
||||
{
|
||||
cerr << "Connection to database '" << dbName << "' failed." << endl
|
||||
<< "Error returned: " << data.ErrorMessage() << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// start a transaction block
|
||||
if ( !data.ExecCommandOk("BEGIN") ) {
|
||||
if ( !data.ExecCommandOk("BEGIN") )
|
||||
{
|
||||
cerr << "BEGIN command failed" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// submit command to the backend
|
||||
if ( !data.ExecCommandOk("DECLARE myportal CURSOR FOR select * from pg_database") ) {
|
||||
if ( !data.ExecCommandOk("DECLARE myportal CURSOR FOR select * from pg_database") )
|
||||
{
|
||||
cerr << "DECLARE CURSOR command failed" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// fetch instances from the pg_database, the system catalog of databases
|
||||
if ( !data.ExecTuplesOk("FETCH ALL in myportal") ) {
|
||||
if ( !data.ExecTuplesOk("FETCH ALL in myportal") )
|
||||
{
|
||||
cerr << "FETCH ALL command didn't return tuples properly" << endl;
|
||||
exit(1);
|
||||
}
|
||||
@ -51,7 +55,8 @@ int main()
|
||||
cout << endl << endl;
|
||||
|
||||
// next, print out the instances
|
||||
for (int i=0; i < data.Tuples(); i++) {
|
||||
for (int i = 0; i < data.Tuples(); i++)
|
||||
{
|
||||
for (int j = 0; j < nFields; j++)
|
||||
cout << setiosflags(ios::right) << setw(15) << data.GetValue(i, j);
|
||||
cout << endl;
|
||||
|
@ -20,20 +20,23 @@ int main()
|
||||
PgTransaction data(dbName);
|
||||
|
||||
// check to see that the backend connection was successfully made
|
||||
if ( data.ConnectionBad() ) {
|
||||
if ( data.ConnectionBad() )
|
||||
{
|
||||
cerr << "Connection to database '" << dbName << "' failed." << endl
|
||||
<< "Error returned: " << data.ErrorMessage() << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// submit command to the backend
|
||||
if ( !data.ExecCommandOk("DECLARE myportal CURSOR FOR select * from pg_database") ) {
|
||||
if ( !data.ExecCommandOk("DECLARE myportal CURSOR FOR select * from pg_database") )
|
||||
{
|
||||
cerr << "DECLARE CURSOR command failed" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// fetch instances from the pg_database, the system catalog of databases
|
||||
if ( !data.ExecTuplesOk("FETCH ALL in myportal") ) {
|
||||
if ( !data.ExecTuplesOk("FETCH ALL in myportal") )
|
||||
{
|
||||
cerr << "FETCH ALL command didn't return tuples properly" << endl;
|
||||
exit(1);
|
||||
}
|
||||
@ -45,7 +48,8 @@ int main()
|
||||
cout << endl << endl;
|
||||
|
||||
// next, print out the instances
|
||||
for (int i=0; i < data.Tuples(); i++) {
|
||||
for (int i = 0; i < data.Tuples(); i++)
|
||||
{
|
||||
for (int j = 0; j < nFields; j++)
|
||||
cout << setiosflags(ios::right) << setw(15) << data.GetValue(i, j);
|
||||
cout << endl;
|
||||
|
@ -23,20 +23,23 @@ int main()
|
||||
PgCursor cData(dbName, "myportal");
|
||||
|
||||
// check to see that the backend connection was successfully made
|
||||
if ( cData.ConnectionBad() ) {
|
||||
if ( cData.ConnectionBad() )
|
||||
{
|
||||
cerr << "Connection to database '" << dbName << "' failed." << endl
|
||||
<< "Error returned: " << cData.ErrorMessage() << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// submit command to the backend
|
||||
if ( !cData.Declare("select * from pg_database") ) {
|
||||
if ( !cData.Declare("select * from pg_database") )
|
||||
{
|
||||
cerr << "DECLARE CURSOR command failed" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// fetch instances from the pg_cDatabase, the system catalog of cDatabases
|
||||
if ( !cData.Fetch() ) {
|
||||
if ( !cData.Fetch() )
|
||||
{
|
||||
cerr << "FETCH ALL command didn't return tuples properly" << endl;
|
||||
exit(1);
|
||||
}
|
||||
@ -48,7 +51,8 @@ int main()
|
||||
cout << endl << endl;
|
||||
|
||||
// next, print out the instances
|
||||
for (int i=0; i < cData.Tuples(); i++) {
|
||||
for (int i = 0; i < cData.Tuples(); i++)
|
||||
{
|
||||
for (int j = 0; j < nFields; j++)
|
||||
cout << setiosflags(ios::right) << setw(15) << cData.GetValue(i, j);
|
||||
cout << endl;
|
||||
|
@ -31,23 +31,27 @@ int main()
|
||||
PgDatabase data(dbName);
|
||||
|
||||
// Check to see that the backend connection was successfully made
|
||||
if ( data.ConnectionBad() ) {
|
||||
if ( data.ConnectionBad() )
|
||||
{
|
||||
cerr << "Connection to database '" << dbName << "' failed." << endl
|
||||
<< data.ErrorMessage() << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Listen to a table
|
||||
if ( !data.ExecCommandOk("LISTEN TBL2") ) {
|
||||
if ( !data.ExecCommandOk("LISTEN TBL2") )
|
||||
{
|
||||
cerr << "LISTEN command failed" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Test asynchronous notification
|
||||
while (1) {
|
||||
while (1)
|
||||
{
|
||||
// check for asynchronous returns
|
||||
PGnotify* notify = data.Notifies();
|
||||
if (notify) {
|
||||
if (notify)
|
||||
{
|
||||
cerr << "ASYNC NOTIFY of '" << notify->relname
|
||||
<< "' from backend pid '" << notify->be_pid
|
||||
<< "' received" << endl;
|
||||
|
@ -29,7 +29,8 @@ tuple 1: got
|
||||
#include <iostream.h>
|
||||
#include "libpq++.h"
|
||||
#include <stdlib.h>
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
#include "postgres.h" // for Postgres types
|
||||
#include "utils/geo_decls.h" // for the POLYGON type
|
||||
}
|
||||
@ -43,20 +44,23 @@ int main()
|
||||
PgCursor data(dbName, "mycursor");
|
||||
|
||||
// check to see that the backend connection was successfully made
|
||||
if ( data.ConnectionBad() ) {
|
||||
if ( data.ConnectionBad() )
|
||||
{
|
||||
cerr << "Connection to database '" << dbName << "' failed." << endl
|
||||
<< data.ErrorMessage();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Declare a binary cursor for all the tuples in database 'test1'
|
||||
if ( !data.Declare("select * from test1", 1) ) {
|
||||
if ( !data.Declare("select * from test1", 1) )
|
||||
{
|
||||
cerr << "DECLARE CURSOR command failed" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// fetch all instances from the current cursor
|
||||
if ( !data.Fetch() ) {
|
||||
if ( !data.Fetch() )
|
||||
{
|
||||
cerr << "FETCH ALL command didn't return tuples properly" << endl;
|
||||
exit(1);
|
||||
}
|
||||
@ -75,7 +79,8 @@ int main()
|
||||
*/
|
||||
|
||||
// Print out the information about the extracted tuple
|
||||
for (int i=0; i < data.Tuples(); i++) {
|
||||
for (int i = 0; i < data.Tuples(); i++)
|
||||
{
|
||||
// we hard-wire this to the 3 fields we know about
|
||||
int* ival = (int*)data.GetValue(i, i_fnum);
|
||||
float* dval = (float*)data.GetValue(i, d_fnum);
|
||||
|
@ -17,26 +17,32 @@ int main()
|
||||
PgTransaction data(dbName);
|
||||
|
||||
// check to see that the backend connection was successfully made
|
||||
if ( data.ConnectionBad() ) {
|
||||
if ( data.ConnectionBad() )
|
||||
{
|
||||
cerr << "Connection to database '" << dbName << "' failed." << endl
|
||||
<< data.ErrorMessage();
|
||||
exit(1);
|
||||
}
|
||||
else cout << "Connected to database '" << dbName << "'..." << endl;
|
||||
else
|
||||
cout << "Connected to database '" << dbName << "'..." << endl;
|
||||
|
||||
// Create a new table
|
||||
if ( !data.ExecCommandOk("CREATE TABLE foo (a int4, b char(16), d float8)") ) {
|
||||
if ( !data.ExecCommandOk("CREATE TABLE foo (a int4, b char(16), d float8)") )
|
||||
{
|
||||
cerr << "CREATE TABLE foo command failed" << endl;
|
||||
exit(1);
|
||||
}
|
||||
else cout << "CREATEd TABLE foo successfully.." << endl;
|
||||
else
|
||||
cout << "CREATEd TABLE foo successfully.." << endl;
|
||||
|
||||
// Initiate Copy command
|
||||
if ( data.ExecCommandOk("COPY foo FROM STDIN") ) {
|
||||
if ( data.ExecCommandOk("COPY foo FROM STDIN") )
|
||||
{
|
||||
cerr << "COPY foo FROM STDIN" << endl;
|
||||
exit(1);
|
||||
}
|
||||
else cout << "COPY foo FROM STDIN was successful.." << endl;
|
||||
else
|
||||
cout << "COPY foo FROM STDIN was successful.." << endl;
|
||||
|
||||
// Put some test data into the table
|
||||
data.PutLine("3\thello world\t4.5\n");
|
||||
@ -47,12 +53,14 @@ int main()
|
||||
cout << "Line: \"\\.\" copied..." << endl;
|
||||
if ( !data.EndCopy() )
|
||||
cout << "Ended COPY succesfully..." << endl;
|
||||
else cerr << "End Copy failed..." << endl;
|
||||
else
|
||||
cerr << "End Copy failed..." << endl;
|
||||
|
||||
// Print the data that was inserted into the table
|
||||
if ( data.ExecTuplesOk("SELECT * FROM foo") )
|
||||
data.PrintTuples();
|
||||
else cerr << "SELECT * FROM foo failed..." << endl;
|
||||
else
|
||||
cerr << "SELECT * FROM foo failed..." << endl;
|
||||
|
||||
// Drop the test table
|
||||
data.Exec("DROP TABLE foo");
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq++/examples/Attic/testlo.cc,v 1.8 2000/05/29 21:25:04 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq++/examples/Attic/testlo.cc,v 1.9 2002/07/02 16:32:19 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -18,7 +18,8 @@
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// Check if the program was invoked correctly; if not, signal error
|
||||
if (argc < 4 || argc > 5) {
|
||||
if (argc < 4 || argc > 5)
|
||||
{
|
||||
cerr << "Usage: " << argv[0] << " conninfo_str in_filename out_filename [oid]" << endl;
|
||||
exit(1);
|
||||
}
|
||||
@ -33,7 +34,8 @@ int main(int argc, char **argv)
|
||||
PgLargeObject object(lobjId, conninfo);
|
||||
|
||||
// check to see that the backend connection was successfully made
|
||||
if ( object.ConnectionBad() ) {
|
||||
if ( object.ConnectionBad() )
|
||||
{
|
||||
cerr << "Connection with conninfo '" << conninfo << "' failed." << endl
|
||||
<< object.ErrorMessage();
|
||||
exit(1);
|
||||
|
@ -16,7 +16,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: libpq++.h,v 1.12 2002/06/20 20:29:54 momjian Exp $
|
||||
* $Id: libpq++.h,v 1.13 2002/07/02 16:32:19 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
@ -10,7 +10,7 @@
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pgconnection.cc,v 1.14 2002/06/15 18:49:29 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pgconnection.cc,v 1.15 2002/07/02 16:32:19 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -34,6 +34,7 @@ PgConnection::PgConnection()
|
||||
|
||||
// constructor -- checks environment variable for database name
|
||||
// Now uses PQconnectdb
|
||||
|
||||
PgConnection::PgConnection(const char* conninfo)
|
||||
: pgConn(NULL), pgResult(NULL), pgCloseConnection(true)
|
||||
{
|
||||
@ -57,7 +58,8 @@ PgConnection::~PgConnection()
|
||||
void PgConnection::CloseConnection()
|
||||
{
|
||||
// if the connection is open, close it first
|
||||
if (pgCloseConnection) {
|
||||
if (pgCloseConnection)
|
||||
{
|
||||
if (pgResult)
|
||||
PQclear(pgResult);
|
||||
pgResult = NULL;
|
||||
|
@ -13,7 +13,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: pgconnection.h,v 1.18 2002/06/20 20:29:54 momjian Exp $
|
||||
* $Id: pgconnection.h,v 1.19 2002/07/02 16:32:19 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -21,7 +21,8 @@
|
||||
#ifndef PGCONNECTION_H
|
||||
#define PGCONNECTION_H
|
||||
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
#include "pg_config.h"
|
||||
}
|
||||
|
||||
@ -37,7 +38,8 @@ extern "C" {
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
#include "libpq-fe.h"
|
||||
}
|
||||
|
||||
@ -56,7 +58,8 @@ extern "C" {
|
||||
// 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 DLLIMPORT PgConnection {
|
||||
class DLLIMPORT PgConnection
|
||||
{
|
||||
protected:
|
||||
PGconn* pgConn; // Connection Structure
|
||||
PGresult* pgResult; // Current Query Result
|
||||
|
@ -10,7 +10,7 @@
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pgcursordb.cc,v 1.7 2002/06/15 18:49:29 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pgcursordb.cc,v 1.8 2002/07/02 16:32:19 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -41,6 +41,7 @@ PgCursor::PgCursor(const char* conninfo, const char* cursor)
|
||||
//{}
|
||||
|
||||
// Destructor: End the transaction block
|
||||
|
||||
PgCursor::~PgCursor()
|
||||
{
|
||||
Close();
|
||||
|
@ -14,7 +14,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
*
|
||||
* $Id: pgcursordb.h,v 1.11 2002/06/20 20:29:54 momjian Exp $
|
||||
* $Id: pgcursordb.h,v 1.12 2002/07/02 16:32:19 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -41,7 +41,8 @@
|
||||
// manipulates data through it. The interface will introduce some
|
||||
// ease of use through the methods that will allow cursor specific
|
||||
// operations, like fetch, forward, etc.
|
||||
class DLLIMPORT PgCursor : public PgTransaction {
|
||||
class DLLIMPORT PgCursor : public PgTransaction
|
||||
{
|
||||
public:
|
||||
PgCursor(const char* conninfo, const char* cursor); // use reasonable & environment defaults
|
||||
// connect to the database with given environment and database name
|
||||
@ -55,10 +56,16 @@ public:
|
||||
int Close(); // Close the cursor
|
||||
|
||||
// Accessors to the cursor name
|
||||
const char* Cursor() const { return pgCursor.c_str(); }
|
||||
const char* Cursor() const
|
||||
{
|
||||
return pgCursor.c_str();
|
||||
}
|
||||
// TODO: Setter has same name as getter--ouch!
|
||||
// OBSOLESCENT
|
||||
void Cursor(PGSTD string cursor) { pgCursor = cursor; }
|
||||
void Cursor(PGSTD string cursor)
|
||||
{
|
||||
pgCursor = cursor;
|
||||
}
|
||||
|
||||
protected:
|
||||
int Fetch(PGSTD string num, PGSTD string dir);
|
||||
@ -67,14 +74,17 @@ protected:
|
||||
PGSTD string pgCursor;
|
||||
|
||||
protected:
|
||||
PgCursor() : PgTransaction() {} // Do not connect
|
||||
PgCursor() : PgTransaction()
|
||||
{} // Do not connect
|
||||
|
||||
|
||||
private:
|
||||
// We don't support copying of PgCursor objects,
|
||||
// so make copy constructor and assignment op private.
|
||||
PgCursor(const PgCursor&);
|
||||
PgCursor& operator= (const PgCursor&);
|
||||
}; // End PgCursor Class Declaration
|
||||
}
|
||||
; // End PgCursor Class Declaration
|
||||
|
||||
|
||||
#undef PGSTD
|
||||
|
@ -10,7 +10,7 @@
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pgdatabase.cc,v 1.12 2001/09/30 22:30:37 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pgdatabase.cc,v 1.13 2002/07/02 16:32:19 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
@ -14,7 +14,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
*
|
||||
* $Id: pgdatabase.h,v 1.13 2002/06/20 20:29:54 momjian Exp $
|
||||
* $Id: pgdatabase.h,v 1.14 2002/07/02 16:32:19 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -34,12 +34,16 @@
|
||||
// This is the basic database access class. Its interface should
|
||||
// be used only after a query has been sent to the backend and
|
||||
// results are being received.
|
||||
class DLLIMPORT PgDatabase : public PgConnection {
|
||||
class DLLIMPORT PgDatabase : public PgConnection
|
||||
{
|
||||
public:
|
||||
// connect to the database with conninfo
|
||||
explicit PgDatabase(const char* conninfo) : PgConnection(conninfo) {}
|
||||
explicit PgDatabase(const char* conninfo) : PgConnection(conninfo)
|
||||
{}
|
||||
|
||||
~PgDatabase()
|
||||
{} // close connection and clean up
|
||||
|
||||
~PgDatabase() {} // close connection and clean up
|
||||
|
||||
typedef int size_type;
|
||||
|
||||
@ -73,7 +77,9 @@ public:
|
||||
int EndCopy();
|
||||
|
||||
protected:
|
||||
PgDatabase() : PgConnection() {} // Do not connect
|
||||
PgDatabase() : PgConnection()
|
||||
{} // Do not connect
|
||||
|
||||
|
||||
private:
|
||||
// We don't support copying of PgDatabase objects,
|
||||
|
@ -10,14 +10,15 @@
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pglobject.cc,v 1.10 2002/06/15 19:30:40 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pglobject.cc,v 1.11 2002/07/02 16:32:19 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "pglobject.h"
|
||||
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
#include "libpq/libpq-fs.h"
|
||||
}
|
||||
|
||||
@ -38,7 +39,8 @@ PgLargeObject::PgLargeObject(const char* conninfo)
|
||||
: PgConnection(conninfo)
|
||||
{
|
||||
Init();
|
||||
if (! ConnectionBad()) {
|
||||
if (! ConnectionBad())
|
||||
{
|
||||
Create();
|
||||
Open();
|
||||
}
|
||||
@ -51,7 +53,8 @@ PgLargeObject::PgLargeObject(Oid lobjId, const char* conninfo)
|
||||
: PgConnection(conninfo)
|
||||
{
|
||||
Init(lobjId);
|
||||
if (! ConnectionBad()) {
|
||||
if (! ConnectionBad())
|
||||
{
|
||||
if ( !pgObject )
|
||||
Create();
|
||||
Open();
|
||||
@ -111,7 +114,8 @@ int PgLargeObject::Unlink()
|
||||
int temp = lo_unlink(pgConn, pgObject);
|
||||
|
||||
// Initialize the large object upon success
|
||||
if (!temp) {
|
||||
if (!temp)
|
||||
{
|
||||
Close();
|
||||
Init();
|
||||
}
|
||||
@ -123,7 +127,8 @@ int PgLargeObject::Unlink()
|
||||
|
||||
void PgLargeObject::Close()
|
||||
{
|
||||
if (pgFd >= 0) lo_close(pgConn, pgFd);
|
||||
if (pgFd >= 0)
|
||||
lo_close(pgConn, pgFd);
|
||||
pgFd = -1;
|
||||
}
|
||||
|
||||
@ -169,6 +174,7 @@ string PgLargeObject::Status() const
|
||||
return loStatus;
|
||||
}
|
||||
|
||||
Oid PgLargeObject::LOid(){
|
||||
Oid PgLargeObject::LOid()
|
||||
{
|
||||
return pgObject;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
*
|
||||
* $Id: pglobject.h,v 1.10 2002/06/20 20:29:54 momjian Exp $
|
||||
* $Id: pglobject.h,v 1.11 2002/07/02 16:32:19 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -35,7 +35,8 @@
|
||||
// PgLargeObject - a class for accessing Large Object in a database
|
||||
//
|
||||
// ****************************************************************
|
||||
class DLLIMPORT PgLargeObject : public PgConnection {
|
||||
class DLLIMPORT PgLargeObject : public PgConnection
|
||||
{
|
||||
private:
|
||||
int pgFd;
|
||||
Oid pgObject;
|
||||
|
@ -10,7 +10,7 @@
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pgtransdb.cc,v 1.4 2001/05/09 17:29:10 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pgtransdb.cc,v 1.5 2002/07/02 16:32:19 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -34,7 +34,8 @@ PgTransaction::PgTransaction(const char* conninfo)
|
||||
// Destructor: End the transaction block
|
||||
PgTransaction::~PgTransaction()
|
||||
{
|
||||
if (!pgCommitted) Exec("ABORT");
|
||||
if (!pgCommitted)
|
||||
Exec("ABORT");
|
||||
}
|
||||
|
||||
// Begin the transaction block
|
||||
|
@ -14,7 +14,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
*
|
||||
* $Id: pgtransdb.h,v 1.9 2002/06/20 20:29:54 momjian Exp $
|
||||
* $Id: pgtransdb.h,v 1.10 2002/07/02 16:32:19 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -34,7 +34,8 @@
|
||||
// This is the database access class that keeps an open
|
||||
// transaction block during its lifetime. The block is ENDed when
|
||||
// the object is destroyed.
|
||||
class DLLIMPORT PgTransaction : public PgDatabase {
|
||||
class DLLIMPORT PgTransaction : public PgDatabase
|
||||
{
|
||||
public:
|
||||
explicit PgTransaction(const char* conninfo); // use reasonable & environment defaults
|
||||
// connect to the database with given environment and database name
|
||||
@ -46,7 +47,9 @@ protected:
|
||||
ExecStatusType EndTransaction();
|
||||
|
||||
protected:
|
||||
PgTransaction() : PgDatabase(), pgCommitted(true) {} // Do not connect
|
||||
PgTransaction() : PgDatabase(), pgCommitted(true)
|
||||
{} // Do not connect
|
||||
|
||||
|
||||
private:
|
||||
bool pgCommitted;
|
||||
@ -55,6 +58,7 @@ private:
|
||||
// so make copy constructor and assignment op private.
|
||||
PgTransaction(const PgTransaction&);
|
||||
PgTransaction& operator= (const PgTransaction&);
|
||||
}; // End PgTransaction Class Declaration
|
||||
}
|
||||
; // End PgTransaction Class Declaration
|
||||
|
||||
#endif // PGTRANSDB_H
|
||||
|
Reference in New Issue
Block a user