This repository has been archived by the owner on Sep 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 83
/
dbgPgConn.h
98 lines (82 loc) · 3.54 KB
/
dbgPgConn.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin III - PostgreSQL Tools
// RCS-ID: $Id$
// Copyright (C) 2002 - 2009, The pgAdmin Development Team
// This software is released under the Artistic Licence
//
// dbgPgConn.h - debugger
//
//////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// class dbgPgConn
//
// A dbgPgConn object encapsulates the connection to a PostgreSQL server. This
// class is a wrapper around a Pgconn that provides a convenient constructor
// and a few member functions.
//
// This class doesn't do much - instead, the real work happens in a dbgPgThread
// (a separate thread) that initiates commands and processes result sets.
//
////////////////////////////////////////////////////////////////////////////////
#ifndef DBGPGCONN_H
#define DBGPGCONN_H
#include <libpq-fe.h>
#include "debugger/frmDebugger.h"
#include "debugger/dbgPgThread.h"
#include "debugger/dbgConnProp.h"
enum DebuggerApiVersions
{
DEBUGGER_UNKNOWN_API = 0,
DEBUGGER_V1_API = 1,
DEBUGGER_V2_API = 2,
DEBUGGER_V3_API = 3
};
class dbgPgParams
{
public:
int nParams;
Oid *paramTypes;
char **paramValues;
int *paramModes;
};
class dbgPgConn
{
public:
dbgPgConn( frmDebugger *frame,
const wxString &server = wxT( "" ),
const wxString &database = wxT( "" ),
const wxString &username = wxT( "" ),
const wxString &password = wxT( "" ),
const wxString &port = wxT( "5432" ),
int sslmode = 0,
int sslverify = 0 );
dbgPgConn( frmDebugger *frame, const dbgConnProp & props, bool startThread = true );
~dbgPgConn();
bool BackendMinimumVersion(int major, int minor);
bool EdbMinimumVersion(int major, int minor);
bool GetIsEdb();
bool GetIsGreenplum();
DebuggerApiVersions DebuggerApiVersion();
wxString GetVersionString();
bool isConnected() const; // Returns true if the connection attempt succeeded
const wxString getName() const; // Returns human-friendly name for this connection
const wxString getHost() const; // Returns the host-name (or IP address) for this connection
const wxString getDatabase() const; // Returns the name of the database that we're connected to
PGconn *getConnection(); // Returns the libpq connection handle
void Close(); // Close this connection
void Cancel(); // Cancel any ongoing queries
void startCommand( const wxString &command, wxEvtHandler * caller, wxEventType eventType = wxEVT_NULL, dbgPgParams *params = NULL ); // Starts executing a command
void setNoticeHandler( PQnoticeProcessor handler, void * arg ); // Registers a NOTICE handler
PGresult *waitForCommand( const wxString &command ); // Starts a command and waits for completion
private:
void Init( const wxString &server, const wxString &database, const wxString &userName, const wxString &password, const wxString &port, int sslmode, int sslverify, bool startThread );
PGconn *m_pgConn; // libpq connection handler
dbgPgThread *m_workerThread; // Worker thread (this thread interacts with the server)
frmDebugger *m_frame;
int m_minorVersion, m_majorVersion;
bool m_isEdb;
bool m_isGreenplum;
DebuggerApiVersions m_debuggerApiVersion;
};
#endif