Minor patch to C++ large object interface (cures two ills)

Started by Adam Haberlachalmost 26 years ago3 messagespatches
Jump to latest
#1Adam Haberlach
adam@newsnipple.com

For quite some time, the C++ large object interface has been getting
away with not declaring transactions, Looks like nobody noticed that
it wasn't getting away with it since 6.5.

Also, it seems to have had a definition for the mythical
PgLargeObject::::LOid() function, but never seemed to have an
implementation.

(forgive me if this isn't a correct patch format. Pretty minor, in
any case)

socket:cvs diff pglobject.cc
Index: pglobject.cc
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/libpq++/pglobject.cc,v
retrieving revision 1.6
diff -r1.6 pglobject.cc
58a59

Exec("END");

67a69

Exec("BEGIN");

149a152,155

Oid PgLargeObject::LOid()
{
return pgObject;
}

--
Adam Haberlach | A billion hours ago, human life appeared on
adam@newsnipple.com | earth. A billion minutes ago, Christianity
http://www.newsnipple.com | emerged. A billion Coca-Colas ago was
'88 EX500 | yesterday morning. -1996 Coca-Cola Ann. Rpt.

#2Bruce Momjian
bruce@momjian.us
In reply to: Adam Haberlach (#1)
Re: Minor patch to C++ large object interface (cures two ills)

First, I need context diffs, diff -c. Second, does the END cause
problems in cases where Close() is called more than once? For example,
Close is called as part of PgLargeObject::Open.

For quite some time, the C++ large object interface has been getting
away with not declaring transactions, Looks like nobody noticed that
it wasn't getting away with it since 6.5.

Also, it seems to have had a definition for the mythical
PgLargeObject::::LOid() function, but never seemed to have an
implementation.

(forgive me if this isn't a correct patch format. Pretty minor, in
any case)

socket:cvs diff pglobject.cc
Index: pglobject.cc
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/libpq++/pglobject.cc,v
retrieving revision 1.6
diff -r1.6 pglobject.cc
58a59

Exec("END");

67a69

Exec("BEGIN");

149a152,155

Oid PgLargeObject::LOid()
{
return pgObject;
}

--
Adam Haberlach | A billion hours ago, human life appeared on
adam@newsnipple.com | earth. A billion minutes ago, Christianity
http://www.newsnipple.com | emerged. A billion Coca-Colas ago was
'88 EX500 | yesterday morning. -1996 Coca-Cola Ann. Rpt.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#3Adam Haberlach
adam@newsnipple.com
In reply to: Bruce Momjian (#2)
Re: Minor patch to C++ large object interface (cures two ills)

On Mon, Sep 25, 2000 at 08:53:02AM -0400, Bruce Momjian wrote:

First, I need context diffs, diff -c. Second, does the END cause
problems in cases where Close() is called more than once? For example,
Close is called as part of PgLargeObject::Open.

I've moved the BEGIN/END to be just before/after the lo_ functions are called,
which gives me a chance to guard the END statement with the check for a valid
pgFd. I'm mildly worried about bracketing the lo_create() call, but it seems
to work this way, and this object is pretty screwed up anyway. :)

In the long run, I may create my own C++ API, which will pool db connections,
handle locking, and have a way to latch in a callback for asynchronous
notifications.

Index: pglobject.cc
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/libpq++/pglobject.cc,v
retrieving revision 1.6
diff -c -r1.6 pglobject.cc
*** pglobject.cc        2000/04/22 22:39:15     1.6
--- pglobject.cc        2000/09/25 16:26:22
***************
*** 88,93 ****
--- 88,94 ----
    // Close any prior object
    Close();
    // Open the object
+   Exec("BEGIN");
    pgFd = lo_open(pgConn, pgObject, INV_READ|INV_WRITE);

// Check for possible errors
***************
*** 119,125 ****

void PgLargeObject::Close()
{
! if (pgFd >= 0) lo_close(pgConn, pgFd);
pgFd = -1;
}

--- 120,129 ----

void PgLargeObject::Close()
{
! if (pgFd >= 0) {
! lo_close(pgConn, pgFd);
! Exec("END");
! }
pgFd = -1;
}

***************
*** 147,152 ****
--- 151,160 ----
    return lo_tell(pgConn, pgFd);
  }
+ Oid PgLargeObject::LOid()
+ {
+       return pgObject;
+ }

Oid PgLargeObject::Import(const char* filename)
{

--
Adam Haberlach | A billion hours ago, human life appeared on
adam@newsnipple.com | earth. A billion minutes ago, Christianity
http://www.newsnipple.com | emerged. A billion Coca-Colas ago was
'88 EX500 | yesterday morning. -1996 Coca-Cola Ann. Rpt.