Randy L. Pearson ([EMAIL PROTECTED]) 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


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

Reply via email to