Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit290978f

Browse files
committed
Remove broken tracing code (which would be dangerous if it did work...)
libpq++.h contained copies of the class declarations in the other libpq++include files, which was bogus enough, but the declarations were notcompletely in step with the real declarations. Remove these in favorof including the headers with #include. Make PgConnection destructorvirtual (not absolutely necessary, but seems like a real good ideaconsidering the number of subclasses derived from it). Give all classesdeclared private copy constructors and assignment operators, to preventcompiler from thinking it can copy these objects safely.
1 parent51c9294 commit290978f

File tree

9 files changed

+95
-252
lines changed

9 files changed

+95
-252
lines changed

‎src/interfaces/libpq++/Makefile.in

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Copyright (c) 1994, Regents of the University of California
77
#
88
# IDENTIFICATION
9-
# $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/Makefile.in,v 1.23 2000/03/31 05:00:36 tgl Exp $
9+
# $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/Makefile.in,v 1.24 2000/04/22 22:39:15 tgl Exp $
1010
#
1111
#-------------------------------------------------------------------------
1212

@@ -27,8 +27,6 @@ CXXFLAGS+= -I$(SRCDIR)/backend \
2727
-I$(SRCHEADERDIR)\
2828
-I$(LIBPQDIR)
2929

30-
#CXXFLAGS+= -DDEBUGFILE
31-
3230
ifdefKRBVERS
3331
CXXFLAGS+=$(KRBFLAGS)
3432
endif

‎src/interfaces/libpq++/libpq++.h

Lines changed: 10 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -8,201 +8,26 @@
88
* used for building front-end applications
99
*
1010
* NOTES
11-
* Currently under construction.
11+
* This is intended to be included by client applications.
12+
* It will not work as an inclusion in the libpq++ sources, since
13+
* in the build environment the individual include files are not
14+
* yet installed in a subdirectory.
1215
*
1316
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
1417
* Portions Copyright (c) 1994, Regents of the University of California
1518
*
16-
* $Id: libpq++.h,v 1.8 2000/04/14 01:00:16 tgl Exp $
19+
* $Id: libpq++.h,v 1.9 2000/04/22 22:39:15 tgl Exp $
1720
*
1821
*-------------------------------------------------------------------------
1922
*/
2023

2124
#ifndefLIBPQXX_H
2225
#defineLIBPQXX_H
2326

24-
extern"C" {
25-
#include"config.h"
26-
}
27-
28-
/* We assume that the C++ compiler will have these keywords, even though
29-
* config.h may have #define'd them to empty because C compiler doesn't.
30-
*/
31-
#undef const
32-
#undef inline
33-
#undef signed
34-
#undef volatile
35-
36-
#ifdef HAVE_CXX_STRING_HEADER
37-
#include<string>
38-
#endif
39-
40-
extern"C" {
41-
#include"postgres.h"
42-
#include"libpq-fe.h"
43-
}
44-
45-
#ifdef HAVE_NAMESPACE_STD
46-
usingnamespacestd;
47-
#endif
48-
49-
50-
// ****************************************************************
51-
//
52-
// PgConnection - a connection made to a postgres backend
53-
//
54-
// ****************************************************************
55-
classPgConnection {
56-
protected:
57-
PGconn* pgConn;// Connection Structures
58-
PGresult* pgResult;// Query Result
59-
int pgCloseConnection;// Flag indicating whether the connection should be closed
60-
ConnStatusTypeConnect(constchar* conninfo);
61-
stringIntToString(int);
62-
PgConnection();
63-
64-
public:
65-
PgConnection(constchar* conninfo);// use reasonable and environment defaults
66-
~PgConnection();// close connection and clean up
67-
68-
ConnStatusTypeStatus();
69-
intConnectionBad();
70-
constchar*ErrorMessage();
71-
72-
// returns the database name of the connection
73-
constchar*DBName();
74-
75-
ExecStatusTypeExec(constchar* query);// send a query to the backend
76-
intExecCommandOk(constchar* query);// send a command and check if it's
77-
intExecTuplesOk(constchar* query);// send a command and check if tuple
78-
PGnotify*Notifies();
79-
};
80-
81-
// ****************************************************************
82-
//
83-
// PgDatabase - a class for accessing databases
84-
//
85-
// ****************************************************************
86-
classPgDatabase :publicPgConnection {
87-
protected:
88-
PgDatabase() : PgConnection() {}// Do not connect
89-
90-
public:
91-
// connect to the database with conninfo
92-
PgDatabase(constchar *conninfo) : PgConnection(conninfo) {};
93-
~PgDatabase() {};// close connection and clean up
94-
// query result access
95-
intTuples();
96-
intCmdTuples();
97-
intFields();
98-
constchar*FieldName(int field_num);
99-
intFieldNum(constchar *field_name);
100-
OidFieldType(int field_num);
101-
OidFieldType(constchar *field_name);
102-
shortFieldSize(int field_num);
103-
shortFieldSize(constchar *field_name);
104-
constchar*GetValue(int tup_num,int field_num);
105-
constchar*GetValue(int tup_num,constchar *field_name);
106-
intGetIsNull(int tup_num,int field_num);
107-
intGetIsNull(int tup_num,constchar* field_name);
108-
intGetLength(int tup_num,int field_num);
109-
intGetLength(int tup_num,constchar* field_name);
110-
voidDisplayTuples(FILE *out =0,int fillAlign =1,
111-
constchar* fieldSep ="|",int printHeader =1,int quiet =0) ;
112-
voidPrintTuples(FILE *out =0,int printAttName =1,
113-
int terseOutput =0,int width =0) ;
114-
115-
// copy command related access
116-
intGetLine(char* string,int length);
117-
voidPutLine(constchar* string);
118-
constchar *OidStatus();
119-
intEndCopy();
120-
};
121-
122-
123-
124-
// ****************************************************************
125-
//
126-
// PGLargeObject - a class for accessing Large Object in a database
127-
//
128-
// ****************************************************************
129-
classPgLargeObject :publicPgConnection {
130-
private:
131-
int pgFd;
132-
Oid pgObject;
133-
string loStatus;
134-
135-
public:
136-
PgLargeObject(constchar* conninfo =0);// use reasonable defaults and create large object
137-
PgLargeObject(Oid lobjId,constchar* conninfo =0);// use reasonable defaults and open large object
138-
~PgLargeObject();// close connection and clean up
139-
140-
voidCreate();
141-
voidOpen();
142-
voidClose();
143-
intRead(char* buf,int len);
144-
intWrite(constchar* buf,int len);
145-
intLSeek(int offset,int whence);
146-
intTell();
147-
intUnlink();
148-
OidLOid();
149-
OidImport(constchar* filename);
150-
intExport(constchar* filename);
151-
stringStatus();
152-
};
153-
154-
155-
// ****************************************************************
156-
//
157-
// PgTransaction - a class for running transactions against databases
158-
//
159-
// ****************************************************************
160-
classPgTransaction :publicPgDatabase {
161-
protected:
162-
ExecStatusTypeBeginTransaction();
163-
ExecStatusTypeEndTransaction();
164-
PgTransaction() : PgDatabase() {}// Do not connect
165-
166-
public:
167-
PgTransaction(constchar* conninfo);// use reasonable & environment defaults
168-
// connect to the database with given environment and database name
169-
PgTransaction(const PgConnection&);
170-
virtual~PgTransaction();// close connection and clean up
171-
172-
};
173-
174-
175-
// ****************************************************************
176-
//
177-
// PgCursor - a class for querying databases using a cursor
178-
//
179-
// ****************************************************************
180-
classPgCursor :publicPgTransaction {
181-
protected:
182-
intFetch(const string& num,const string& dir);
183-
string pgCursor;
184-
PgCursor() : PgTransaction() {}// Do not connect
185-
186-
public:
187-
PgCursor(constchar* dbName,constchar* cursor);// use reasonable & environment defaults
188-
// connect to the database with given environment and database name
189-
PgCursor(const PgConnection&,constchar* cursor);
190-
virtual~PgCursor();// close connection and clean up
191-
192-
// Commands associated with cursor interface
193-
intDeclare(const string& query,int binary =0);// Declare a cursor with given name
194-
intFetch(constchar* dir ="FORWARD");// Fetch ALL tuples in given direction
195-
intFetch(unsigned num,constchar* dir ="FORWARD");// Fetch specified amount of tuples
196-
intClose();// Close the cursor
197-
198-
// Accessors to the cursor name
199-
constchar*Cursor();
200-
voidCursor(const string& cursor);
201-
};
202-
203-
204-
205-
// buffer size
206-
#defineBUFSIZE1024
27+
#include"libpq++/pgconnection.h"
28+
#include"libpq++/pgdatabase.h"
29+
#include"libpq++/pglobject.h"
30+
#include"libpq++/pgtransdb.h"
31+
#include"libpq++/pgcursordb.h"
20732

20833
#endif/* LIBPQXX_H */

‎src/interfaces/libpq++/pgconnection.cc

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*-------------------------------------------------------------------------
22
*
33
* FILE
4-
*pgconnection.cpp
4+
*pgconnection.cc
55
*
66
* DESCRIPTION
77
* implementation of the PgConnection class.
@@ -10,16 +10,13 @@
1010
* Copyright (c) 1994, Regents of the University of California
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pgconnection.cc,v 1.8 2000/03/30 05:30:42 tgl Exp $
13+
* $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pgconnection.cc,v 1.9 2000/04/22 22:39:15 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
1717

1818
#include"pgconnection.h"
1919

20-
extern"C" {
21-
#include"fe-auth.h"
22-
}
2320

2421
// ****************************************************************
2522
//
@@ -46,12 +43,7 @@ PgConnection::PgConnection(const char* conninfo)
4643
// destructor - closes down the connection and cleanup
4744
PgConnection::~PgConnection()
4845
{
49-
// Terminate the debugging output if it was turned on
50-
#if defined(DEBUGFILE)
51-
PQuntrace(pgConn);
52-
#endif
53-
54-
// Close the conneciton only if needed
46+
// Close the connection only if needed
5547
// This feature will most probably be used by the derived classes that
5648
// need not close the connection after they are destructed.
5749
if ( pgCloseConnection ) {
@@ -64,22 +56,14 @@ PgConnection::~PgConnection()
6456
// establish a connection to a backend
6557
ConnStatusTypePgConnection::Connect(constchar* conninfo)
6658
{
67-
ConnStatusType cst;
68-
// Turn the trace on
69-
#if defined(DEBUGFILE)
70-
FILE *debug =fopen("/tmp/trace.out","w");
71-
PQtrace(pgConn, debug);
72-
#endif
73-
7459
// Connect to the database
7560
pgConn =PQconnectdb(conninfo);
61+
62+
// Now we have a connection we must close (even if it's bad!)
63+
pgCloseConnection =1;
7664

7765
// Status will return either CONNECTION_OK or CONNECTION_BAD
78-
cst =Status();
79-
if(CONNECTION_OK == cst) pgCloseConnection = (ConnStatusType)1;
80-
else pgCloseConnection = (ConnStatusType)0;
81-
82-
return cst;
66+
returnStatus();
8367
}
8468

8569
// PgConnection::status -- return connection or result status

‎src/interfaces/libpq++/pgconnection.h

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
1414
* Portions Copyright (c) 1994, Regents of the University of California
1515
*
16-
* $Id: pgconnection.h,v 1.6 2000/04/14 01:00:16 tgl Exp $
16+
* $Id: pgconnection.h,v 1.7 2000/04/22 22:39:15 tgl Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
2020

21-
#ifndefPGCONN_H
22-
#definePGCONN_H
21+
#ifndefPGCONNECTION_H
22+
#definePGCONNECTION_H
2323

2424
extern"C" {
2525
#include"config.h"
@@ -57,13 +57,13 @@ using namespace std;
5757
// derived from this class to obtain the connection interface.
5858
classPgConnection {
5959
protected:
60-
PGconn* pgConn;// ConnectionStructures
61-
PGresult* pgResult;// Query Result
62-
int pgCloseConnection;//Flag indicating whether theconnection should be closedor not
60+
PGconn* pgConn;// ConnectionStructure
61+
PGresult* pgResult;// Current Query Result
62+
int pgCloseConnection;//TRUE ifconnection should be closedby destructor
6363

6464
public:
6565
PgConnection(constchar* conninfo);// use reasonable & environment defaults
66-
~PgConnection();// close connection and clean up
66+
virtual~PgConnection();// close connection and clean up
6767

6868
// Connection status and error messages
6969
ConnStatusTypeStatus();
@@ -82,9 +82,14 @@ class PgConnection {
8282
protected:
8383
ConnStatusTypeConnect(constchar* conninfo);
8484
stringIntToString(int);
85-
86-
protected:
85+
// Default constructor is only available to subclasses
8786
PgConnection();
87+
88+
private:
89+
// We don't support copying of PgConnection objects,
90+
// so make copy constructor and assignment op private.
91+
PgConnection(const PgConnection&);
92+
PgConnection&operator= (const PgConnection&);
8893
};
8994

90-
#endif//PGCONN_H
95+
#endif//PGCONNECTION_H

‎src/interfaces/libpq++/pgcursordb.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@
1414
* Portions Copyright (c) 1994, Regents of the University of California
1515
*
1616
*
17-
* $Id: pgcursordb.h,v 1.4 2000/01/26 05:58:48 momjian Exp $
17+
* $Id: pgcursordb.h,v 1.5 2000/04/22 22:39:15 tgl Exp $
1818
*
1919
*-------------------------------------------------------------------------
2020
*/
2121

22-
#ifndefPGCURSOR_H
23-
#definePGCURSOR_H
22+
#ifndefPGCURSORDB_H
23+
#definePGCURSORDB_H
2424

25+
#ifndef PGTRANSDB_H
2526
#include"pgtransdb.h"
26-
27+
#endif
2728

2829

2930
// ****************************************************************
@@ -60,6 +61,12 @@ class PgCursor : public PgTransaction {
6061

6162
protected:
6263
PgCursor() : PgTransaction() {}// Do not connect
64+
65+
private:
66+
// We don't support copying of PgCursor objects,
67+
// so make copy constructor and assignment op private.
68+
PgCursor(const PgCursor&);
69+
PgCursor&operator= (const PgCursor&);
6370
};// End PgCursor Class Declaration
6471

65-
#endif//PGCURSOR_H
72+
#endif//PGCURSORDB_H

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp