pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feed From: J. T. Vermeulen <jtv@cistron-office.nl>
To: pgsql-interfaces@postgresql.org
Subject: Suggested patches for libpq++/pgdatabase.*
Date: Mon, 26 Feb 2001 14:34:46 +0100
Message-ID: <20010226143446.B17746@cistron.nl> (raw )
Suggest the following fixes for a future version. These include some minor
changes of interface (ints changed to bools) that should be compatible at the
source level but incompatible at the linking level, so those may have to be
skipped or deferred to some more convenient time.
Other changes: fixed possible portability problem for weird platforms (using
memset() to clear pointers); fixed minor memory leak in PrintTuples(), and
marked PrintTuples() / DisplayTuples() as obsolescent; changed dubious
parameter names "string" to "str".
inline patch 1: postgresql-7.0.3-jtv/src/interfaces/libpq++/pgdatabase.cc, postgresql-7.0.3-jtv/src/interfaces/libpq++/pgdatabase.h (+38/-32 lines) download inline-1.patch --- postgresql-7.0.3/src/interfaces/libpq++/pgdatabase.cc Sat Jan 29 17:58:52 2000
+++ postgresql-7.0.3-jtv/src/interfaces/libpq++/pgdatabase.cc Mon Feb 26 14:17:32 2001
@@ -18,37 +18,41 @@
#include "pgdatabase.h"
-void PgDatabase::DisplayTuples(FILE *out, int fillAlign,
- const char* fieldSep, int printHeader,
- int /* quiet */)
+// OBSOLESCENT (uses PQprint(), which is no longer being maintained)
+void PgDatabase::DisplayTuples(FILE *out,
+ bool fillAlign,
+ const char* fieldSep,
+ bool printHeader,
+ bool /* quiet */)
{
PQprintOpt po;
- memset(&po,0,sizeof(po));
-
- po.align = fillAlign;
- po.fieldSep = (char *)fieldSep;
po.header = printHeader;
+ po.align = fillAlign;
+ po.standard = po.html3 = po.expanded = po.pager = 0;
+ po.fieldSep = const_cast<char *>(fieldSep);
+ po.tableOpt = po.caption = 0;
+ po.fieldName = 0;
PQprint(out,pgResult,&po);
}
-
-void PgDatabase::PrintTuples(FILE *out, int printAttName, int terseOutput,
- int width)
+// OBSOLESCENT (uses PQprint(), which is no longer being maintained)
+void PgDatabase::PrintTuples(FILE *out,
+ bool printAttName,
+ bool terseOutput,
+ bool fillAlign)
{
PQprintOpt po;
- memset(&po,0,sizeof(po));
-
- po.align = width;
-
- if(terseOutput) po.fieldSep = strdup("|");
- else po.fieldSep = "";
-
po.header = printAttName;
+ po.align = fillAlign;
+ po.standard = po.html3 = po.expanded = po.pager = 0;
+ po.tableOpt = po.caption = 0;
+ po.fieldSep = const_cast<char *>(terseOutput ? "" : "|");
+ po.fieldName = 0;
PQprint(out,pgResult,&po);
}
@@ -126,13 +130,13 @@
}
-int PgDatabase::GetIsNull(int tup_num, int field_num)
+bool PgDatabase::GetIsNull(int tup_num, int field_num)
{
return PQgetisnull(pgResult, tup_num, field_num);
}
-int PgDatabase::GetIsNull(int tup_num, const char* field_name)
+bool PgDatabase::GetIsNull(int tup_num, const char* field_name)
{
return PQgetisnull(pgResult, tup_num, FieldNum(field_name));
}
@@ -150,15 +154,15 @@
}
-int PgDatabase::GetLine(char* string, int length)
+int PgDatabase::GetLine(char str[], int length)
{
-return PQgetline(pgConn, string, length);
+return PQgetline(pgConn, str, length);
}
-void PgDatabase::PutLine(const char* string)
+void PgDatabase::PutLine(const char str[])
{
-PQputline(pgConn, string);
+PQputline(pgConn, str);
}
--- postgresql-7.0.3/src/interfaces/libpq++/pgdatabase.h Sun Apr 23 00:39:15 2000
+++ postgresql-7.0.3-jtv/src/interfaces/libpq++/pgdatabase.h Mon Feb 26 14:17:44 2001
@@ -37,7 +37,7 @@
class PgDatabase : public PgConnection {
public:
// connect to the database with conninfo
- PgDatabase(const char* conninfo) : PgConnection(conninfo) {}
+ explicit PgDatabase(const char conninfo[]) : PgConnection(conninfo) {}
~PgDatabase() {} // close connection and clean up
@@ -53,18 +53,20 @@
short FieldSize(const char* field_name);
const char* GetValue(int tup_num, int field_num);
const char* GetValue(int tup_num, const char* field_name);
- int GetIsNull(int tup_num, int field_num);
- int GetIsNull(int tup_num, const char* field_name);
+ bool GetIsNull(int tup_num, int field_num);
+ bool GetIsNull(int tup_num, const char* field_name);
int GetLength(int tup_num, int field_num);
int GetLength(int tup_num, const char* field_name);
- void DisplayTuples(FILE *out = 0, int fillAlign = 1,
- const char* fieldSep = "|",int printHeader = 1, int quiet = 0) ;
- void PrintTuples(FILE *out = 0, int printAttName = 1,
- int terseOutput = 0, int width = 0) ;
+
+ // OBSOLESCENT (use PQprint()):
+ void DisplayTuples(FILE *out=0, bool fillAlign=true,
+ const char* fieldSep="|", bool printHeader=true, bool quiet=false) ;
+ void PrintTuples(FILE *out=0, bool printAttName=true,
+ bool terseOutput=false, bool fillAlign=false) ;
// copy command related access
- int GetLine(char* string, int length);
- void PutLine(const char* string);
+ int GetLine(char str[], int length);
+ void PutLine(const char str[]);
const char* OidStatus();
int EndCopy();
view thread (2+ messages) latest in thread
Message-ID: <20010226143446.B17746@cistron.nl>
Permalink: ../20010226143446.B17746@cistron.nl/
Also on: postgresql.org/message-id/20010226143446.B17746@cistron.nl
copy link · copy postgr.es · copy git am
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: jtv@cistron-office.nl
Subject: Re: Suggested patches for libpq++/pgdatabase.*
In-Reply-To: <20010226143446.B17746@cistron.nl>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox