Index: src/interfaces/libpq++/README
===================================================================
RCS file: /var/lib/cvs/pgsql/src/interfaces/libpq++/README,v
retrieving revision 1.3
diff -c -r1.3 README
*** src/interfaces/libpq++/README	23 May 1999 01:03:57 -0000	1.3
--- src/interfaces/libpq++/README	22 May 2002 18:26:32 -0000
***************
*** 1,4 ****
- 
  Based on the original work by William Wanders (wwanders@sci.kun.nl)
  and Jolly Chen (jolly@cs.berkeley.edu), this is the first set of
  changes to libpq++ since ~1997.  Pgenv has been removed, deprecated 
--- 1,3 ----
***************
*** 10,17 ****
  The API provided herein is subject to change in later versions of 
  PostgreSQL.
  
! For details on how to to use libpq++, see the man page in the man/
! subdirectory and the test programs in the examples/ subdirectory.
  
  ** PgConnection has been changed to accept either the environment
  variables or conninfo style strings.  See the PQconnectdb in the
--- 9,17 ----
  The API provided herein is subject to change in later versions of 
  PostgreSQL.
  
! For details on how to to use libpq++, see Section 3 in Part 1 of
! the PostgreSQL Developer's Guide and the test programs in the
! examples/ subdirectory.
  
  ** PgConnection has been changed to accept either the environment
  variables or conninfo style strings.  See the PQconnectdb in the
Index: src/interfaces/libpq++/libpq++.h
===================================================================
RCS file: /var/lib/cvs/pgsql/src/interfaces/libpq++/libpq++.h,v
retrieving revision 1.10
diff -c -r1.10 libpq++.h
*** src/interfaces/libpq++/libpq++.h	24 Jan 2001 19:43:32 -0000	1.10
--- src/interfaces/libpq++/libpq++.h	22 May 2002 18:26:32 -0000
***************
*** 21,28 ****
--- 21,31 ----
   *-------------------------------------------------------------------------
   */
  
+ 
  #ifndef LIBPQXX_H
  #define LIBPQXX_H
+ 
+ #include <string.h>
  
  #include "libpq++/pgconnection.h"
  #include "libpq++/pgdatabase.h"
Index: src/interfaces/libpq++/pgconnection.cc
===================================================================
RCS file: /var/lib/cvs/pgsql/src/interfaces/libpq++/pgconnection.cc,v
retrieving revision 1.13
diff -c -r1.13 pgconnection.cc
*** src/interfaces/libpq++/pgconnection.cc	11 Mar 2002 15:08:18 -0000	1.13
--- src/interfaces/libpq++/pgconnection.cc	22 May 2002 18:26:32 -0000
***************
*** 21,27 ****
  using namespace std;
  #endif
  
- 
  // ****************************************************************
  //
  // PgConnection Implementation
--- 21,26 ----
***************
*** 38,46 ****
  PgConnection::PgConnection(const char* conninfo)
  	: pgConn(NULL), pgResult(NULL), pgCloseConnection(true)
  {
-     
    // Connect to the database
!   Connect( conninfo );
  }
  
  
--- 37,44 ----
  PgConnection::PgConnection(const char* conninfo)
  	: pgConn(NULL), pgResult(NULL), pgCloseConnection(true)
  {
    // Connect to the database
!   Connect(conninfo);
  }
  
  
***************
*** 59,70 ****
  void PgConnection::CloseConnection() 
  {
    // if the connection is open, close it first
!   if ( pgCloseConnection ) {    
!        if(pgResult) PQclear(pgResult);
!        pgResult=NULL;
!        if(pgConn) PQfinish(pgConn);
!        pgConn=NULL;
!        pgCloseConnection=false;
    }
  }
  
--- 57,70 ----
  void PgConnection::CloseConnection() 
  {
    // if the connection is open, close it first
!   if (pgCloseConnection) {    
!        if (pgResult)
! 		   PQclear(pgResult);
!        pgResult = NULL;
!        if (pgConn)
! 		   PQfinish(pgConn);
!        pgConn = NULL;
!        pgCloseConnection = false;
    }
  }
  
***************
*** 95,101 ****
  // PgConnection::exec  -- send a query to the backend
  ExecStatusType PgConnection::Exec(const char* query)
  {
!   // Clear the Result Stucture if needed
    if (pgResult)
      PQclear(pgResult); 
  
--- 95,101 ----
  // PgConnection::exec  -- send a query to the backend
  ExecStatusType PgConnection::Exec(const char* query)
  {
!   // Clear the result stucture if needed
    if (pgResult)
      PQclear(pgResult); 
  
***************
*** 113,137 ****
  int PgConnection::ExecCommandOk(const char* query)
  {
  	return Exec(query) == PGRES_COMMAND_OK;
! } // End ExecCommandOk()
  
  int PgConnection::ExecTuplesOk(const char* query)
  {
  	return Exec(query) == PGRES_TUPLES_OK;
! } // End ExecTuplesOk()
! 
! 
  
  // Don't know why these next two need to be part of Connection
  
  // PgConnection::notifies() -- returns a notification from a list of unhandled notifications
  PGnotify* PgConnection::Notifies()
  {
-   Exec(" "); 
    return PQnotifies(pgConn);
  }
  
- 
  // From Integer To String Conversion Function
  string PgConnection::IntToString(int n)
  {
--- 113,133 ----
  int PgConnection::ExecCommandOk(const char* query)
  {
  	return Exec(query) == PGRES_COMMAND_OK;
! }
  
  int PgConnection::ExecTuplesOk(const char* query)
  {
  	return Exec(query) == PGRES_TUPLES_OK;
! }
  
  // Don't know why these next two need to be part of Connection
  
  // PgConnection::notifies() -- returns a notification from a list of unhandled notifications
  PGnotify* PgConnection::Notifies()
  {
    return PQnotifies(pgConn);
  }
  
  // From Integer To String Conversion Function
  string PgConnection::IntToString(int n)
  {
***************
*** 140,166 ****
    return buffer;
  }
  
- 
- 
  bool PgConnection::ConnectionBad() const
  { 
! return Status() == CONNECTION_BAD; 
  }
  
- 
  const char* PgConnection::ErrorMessage() const
  { 
! return (const char *)PQerrorMessage(pgConn); 
  }
    
- 
  const char* PgConnection::DBName() const
  { 
! return (const char *)PQdb(pgConn); 
  }
  
  PQnoticeProcessor PgConnection::SetNoticeProcessor(PQnoticeProcessor proc, void *arg)
  {
! return PQsetNoticeProcessor(pgConn, proc, arg);
  }
  
--- 136,158 ----
    return buffer;
  }
  
  bool PgConnection::ConnectionBad() const
  { 
!   return Status() == CONNECTION_BAD; 
  }
  
  const char* PgConnection::ErrorMessage() const
  { 
!   return (const char *)PQerrorMessage(pgConn); 
  }
    
  const char* PgConnection::DBName() const
  { 
!   return (const char *)PQdb(pgConn); 
  }
  
  PQnoticeProcessor PgConnection::SetNoticeProcessor(PQnoticeProcessor proc, void *arg)
  {
!   return PQsetNoticeProcessor(pgConn, proc, arg);
  }
  
Index: src/interfaces/libpq++/pgconnection.h
===================================================================
RCS file: /var/lib/cvs/pgsql/src/interfaces/libpq++/pgconnection.h,v
retrieving revision 1.16
diff -c -r1.16 pgconnection.h
*** src/interfaces/libpq++/pgconnection.h	11 Mar 2002 15:08:18 -0000	1.16
--- src/interfaces/libpq++/pgconnection.h	22 May 2002 18:26:32 -0000
***************
*** 26,32 ****
  }
  
  /* We assume that the C++ compiler will have these keywords, even though
!  * pg_config.h may have #define'd them to empty because C compiler doesn't.
   */
  #undef const
  #undef inline
--- 26,32 ----
  }
  
  /* We assume that the C++ compiler will have these keywords, even though
!  * pg_config.h may have #define'd them to empty because the C compiler doesn't.
   */
  #undef const
  #undef inline
Index: src/interfaces/libpq++/pgcursordb.cc
===================================================================
RCS file: /var/lib/cvs/pgsql/src/interfaces/libpq++/pgcursordb.cc,v
retrieving revision 1.6
diff -c -r1.6 pgcursordb.cc
*** src/interfaces/libpq++/pgcursordb.cc	30 Sep 2001 22:30:37 -0000	1.6
--- src/interfaces/libpq++/pgcursordb.cc	22 May 2002 18:26:32 -0000
***************
*** 60,85 ****
  	     cmd += " BINARY";
  	cmd += " CURSOR FOR " + query;
  	return ExecCommandOk( cmd.c_str() );
! } // End Declare()
  
  // Fetch ALL tuples in given direction
  int PgCursor::Fetch(const char* dir)
  {
  	return Fetch("ALL", dir);
! } // End Fetch()
  
  // Fetch specified amount of tuples in given direction
  int PgCursor::Fetch(unsigned num, const char* dir)
  {
  	return Fetch( IntToString(num), dir );
! } // End Fetch()
  
  // Create and execute the actual fetch command with the given arguments
  int PgCursor::Fetch(string num, string dir)
  {
  	string cmd = "FETCH " + dir + " " + num + " IN " + pgCursor;
  	return ExecTuplesOk( cmd.c_str() );
! } // End Fetch()
  
  // Close the cursor: no more queries using the cursor should be allowed
  // Actually, the backend should take care of it.
--- 60,85 ----
  	     cmd += " BINARY";
  	cmd += " CURSOR FOR " + query;
  	return ExecCommandOk( cmd.c_str() );
! }
  
  // Fetch ALL tuples in given direction
  int PgCursor::Fetch(const char* dir)
  {
  	return Fetch("ALL", dir);
! }
  
  // Fetch specified amount of tuples in given direction
  int PgCursor::Fetch(unsigned num, const char* dir)
  {
  	return Fetch( IntToString(num), dir );
! }
  
  // Create and execute the actual fetch command with the given arguments
  int PgCursor::Fetch(string num, string dir)
  {
  	string cmd = "FETCH " + dir + " " + num + " IN " + pgCursor;
  	return ExecTuplesOk( cmd.c_str() );
! }
  
  // Close the cursor: no more queries using the cursor should be allowed
  // Actually, the backend should take care of it.
***************
*** 87,90 ****
  {
  	string cmd = "CLOSE " + pgCursor;
  	return ExecCommandOk( cmd.c_str() );
! } // End CloseCursor()
--- 87,90 ----
  {
  	string cmd = "CLOSE " + pgCursor;
  	return ExecCommandOk( cmd.c_str() );
! }
Index: src/interfaces/libpq++/pgcursordb.h
===================================================================
RCS file: /var/lib/cvs/pgsql/src/interfaces/libpq++/pgcursordb.h,v
retrieving revision 1.9
diff -c -r1.9 pgcursordb.h
*** src/interfaces/libpq++/pgcursordb.h	30 Sep 2001 22:30:37 -0000	1.9
--- src/interfaces/libpq++/pgcursordb.h	22 May 2002 18:26:32 -0000
***************
*** 32,38 ****
  #define PGSTD
  #endif
  
- 
  // ****************************************************************
  //
  // PgCursor - a class for querying databases using a cursor
--- 32,37 ----
***************
*** 50,56 ****
    ~PgCursor();	// close connection and clean up
    
    // Commands associated with cursor interface
!   int Declare(PGSTD string query, bool binary=false);	// Declare a cursor with given name
    int Fetch(const char* dir = "FORWARD");		// Fetch ALL tuples in given direction
    int Fetch(unsigned num, const char* dir = "FORWARD");	// Fetch specified amount of tuples
    int Close();	// Close the cursor
--- 49,55 ----
    ~PgCursor();	// close connection and clean up
    
    // Commands associated with cursor interface
!   int Declare(PGSTD string query, bool binary = false);	// Declare a cursor with given name
    int Fetch(const char* dir = "FORWARD");		// Fetch ALL tuples in given direction
    int Fetch(unsigned num, const char* dir = "FORWARD");	// Fetch specified amount of tuples
    int Close();	// Close the cursor
Index: src/interfaces/libpq++/pglobject.cc
===================================================================
RCS file: /var/lib/cvs/pgsql/src/interfaces/libpq++/pglobject.cc,v
retrieving revision 1.8
diff -c -r1.8 pglobject.cc
*** src/interfaces/libpq++/pglobject.cc	30 Sep 2001 22:30:37 -0000	1.8
--- src/interfaces/libpq++/pglobject.cc	22 May 2002 18:26:32 -0000
***************
*** 104,110 ****
  }
  
  // PgLargeObject::unlink
! // destruct large object and delete from it from the database
  int PgLargeObject::Unlink()
  {
    // Unlink the object
--- 104,110 ----
  }
  
  // PgLargeObject::unlink
! // destroy large object and delete from it from the database
  int PgLargeObject::Unlink()
  {
    // Unlink the object
***************
*** 155,167 ****
  
  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); 
  }
  
  
--- 155,167 ----
  
  Oid PgLargeObject::Import(const char* filename) 
  { 
!   return pgObject = lo_import(pgConn, filename); 
  }
  
  
  int PgLargeObject::Export(const char* filename) 
  { 
!   return lo_export(pgConn, pgObject, filename); 
  }
  
  
Index: src/interfaces/libpq++/examples/Makefile
===================================================================
RCS file: /var/lib/cvs/pgsql/src/interfaces/libpq++/examples/Makefile,v
retrieving revision 1.12
diff -c -r1.12 Makefile
*** src/interfaces/libpq++/examples/Makefile	17 Jun 2000 00:10:20 -0000	1.12
--- src/interfaces/libpq++/examples/Makefile	22 May 2002 18:26:32 -0000
***************
*** 1,18 ****
  #
! # Makefile for example programs
  #
  
  
  LIBNAME= libpq++
! HEADERDIR= /usr/local/pgsql/include
! LIBPQDIR= /usr/local/pgsql/lib
! 
! 
! # We have to override -Werror, which makes warnings, fatal, because we
! # inevitably get the warning, "abstract declarator used as declaration"
! # because of our inclusion of c.h and we don't know how to stop that.
  
- #CXXFLAGS= $(CFLAGS) -Wno-error -Wno-unused -Wl,-Bdynamic
  CXXFLAGS= $(CFLAGS)
  
  CXXFLAGS+= -I$(HEADERDIR)
--- 1,22 ----
+ #-------------------------------------------------------------------------
  #
! # Makefile for libpq++ examples
  #
+ # Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
+ # Portions Copyright (c) 1994, Regents of the University of California
+ #
+ # $Header$
+ #
+ #-------------------------------------------------------------------------
  
+ subdir = src/interfaces/libpq++/examples
+ top_builddir = ../../../..
+ include $(top_builddir)/src/Makefile.global
  
  LIBNAME= libpq++
! HEADERDIR= $(includedir)
! LIBPQDIR= $(libdir)
  
  CXXFLAGS= $(CFLAGS)
  
  CXXFLAGS+= -I$(HEADERDIR)
