summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian2002-06-15 18:49:29 +0000
committerBruce Momjian2002-06-15 18:49:29 +0000
commit2e58024066e1ddf63d729ffb42077938fe25a9bf (patch)
tree8af75e9dd7c45531ea18c44322eb628af57162dd
parent133df7ce70749156a6115ef49ef7d52e0c584adc (diff)
This patch fixes a few minor problems with libpq++: remove the deprecated
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
-rw-r--r--src/interfaces/libpq++/README6
-rw-r--r--src/interfaces/libpq++/examples/Makefile22
-rw-r--r--src/interfaces/libpq++/libpq++.h5
-rw-r--r--src/interfaces/libpq++/pgconnection.cc42
-rw-r--r--src/interfaces/libpq++/pgconnection.h4
-rw-r--r--src/interfaces/libpq++/pgcursordb.cc12
-rw-r--r--src/interfaces/libpq++/pgcursordb.h5
-rw-r--r--src/interfaces/libpq++/pglobject.cc8
8 files changed, 51 insertions, 53 deletions
diff --git a/src/interfaces/libpq++/README b/src/interfaces/libpq++/README
index 975bd54e79..810045b49b 100644
--- a/src/interfaces/libpq++/README
+++ b/src/interfaces/libpq++/README
@@ -1,4 +1,3 @@
-
Based on the original work by William Wanders ([email protected])
and Jolly Chen ([email protected]), 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
diff --git a/src/interfaces/libpq++/examples/Makefile b/src/interfaces/libpq++/examples/Makefile
index c6ce50f8c6..919e637712 100644
--- a/src/interfaces/libpq++/examples/Makefile
+++ b/src/interfaces/libpq++/examples/Makefile
@@ -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)
diff --git a/src/interfaces/libpq++/libpq++.h b/src/interfaces/libpq++/libpq++.h
index 10afb38d90..e429d3509f 100644
--- a/src/interfaces/libpq++/libpq++.h
+++ b/src/interfaces/libpq++/libpq++.h
@@ -16,14 +16,17 @@
* 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"
diff --git a/src/interfaces/libpq++/pgconnection.cc b/src/interfaces/libpq++/pgconnection.cc
index 352b70fb0c..074a6bdc43 100644
--- a/src/interfaces/libpq++/pgconnection.cc
+++ b/src/interfaces/libpq++/pgconnection.cc
@@ -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);
}
diff --git a/src/interfaces/libpq++/pgconnection.h b/src/interfaces/libpq++/pgconnection.h
index 95ee385f75..9e9cadb638 100644
--- a/src/interfaces/libpq++/pgconnection.h
+++ b/src/interfaces/libpq++/pgconnection.h
@@ -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
diff --git a/src/interfaces/libpq++/pgcursordb.cc b/src/interfaces/libpq++/pgcursordb.cc
index 585428ddfb..ee77a36b12 100644
--- a/src/interfaces/libpq++/pgcursordb.cc
+++ b/src/interfaces/libpq++/pgcursordb.cc
@@ -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()
+}
diff --git a/src/interfaces/libpq++/pgcursordb.h b/src/interfaces/libpq++/pgcursordb.h
index 7dca828ce1..43edc6e31c 100644
--- a/src/interfaces/libpq++/pgcursordb.h
+++ b/src/interfaces/libpq++/pgcursordb.h
@@ -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
diff --git a/src/interfaces/libpq++/pglobject.cc b/src/interfaces/libpq++/pglobject.cc
index 6bf5e30443..95e63c17df 100644
--- a/src/interfaces/libpq++/pglobject.cc
+++ b/src/interfaces/libpq++/pglobject.cc
@@ -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);
}