]> granicus.if.org Git - postgresql/commitdiff
This patch fixes a few minor problems with libpq++: remove the deprecated
authorBruce Momjian <bruce@momjian.us>
Sat, 15 Jun 2002 18:49:29 +0000 (18:49 +0000)
committerBruce Momjian <bruce@momjian.us>
Sat, 15 Jun 2002 18:49:29 +0000 (18:49 +0000)
PQExec(" ") in the wrapper around PQnotifies(), fix the Makefile for
the examples so that they will actually compile properly (with the
exception of #5, which depends on internal headers), make a minor change
to libpq++.h so that "make examples" now works on my machine, update
some documentation, fix some grammatical problems, and remove some of
the more hideous comments.

Neil Conway

src/interfaces/libpq++/README
src/interfaces/libpq++/examples/Makefile
src/interfaces/libpq++/libpq++.h
src/interfaces/libpq++/pgconnection.cc
src/interfaces/libpq++/pgconnection.h
src/interfaces/libpq++/pgcursordb.cc
src/interfaces/libpq++/pgcursordb.h
src/interfaces/libpq++/pglobject.cc

index 975bd54e79be8c9d68c7dd8217469df0d9298b1e..810045b49bd1fff73704ad1da2d947bdee357d65 100644 (file)
@@ -1,4 +1,3 @@
-
 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 
@@ -10,8 +9,9 @@ the function of libpq++.
 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.
+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 c6ce50f8c68113600a8b3bc3d684dc4e1e2ef941..919e637712f3c4416dc23b8e37a4ab5afaf989f8 100644 (file)
@@ -1,18 +1,22 @@
+#-------------------------------------------------------------------------
 #
-# Makefile for example programs
+# Makefile for libpq++ examples
 #
+# Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
+# Portions Copyright (c) 1994, Regents of the University of California
+#
+# $Header: /cvsroot/pgsql/src/interfaces/libpq++/examples/Attic/Makefile,v 1.13 2002/06/15 18:49:29 momjian Exp $
+#
+#-------------------------------------------------------------------------
 
+subdir = src/interfaces/libpq++/examples
+top_builddir = ../../../..
+include $(top_builddir)/src/Makefile.global
 
 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.
+HEADERDIR= $(includedir)
+LIBPQDIR= $(libdir)
 
-#CXXFLAGS= $(CFLAGS) -Wno-error -Wno-unused -Wl,-Bdynamic
 CXXFLAGS= $(CFLAGS)
 
 CXXFLAGS+= -I$(HEADERDIR)
index 10afb38d90f122fff572e1d049de3d05d1764ed7..e429d3509faf4c00d7f25468d69e2523ede85a41 100644 (file)
  * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: libpq++.h,v 1.10 2001/01/24 19:43:32 momjian Exp $
+ * $Id: libpq++.h,v 1.11 2002/06/15 18:49:29 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 
+
 #ifndef LIBPQXX_H
 #define LIBPQXX_H
 
+#include <string.h>
+
 #include "libpq++/pgconnection.h"
 #include "libpq++/pgdatabase.h"
 #include "libpq++/pglobject.h"
index 352b70fb0cc40f71ee7373b5204379249c3e6ef8..074a6bdc4336a32e28ce03558291fe2e002bb4fe 100644 (file)
@@ -10,7 +10,7 @@
  * Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pgconnection.cc,v 1.13 2002/03/11 15:08:18 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pgconnection.cc,v 1.14 2002/06/15 18:49:29 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -21,7 +21,6 @@
 using namespace std;
 #endif
 
-
 // ****************************************************************
 //
 // PgConnection Implementation
@@ -38,9 +37,8 @@ PgConnection::PgConnection()
 PgConnection::PgConnection(const char* conninfo)
        : pgConn(NULL), pgResult(NULL), pgCloseConnection(true)
 {
-    
   // Connect to the database
-  Connect( conninfo );
+  Connect(conninfo);
 }
 
 
@@ -59,12 +57,14 @@ PgConnection::~PgConnection()
 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;
+  if (pgCloseConnection) {    
+       if (pgResult)
+                  PQclear(pgResult);
+       pgResult = NULL;
+       if (pgConn)
+                  PQfinish(pgConn);
+       pgConn = NULL;
+       pgCloseConnection = false;
   }
 }
 
@@ -95,7 +95,7 @@ ConnStatusType PgConnection::Status() const
 // PgConnection::exec  -- send a query to the backend
 ExecStatusType PgConnection::Exec(const char* query)
 {
-  // Clear the Result Stucture if needed
+  // Clear the result stucture if needed
   if (pgResult)
     PQclear(pgResult); 
 
@@ -113,25 +113,21 @@ ExecStatusType PgConnection::Exec(const char* query)
 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)
 {
@@ -140,27 +136,23 @@ string PgConnection::IntToString(int n)
   return buffer;
 }
 
-
-
 bool PgConnection::ConnectionBad() const
 { 
-return Status() == CONNECTION_BAD; 
+  return Status() == CONNECTION_BAD; 
 }
 
-
 const char* PgConnection::ErrorMessage() const
 { 
-return (const char *)PQerrorMessage(pgConn); 
+  return (const char *)PQerrorMessage(pgConn); 
 }
   
-
 const char* PgConnection::DBName() const
 { 
-return (const char *)PQdb(pgConn); 
+  return (const char *)PQdb(pgConn); 
 }
 
 PQnoticeProcessor PgConnection::SetNoticeProcessor(PQnoticeProcessor proc, void *arg)
 {
-return PQsetNoticeProcessor(pgConn, proc, arg);
+  return PQsetNoticeProcessor(pgConn, proc, arg);
 }
 
index 95ee385f75782c853289f7d5160a074a048273f6..9e9cadb6384ad72b28597538dab7f645452845c1 100644 (file)
@@ -13,7 +13,7 @@
  * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  * 
- * $Id: pgconnection.h,v 1.16 2002/03/11 15:08:18 momjian Exp $
+ * $Id: pgconnection.h,v 1.17 2002/06/15 18:49:29 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@ extern "C" {
 }
 
 /* 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.
+ * pg_config.h may have #define'd them to empty because the C compiler doesn't.
  */
 #undef const
 #undef inline
index 585428ddfb1433cb6a139fd539fbeea28b71ffe4..ee77a36b12435b0a6af40a370e2e3bbe55e9e940 100644 (file)
@@ -10,7 +10,7 @@
  * Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pgcursordb.cc,v 1.6 2001/09/30 22:30:37 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pgcursordb.cc,v 1.7 2002/06/15 18:49:29 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -60,26 +60,26 @@ int PgCursor::Declare(string query, bool binary)
             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.
@@ -87,4 +87,4 @@ int PgCursor::Close()
 {
        string cmd = "CLOSE " + pgCursor;
        return ExecCommandOk( cmd.c_str() );
-} // End CloseCursor()
+}
index 7dca828ce1ac8b22b60e4ffb4e79e675cb8fc346..43edc6e31cd345c8ec0ae5c277f21b06c307198a 100644 (file)
@@ -14,7 +14,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  *
- *  $Id: pgcursordb.h,v 1.9 2001/09/30 22:30:37 tgl Exp $
+ *  $Id: pgcursordb.h,v 1.10 2002/06/15 18:49:29 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -32,7 +32,6 @@
 #define PGSTD
 #endif
 
-
 // ****************************************************************
 //
 // PgCursor - a class for querying databases using a cursor
@@ -50,7 +49,7 @@ public:
   ~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 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 6bf5e304438646d4c27ed052f85563698a135caa..95e63c17df3e19918a3cf45eaa5cf06ea7f9b7bc 100644 (file)
@@ -10,7 +10,7 @@
  * Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pglobject.cc,v 1.8 2001/09/30 22:30:37 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pglobject.cc,v 1.9 2002/06/15 18:49:29 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -104,7 +104,7 @@ void PgLargeObject::Open()
 }
 
 // PgLargeObject::unlink
-// destruct large object and delete from it from the database
+// destroy large object and delete from it from the database
 int PgLargeObject::Unlink()
 {
   // Unlink the object
@@ -155,13 +155,13 @@ int PgLargeObject::Tell() const
 
 Oid PgLargeObject::Import(const char* filename) 
 { 
-  return pgObject = lo_import(pgConn, (char*)filename); 
+  return pgObject = lo_import(pgConn, filename); 
 }
 
 
 int PgLargeObject::Export(const char* filename) 
 { 
-  return lo_export(pgConn, pgObject, (char*)filename); 
+  return lo_export(pgConn, pgObject, filename); 
 }