Bug #763: PgLargeObject Class

From: pgsql-bugs(at)postgresql(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: Bug #763: PgLargeObject Class
Date: 2002-09-11 16:35:45
Message-ID: 20020911163545.4E8E84762D2@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Randy L. Pearson (blueboy(at)bamafolks(dot)com) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
PgLargeObject Class

Long Description
The definition of PgLargeObject currently declares all data members as private

Problem:

When attempting to read an existing LO, you must construct a new PgLargeObject, since that is the only place where the desired OID can be provided.

My project is attempting to use a connection pool for both PgDatabase and PgLargeObject objects to avoid the overhead of establishing connections to the backend.

PgLargeObject should either define its data members as protected, so you can override the class and access the protected pgObject member, or a member function should be provided so the user can set the desired OID without constructing a new object.

I suggest modifying the Open function to accept a new OID.

Sample Code
Patch against 7.2.2:

--- pglobject.h.orig 2002-09-11 11:19:29.000000000 -0500
+++ pglobject.h 2002-09-11 11:24:27.000000000 -0500
@@ -48,14 +48,14 @@
~PgLargeObject(); // close connection and clean up

void Create();
- void Open();
+ void Open( Oid oid = 0 );
void Close();
int Read(char* buf, int len);
int Write(const char* buf, int len);
int LSeek(int offset, int whence);
int Tell() const;
int Unlink();
- Oid LOid();
+ Oid LOid() const;
Oid Import(const char* filename);
int Export(const char* filename);
PGSTD string Status() const;

--- pglobject.cc.orig 2002-09-11 11:19:35.000000000 -0500
+++ pglobject.cc 2002-09-11 11:28:58.000000000 -0500
@@ -88,10 +88,13 @@

// PgLargeObject::open
// open large object and check for errors
-void PgLargeObject::Open()
+void PgLargeObject::Open( Oid oid )
{
// Close any prior object
Close();
+ // Store new OID (if provided)
+ if( oid )
+ pgObject = oid;
// Open the object
pgFd = lo_open(pgConn, pgObject, INV_READ|INV_WRITE);

@@ -169,3 +172,8 @@
{
return loStatus;
}
+
+Oid PgLargeObject::LOid() const
+{
+ return pgObject;
+}

No file was uploaded with this report

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2002-09-12 00:24:05 Re: Schemas not available for pl/pgsql %TYPE....
Previous Message Prasanna 2002-09-11 07:37:36 Problem