diff options
| author | Bruce Momjian <bruce@momjian.us> | 1999-05-23 01:04:07 +0000 |
|---|---|---|
| committer | Bruce Momjian <bruce@momjian.us> | 1999-05-23 01:04:07 +0000 |
| commit | b14c99d8d6bdb3155fe54e6f24e8aac32a09ed81 (patch) | |
| tree | 0b63fc00dfff28c643cfafe587777ab11e5733c5 /src/interfaces/libpq++/pglobject.cc | |
| parent | 795f6ca66ab734559e6eed7a9466eb19b58f3166 (diff) | |
| download | postgresql-b14c99d8d6bdb3155fe54e6f24e8aac32a09ed81.tar.gz | |
Here it is. Remove or rename the current interfaces/libpq++ and untar
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.
Diffstat (limited to 'src/interfaces/libpq++/pglobject.cc')
| -rw-r--r-- | src/interfaces/libpq++/pglobject.cc | 97 |
1 files changed, 65 insertions, 32 deletions
diff --git a/src/interfaces/libpq++/pglobject.cc b/src/interfaces/libpq++/pglobject.cc index 917a368f50..d6cf865bbd 100644 --- a/src/interfaces/libpq++/pglobject.cc +++ b/src/interfaces/libpq++/pglobject.cc @@ -9,8 +9,6 @@ * * Copyright (c) 1994, Regents of the University of California * - * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pglobject.cc,v 1.3 1997/02/13 10:00:34 scrappy Exp $ * *------------------------------------------------------------------------- */ @@ -21,7 +19,7 @@ extern "C" { #include "pglobject.h" - +static char rcsid[] = "$Id: pglobject.cc,v 1.4 1999/05/23 01:04:03 momjian Exp $"; // **************************************************************** // @@ -30,8 +28,9 @@ extern "C" { // **************************************************************** // default constructor // creates a large object in the default database -PgLargeObject::PgLargeObject(const char* dbName) - : PgConnection(dbName) +// See PQconnectdb() for conninfo usage +PgLargeObject::PgLargeObject(const char* conninfo) + : PgConnection(conninfo) { Init(); Create(); @@ -40,33 +39,15 @@ PgLargeObject::PgLargeObject(const char* dbName) // constructor // open an existing large object in the default database -PgLargeObject::PgLargeObject(Oid lobjId, const char* dbName) - : PgConnection(dbName) +// See PQconnectdb() for conninfo usage +PgLargeObject::PgLargeObject(Oid lobjId, const char* conninfo) + : PgConnection(conninfo) { - Init(lobjId); - if ( !pgObject ) - Create(); - Open(); -} - -// constructor -// create a large object in the given database -PgLargeObject::PgLargeObject(const PgEnv& env, const char* dbName) - : PgConnection(env, dbName) -{ - Init(); - Create(); - Open(); -} -// constructor -// open an existing large object in the given database -PgLargeObject::PgLargeObject(const PgEnv& env, const char* dbName, Oid lobjId) - : PgConnection(env, dbName) -{ Init(lobjId); - if ( !pgObject ) - Create(); + if ( !pgObject ) { + Create(); + } Open(); } @@ -93,7 +74,9 @@ void PgLargeObject::Create() // Check for possible errors if (!pgObject) - SetErrorMessage( "PgLargeObject: can't create large object" ); + loStatus = "PgLargeObject: can't create large object" ; + else + loStatus = "PgLargeObject: created large object" ; } // PgLargeObject::open @@ -106,9 +89,9 @@ void PgLargeObject::Open() // Check for possible errors string objStr( IntToString(pgObject) ); if (pgFd < 0) - SetErrorMessage( "PgLargeObject: can't open large object " + objStr ); + loStatus = "PgLargeObject: can't open large object " + objStr ; else - SetErrorMessage( "PgLargeObject: created and opened large object " + objStr ); + loStatus = "PgLargeObject: created and opened large object " + objStr ; } // PgLargeObject::unlink @@ -127,3 +110,53 @@ int PgLargeObject::Unlink() // Return the status return temp; } + + + +void PgLargeObject::Close() +{ + if (pgFd >= 0) lo_close(pgConn, pgFd); +} + + +int PgLargeObject::Read(char* buf, int len) +{ + return lo_read(pgConn, pgFd, buf, len); +} + + +int PgLargeObject::Write(const char* buf, int len) +{ + return lo_write(pgConn, pgFd, (char*)buf, len); +} + + +int PgLargeObject::LSeek(int offset, int whence) +{ + return lo_lseek(pgConn, pgFd, offset, whence); +} + + +int PgLargeObject::Tell() +{ + return lo_tell(pgConn, pgFd); +} + + +Oid PgLargeObject::Import(const char* filename) +{ + return pgObject = lo_import(pgConn, (char*)filename); +} + + +int PgLargeObject::Export(const char* filename) +{ + return lo_export(pgConn, pgObject, (char*)filename); +} + + +string PgLargeObject::Status() +{ + return loStatus; +} + |
