~ubuntu-branches/ubuntu/utopic/pgadmin3/utopic-proposed

« back to all changes in this revision

Viewing changes to src/include/pgConn.h

  • Committer: Bazaar Package Importer
  • Author(s): Raphael Enrici
  • Date: 2004-12-14 23:46:39 UTC
  • Revision ID: james.westby@ubuntu.com-20041214234639-tve0i5l49fq13jli
Tags: upstream-1.2.0
ImportĀ upstreamĀ versionĀ 1.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//////////////////////////////////////////////////////////////////////////
 
2
//
 
3
// pgAdmin III - PostgreSQL Tools
 
4
// RCS-ID:      $Id: pgConn.h,v 1.27 2004/10/13 19:09:13 andreas Exp $
 
5
// Copyright (C) 2002 - 2004, The pgAdmin Development Team
 
6
// This software is released under the Artistic Licence
 
7
//
 
8
// pgConn.h - PostgreSQL Connection class
 
9
//
 
10
//////////////////////////////////////////////////////////////////////////
 
11
 
 
12
#ifndef PGCONN_H
 
13
#define PGCONN_H
 
14
 
 
15
// wxWindows headers
 
16
#include <wx/wx.h>
 
17
 
 
18
// PostgreSQL headers
 
19
#include <libpq-fe.h>
 
20
 
 
21
// App headers
 
22
#include "pgAdmin3.h"
 
23
#include "pgSet.h"
 
24
 
 
25
 
 
26
// status enums
 
27
enum 
 
28
{
 
29
    PGCONN_OK = CONNECTION_OK,
 
30
    PGCONN_BAD = CONNECTION_BAD,
 
31
    PGCONN_REFUSED,
 
32
    PGCONN_DNSERR,
 
33
    PGCONN_ABORTED,     // connect user aborted
 
34
    PGCONN_BROKEN       // tcp/pipe broken
 
35
};
 
36
 
 
37
enum 
 
38
{
 
39
    PGCONN_EMPTY_QUERY = PGRES_EMPTY_QUERY,
 
40
    PGCONN_COMMAND_OK = PGRES_COMMAND_OK,
 
41
    PGCONN_TUPLES_OK = PGRES_TUPLES_OK,
 
42
    PGCONN_COPY_OUT = PGRES_COPY_OUT,
 
43
    PGCONN_COPY_IN = PGRES_COPY_IN,
 
44
    PGCONN_BAD_RESPONSE = PGRES_BAD_RESPONSE,
 
45
    PGCONN_NONFATAL_ERROR = PGRES_NONFATAL_ERROR,
 
46
    PGCONN_FATAL_ERROR = PGRES_FATAL_ERROR
 
47
};
 
48
 
 
49
// Class declarations
 
50
class pgConn
 
51
{
 
52
public:
 
53
    pgConn(const wxString& server = wxT(""), const wxString& database = wxT(""), const wxString& username = wxT(""), const wxString& password = wxT(""), int port = 5432, int sslmode=0, OID oid=0);
 
54
    ~pgConn();
 
55
 
 
56
    void Close();
 
57
    bool HasPrivilege(const wxString &objTyp, const wxString &objName, const wxString &priv);
 
58
    bool HasFeature(int feature=0);
 
59
    bool ExecuteVoid(const wxString& sql);
 
60
    wxString ExecuteScalar(const wxString& sql);
 
61
    pgSet *ExecuteSet(const wxString& sql);
 
62
    wxString GetUser() const { return wxString(PQuser(conn), *conv); }
 
63
    wxString GetPassword() const { return wxString(PQpass(conn), *conv); }
 
64
    wxString GetHost() const { return dbHost; }
 
65
    int GetPort() const { return atoi(PQport(conn)); };
 
66
    wxString GetTTY() const { return wxString(PQtty(conn), *conv); }
 
67
    wxString GetOptions() const { return wxString(PQoptions(conn), *conv); }
 
68
    int GetBackendPID() const { return PQbackendPID(conn); }
 
69
    int GetStatus() const;
 
70
    int GetLastResultStatus() const { return lastResultStatus; }
 
71
    bool IsAlive();
 
72
    wxString GetLastError() const;
 
73
    wxString GetVersionString();
 
74
    OID GetLastSystemOID() const { return lastSystemOID; }
 
75
    OID GetDbOid() const { return dbOid; }
 
76
    bool BackendMinimumVersion(int major, int minor);
 
77
    void RegisterNoticeProcessor(PQnoticeProcessor proc, void *arg);
 
78
    wxString SystemNamespaceRestriction(const wxString &nsp);
 
79
 
 
80
    void LogError();
 
81
 
 
82
#ifdef SSL
 
83
    bool IsSSLconnected();
 
84
#endif
 
85
    PGconn *connection() { return conn; }
 
86
    void Notice(const char *msg);
 
87
 
 
88
private:
 
89
    PGconn *conn;
 
90
    int lastResultStatus;
 
91
    bool features[32];
 
92
 
 
93
    int connStatus;
 
94
    int minorVersion, majorVersion;
 
95
    wxMBConv *conv;
 
96
    bool needColQuoting;
 
97
    wxString dbHost;
 
98
    OID lastSystemOID;
 
99
    OID dbOid;
 
100
 
 
101
    void *noticeArg;
 
102
    PQnoticeProcessor noticeProc;
 
103
 
 
104
    friend class pgQueryThread;
 
105
};
 
106
 
 
107
#endif
 
108